go_maps 0.3.2 → 0.4
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.
- data/Rakefile +1 -1
 - data/go_maps.gemspec +2 -2
 - data/lib/go_maps/address.rb +12 -0
 - data/spec/go_maps/address_spec.rb +27 -0
 - metadata +4 -5
 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -7,7 +7,7 @@ begin 
     | 
|
| 
       7 
7 
     | 
    
         
             
              require 'jeweler'
         
     | 
| 
       8 
8 
     | 
    
         
             
              Jeweler::Tasks.new do |gem|
         
     | 
| 
       9 
9 
     | 
    
         
             
                gem.name = "go_maps"
         
     | 
| 
       10 
     | 
    
         
            -
                gem.version = "0. 
     | 
| 
      
 10 
     | 
    
         
            +
                gem.version = "0.4"
         
     | 
| 
       11 
11 
     | 
    
         
             
                gem.summary = %Q{Ruby API to geographic operations}
         
     | 
| 
       12 
12 
     | 
    
         
             
                gem.description = %Q{Ruby API to geographic operations}
         
     | 
| 
       13 
13 
     | 
    
         
             
                gem.homepage = "http://github.com/gonow/go_maps"
         
     | 
    
        data/go_maps.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{go_maps}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.4"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Gonow"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-08 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-12-08}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{Ruby API to geographic operations}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
       15 
15 
     | 
    
         
             
                "README.markdown"
         
     | 
    
        data/lib/go_maps/address.rb
    CHANGED
    
    | 
         @@ -17,6 +17,14 @@ module GoMaps 
     | 
|
| 
       17 
17 
     | 
    
         
             
                  directions_to(address, "&language=#{options[:language]}")['routes'].first['legs'].first rescue raise AddressNotFoundException
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
                def latitude
         
     | 
| 
      
 21 
     | 
    
         
            +
                  geometry["lat"]
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def longitude
         
     | 
| 
      
 25 
     | 
    
         
            +
                  geometry["lng"]
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       20 
28 
     | 
    
         
             
                private
         
     | 
| 
       21 
29 
     | 
    
         | 
| 
       22 
30 
     | 
    
         
             
                def directions_to(address, language)
         
     | 
| 
         @@ -27,6 +35,10 @@ module GoMaps 
     | 
|
| 
       27 
35 
     | 
    
         
             
                  api_response :geocode, "address=#{@address}"
         
     | 
| 
       28 
36 
     | 
    
         
             
                end
         
     | 
| 
       29 
37 
     | 
    
         | 
| 
      
 38 
     | 
    
         
            +
                def geometry
         
     | 
| 
      
 39 
     | 
    
         
            +
                  @geometry ||= location["results"].first["geometry"]["location"]
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       30 
42 
     | 
    
         
             
                def api_response(api, query_string)
         
     | 
| 
       31 
43 
     | 
    
         
             
                  Crack::JSON.parse open(URI.escape(url_for(api) + query_string)).read
         
     | 
| 
       32 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -28,5 +28,32 @@ describe GoMaps::Address do 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  lambda { GoMaps::Address.new(address1).distance_to(address2) }.should raise_error(GoMaps::AddressNotFoundException)
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              context "on #latitude" do
         
     | 
| 
      
 33 
     | 
    
         
            +
                it "should return the address latitude" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  address = 'Valid Address'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  map_address_to_file address, 'address_success'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  GoMaps::Address.new(address).latitude.should eql(-20.801184)
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              context "on #longitude" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                it "should return the address longitude" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  address = 'Valid Address'
         
     | 
| 
      
 43 
     | 
    
         
            +
                  map_address_to_file address, 'address_success'
         
     | 
| 
      
 44 
     | 
    
         
            +
                  GoMaps::Address.new(address).longitude.should eql(-49.3747043)
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              context "when requesting coordenates" do
         
     | 
| 
      
 49 
     | 
    
         
            +
                it "should call the Google Maps service only once" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  address = 'Valid Address'
         
     | 
| 
      
 51 
     | 
    
         
            +
                  map_address_to_file address, 'address_success'
         
     | 
| 
      
 52 
     | 
    
         
            +
                  gomaps = GoMaps::Address.new address
         
     | 
| 
      
 53 
     | 
    
         
            +
                  gomaps.latitude
         
     | 
| 
      
 54 
     | 
    
         
            +
                  gomaps.should_not_receive(:open)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  gomaps.longitude
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
       31 
58 
     | 
    
         
             
            end
         
     | 
| 
       32 
59 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: go_maps
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
              version: 0.3.2
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 4
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: "0.4"
         
     | 
| 
       11 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
12 
     | 
    
         
             
            - Gonow
         
     | 
| 
         @@ -15,7 +14,7 @@ autorequire: 
     | 
|
| 
       15 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2010-08 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-12-08 00:00:00 -02:00
         
     | 
| 
       19 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |