simple_geolocation 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ module SimpleGeolocation
8
8
  Location::ATTRIBUTES + [:completeness]
9
9
  end
10
10
 
11
- delegate :lat, :lng, :city, :state, :provider, :zip, :street, :district, :number, :completeness, :to => :location
11
+ delegate :lat, :lng, :city, :state, :country, :provider, :zip, :street, :district, :number, :completeness, :to => :location
12
12
 
13
13
  def initialize(raw_location)
14
14
  @raw_location = raw_location
@@ -16,14 +16,12 @@ module SimpleGeolocation
16
16
 
17
17
  def get_location!
18
18
  result = ip_geocoder.city(geocoder.raw_location)
19
- if @success = result && result.city_name.present? && result.region_name.present?
20
- @location = Location.new(
21
- :lat => result.latitude,
22
- :lng => result.longitude,
23
- :city => result.city_name,
24
- :state => result.region_name,
25
- :provider => "geoip"
26
- )
19
+ if @success = result && result.latitude.present? && result.longitude.present?
20
+ new_raw_location = "#{result.latitude}, #{result.longitude}"
21
+ geokit = Geokit.new(Geocoder.new(new_raw_location))
22
+ geokit.process!
23
+ @success = geokit.success?
24
+ @location = geokit.location
27
25
  else
28
26
  Geokit.new(geocoder).process!
29
27
  end
@@ -22,6 +22,7 @@ module SimpleGeolocation
22
22
  :lng => result.lng,
23
23
  :city => result.city,
24
24
  :state => result.state,
25
+ :country => result.country,
25
26
  :street => result.street_name,
26
27
  :number => result.street_number,
27
28
  :zip => result.zip,
@@ -1,6 +1,6 @@
1
1
  module SimpleGeolocation
2
2
  class Location
3
- ATTRIBUTES = [:lat, :lng, :city, :state, :provider, :zip, :street, :district, :number]
3
+ ATTRIBUTES = [:lat, :lng, :city, :state, :country, :provider, :zip, :street, :district, :number]
4
4
  attr_accessor *ATTRIBUTES
5
5
 
6
6
  def initialize(attributes = {})
@@ -1,3 +1,3 @@
1
1
  module SimpleGeolocation
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -5,7 +5,7 @@ describe SimpleGeolocation do
5
5
 
6
6
 
7
7
  it 'should identify if the given location is an ip' do
8
- @geo = SimpleGeolocation::Geocoder.new("74.125.113.105")
8
+ @geo = SimpleGeolocation::Geocoder.new("189.58.112.247")
9
9
  @geo.ip?.should be_true
10
10
  @geo.zip?.should be_false
11
11
  @geo.address?.should be_false
@@ -26,13 +26,16 @@ describe SimpleGeolocation do
26
26
  end
27
27
 
28
28
  it "should return the location of an user's based on IP" do
29
- @geo = SimpleGeolocation::Geocoder.new("74.125.113.105")
29
+ @geo = SimpleGeolocation::Geocoder.new("189.58.112.247")
30
30
  @geo.ip?.should be_true
31
31
  @geo.geocode!
32
32
  @geo.success?.should be_true
33
- @geo.lat.should == 37.41919999999999
34
- @geo.lng.should == -122.0574
35
- @geo.completeness.should == 55
33
+ @geo.lat.should == -26.3001576
34
+ @geo.lng.should == -48.8320838
35
+ @geo.city.should == "Joinville"
36
+ @geo.state.should == "SC"
37
+ @geo.country.should == "Brasil"
38
+ @geo.completeness.should == 90
36
39
  end
37
40
 
38
41
  it "should return the location of an ordinary address" do
@@ -42,7 +45,7 @@ describe SimpleGeolocation do
42
45
  @geo.success?.should be_true
43
46
  @geo.lat.should == -26.30101
44
47
  @geo.lng.should == -48.8452974
45
- @geo.completeness.should == 88
48
+ @geo.completeness.should == 90
46
49
  end
47
50
 
48
51
  it "should return the location of a brazilian zipcode (CEP)" do
@@ -57,7 +60,7 @@ describe SimpleGeolocation do
57
60
  @geo.zip.should == "22640-100"
58
61
  @geo.lat.should == -23.0032808
59
62
  @geo.lng.should == -43.3230295
60
- @geo.completeness.should == 88
63
+ @geo.completeness.should == 90
61
64
  end
62
65
 
63
66
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_geolocation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
5
+ version: 0.0.6
11
6
  platform: ruby
12
7
  authors:
13
8
  - Esdras Mayrink
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-10 00:00:00 -03:00
13
+ date: 2011-04-21 00:00:00 -03:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,9 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
24
  version: "0"
33
25
  type: :development
34
26
  version_requirements: *id001
@@ -40,9 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
35
  version: "0"
47
36
  type: :runtime
48
37
  version_requirements: *id002
@@ -54,9 +43,6 @@ dependencies:
54
43
  requirements:
55
44
  - - ">="
56
45
  - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
46
  version: "0"
61
47
  type: :runtime
62
48
  version_requirements: *id003
@@ -68,9 +54,6 @@ dependencies:
68
54
  requirements:
69
55
  - - ">="
70
56
  - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
57
  version: "0"
75
58
  type: :runtime
76
59
  version_requirements: *id004
@@ -82,9 +65,6 @@ dependencies:
82
65
  requirements:
83
66
  - - ">="
84
67
  - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
68
  version: "0"
89
69
  type: :runtime
90
70
  version_requirements: *id005
@@ -129,23 +109,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
109
  requirements:
130
110
  - - ">="
131
111
  - !ruby/object:Gem::Version
132
- hash: 3
133
- segments:
134
- - 0
135
112
  version: "0"
136
113
  required_rubygems_version: !ruby/object:Gem::Requirement
137
114
  none: false
138
115
  requirements:
139
116
  - - ">="
140
117
  - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
118
  version: "0"
145
119
  requirements: []
146
120
 
147
121
  rubyforge_project: simple_geolocation
148
- rubygems_version: 1.4.1
122
+ rubygems_version: 1.5.2
149
123
  signing_key:
150
124
  specification_version: 3
151
125
  summary: A gem that fetch locations based on IP, ZIP and ordinary address through several existing geolocation gems.