geoip_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +60 -3
  3. data/lib/geoip_rails/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6f3dd3571e8ece7ff0f08cf8efb6ea12615d529
4
- data.tar.gz: 0ee67e2beb9528a0914d66a08fde2f0e0281da54
3
+ metadata.gz: 6e3b4e789c007000b5362101181f33ac700281d4
4
+ data.tar.gz: 339c7adfa4ccbfc62ded5acd6a0c2f595a0b3edc
5
5
  SHA512:
6
- metadata.gz: 7505f237242a2ab875ed7c6e1c5578b46f8793be8da2f9c2041addfee9ac92e77f4369697fe01a318aaf871c35305a82e4b98792adf5948dcaf1a2da630eb383
7
- data.tar.gz: e557bd37ca703b4869ac4a85c188a340f3e99bbf6b0c4e8262667b147a37a935a4395330e8a2359debc5261ed7dd7db996636017f8f8a152b7f3691129805b54
6
+ metadata.gz: 99d9bd5bdc49318964e34d989f135c9c35ea71c2fea6155c7962d2ebdf40a3e157e1603c01dff986e6de08f666511a5247094f4a8ef558799b2f1ae0f3ab4354
7
+ data.tar.gz: 109a169dabc1cfa8fffa77d7a24c9b51db229ca7069d53cd2403aeff287ed1889334e83b4e1fce3994365097fe45ab2c585c4eb043c4685f6d656aa93e26cdbf
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # GeoipRails
2
2
 
3
- TODO: Write a gem description
4
-
3
+ Gives geolocation details based on an IP address or a host name
4
+ The gem uses freegeoip's API to fetch geolocation data given an IP address. freegeoip.net is a public REST API for searching geolocation of IP addresses and host names. Thanks to http://freegeoip.net/ for providing such a great API
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
@@ -18,7 +18,63 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ You can pass the IP address/hostname for which you want to check geolocation data to:
22
+
23
+ GeoipRails.find_by_ip("208.95.216.41")
24
+ GeoipRails.find_by_ip("google.com")
25
+
26
+ These return the hashes below:
27
+
28
+ {"ip"=>"208.95.216.41", "country_code"=>"US", "country_name"=>"United States",
29
+ "region_code"=>"VT", "region_name"=>"Vermont", "city"=>"Colchester", "zipcode"=>"05446",
30
+ "latitude"=>44.55, "longitude"=>-73.1552, "metro_code"=>"523", "area_code"=>"802"}
31
+
32
+ And
33
+
34
+ {"ip"=>"173.194.115.72", "country_code"=>"US", "country_name"=>"United States",
35
+ "region_code"=>"CA", "region_name"=>"California", "city"=>"Mountain View", "zipcode"=>"94043",
36
+ "latitude"=>37.4192, "longitude"=>-122.0574, "metro_code"=>"807", "area_code"=>"650"}
37
+
38
+ for the second case.
39
+
40
+ You can of course select your desired value from this hash i.e.
41
+
42
+ GeoipRails.find_by_ip("208.95.216.41")["country_name"]
43
+ => "United States"
44
+ GeoipRails.find_by_ip("208.95.216.41")["country_code"]
45
+ => "US"
46
+
47
+ And so on. But we have shorthand methods for all this as shown below:
48
+
49
+ GeoipRails.country("208.95.216.41")
50
+ => "United States"
51
+ GeoipRails.city("208.95.216.41")
52
+ => "Colchester"
53
+ GeoipRails.area_code("208.95.216.41")
54
+ => "802"
55
+ GeoipRails.metro_code("208.95.216.41")
56
+ => "523"
57
+ GeoipRails.zipcode("208.95.216.41")
58
+ => "05446"
59
+ GeoipRails.region_code("208.95.216.41")
60
+ => "VT"
61
+ GeoipRails.region_name("208.95.216.41")
62
+ => "Vermont"
63
+ GeoipRails.latitude("208.95.216.41")
64
+ => 44.55
65
+ GeoipRails.longitude("208.95.216.41")
66
+ => -73.1552
67
+
68
+ ## Pros and Cons
69
+
70
+ ### Pros
71
+ This gem relies on the freegeoip.net API which already has an internal database with geolocation information, which is queried via the API. This means that you don't have to deal with the database yourself as you would with some of the gems out there.
72
+ ### Cons
73
+ The freegoip.net API has a usage limit but, you will probably never have to worry about it. API usage is limited to 10,000 queries per hour. After reaching this limit, all requests will result in HTTP 403 (Forbidden) until the roll over.
74
+
75
+ If the usage limit is a problem, please consider running your own instance of this system. It's open source and freely available at GitHub.
76
+
77
+ Download the source code at https://github.com/fiorix/freegeoip.
22
78
 
23
79
  ## Contributing
24
80
 
@@ -27,3 +83,4 @@ TODO: Write usage instructions here
27
83
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
84
  4. Push to the branch (`git push origin my-new-feature`)
29
85
  5. Create new Pull Request
86
+
@@ -1,3 +1,3 @@
1
1
  module GeoipRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - muaad