Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matsumotory/mruby-geoip
GeoIP mrbgem using GeoIPCity.dat
https://github.com/matsumotory/mruby-geoip
Last synced: about 2 months ago
JSON representation
GeoIP mrbgem using GeoIPCity.dat
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-geoip
- Owner: matsumotory
- License: other
- Created: 2014-12-03T05:57:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-02-13T05:27:33.000Z (almost 7 years ago)
- Last Synced: 2024-10-18T18:25:49.723Z (3 months ago)
- Language: C
- Size: 17.6 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mruby-geoip [![Build Status](https://travis-ci.org/matsumotory/mruby-geoip.png?branch=master)](https://travis-ci.org/matsumotory/mruby-geoip)
GeoIPCity class using [GeoIPCity.dat](http://dev.maxmind.com/geoip/legacy/install/city/) for mruby
## install by mrbgems
- add conf.gem line to `build_config.rb````ruby
MRuby::Build.new do |conf|# ... (snip) ...
conf.gem :github => 'matsumoto-r/mruby-geoip'
end
```
## example
```ruby
db_path = "/usr/share/GeoIP/GeoIPCity.dat"
host = "www.google.com"geoip = GeoIP.new db_path
# You can use record_by_addr when using IP address into host
geoip.record_by_name hostgeoip.country_code #=> "US"
geoip.region #=> "CA"
geoip.region_name #=> "California"
geoip.city #=> "Mountain View"
geoip.postal_code #=> "94043"
geoip.latitude.round(4) #=> 37.4192
geoip.longitude.round(4) #=> -122.0574
geoip.metro_code #=> 807
geoip.area_code #=> 650
geoip.time_zone #=> "America/Los_Angeles"
```## License
under the MIT License:
- see LICENSE file