google-maps 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99e37aed73a33c0d720a2028b68da7062e844ec7
4
- data.tar.gz: f9b122db7e86ffe2ec0e7fa2e0fd8416be4d5cad
3
+ metadata.gz: 13f8b08401429d693bf7b68fc78d5f215be09eb0
4
+ data.tar.gz: 001d41179c93c787757a42cfce0b1738aa267673
5
5
  SHA512:
6
- metadata.gz: a3e2ba9ef478660f882dafcfb5bf875fa225fa8ff4af2c6f2af61b92aa94372d579697de7e64692b82edffceb86ed02f1f299afe6a8e56977e34597f4911a52a
7
- data.tar.gz: 8306f41b80d5180a3bba0ab0b104dbf0ae74031d47e0d49af2cce94fecbdb31f814454ccb8e58fda8f65834197f3d58c3b9e9703aa22ec60a146c9a4171862dc
6
+ metadata.gz: 924bdce3f76819f03c4f2f51618a692874efb12cc69d77d6d2ae038d1d9b825cf1bdb53a746ed21eaca6921ca2a78d30311f64895c41461a9643f3b218acdf9e
7
+ data.tar.gz: 16b04aebffcac817ee1c7d298110f0433718ce0ed3c54bf43a557bb1d45352bdac83cee720b44456ea4754aa4d17ea329e747edad7dfc554560f433610c85895
data/README.mkd CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/zilverline/google-maps.svg?branch=master)](https://travis-ci.org/zilverline/google-maps)
2
- [![Coverage Status](https://coveralls.io/repos/zilverline/google-maps/badge.svg)](https://coveralls.io/r/zilverline/google-maps)
2
+ [![Coverage Status](https://coveralls.io/repos/zilverline/google-maps/badge.svg?branch=master)](https://coveralls.io/r/zilverline/google-maps?branch=master)
3
3
  [![Code Climate](https://codeclimate.com/repos/55671579695680044d01e0ac/badges/8f4d88f30585847e4fcf/gpa.svg)](https://codeclimate.com/repos/55671579695680044d01e0ac/feed)
4
4
 
5
5
  Google Maps
@@ -8,19 +8,19 @@ module Google
8
8
  module Maps
9
9
  extend Configuration
10
10
  extend Logger
11
-
12
- def self.route(from, to, language = self.default_language)
13
- Route.new(from, to, language)
11
+
12
+ def self.route(from, to, options={})
13
+ Route.new(from, to, options_with_defaults(options))
14
14
  end
15
-
16
- def self.distance(from, to, language = self.default_language)
17
- Route.new(from, to, language).distance.text
15
+
16
+ def self.distance(from, to, options={})
17
+ Route.new(from, to, options_with_defaults(options)).distance.text
18
18
  end
19
-
20
- def self.duration(from, to, language = self.default_language)
21
- Route.new(from, to, language).duration.text
19
+
20
+ def self.duration(from, to, options={})
21
+ Route.new(from, to, options_with_defaults(options)).duration.text
22
22
  end
23
-
23
+
24
24
  def self.places(keyword, language = self.default_language)
25
25
  Place.find(keyword, language)
26
26
  end
@@ -34,5 +34,11 @@ module Google
34
34
  rescue ZeroResultsException
35
35
  []
36
36
  end
37
+
38
+ protected
39
+
40
+ def self.options_with_defaults(options)
41
+ {language: self.default_language}.merge(options)
42
+ end
37
43
  end
38
44
  end
@@ -2,12 +2,13 @@ require File.expand_path('../api', __FILE__)
2
2
 
3
3
  module Google
4
4
  module Maps
5
-
5
+
6
6
  class Route
7
- attr_accessor :from, :to, :language
8
-
9
- def initialize(from, to, language=:en)
10
- @from, @to, @language = from, to, language
7
+ attr_accessor :from, :to, :options
8
+
9
+ def initialize(from, to, options={})
10
+ options = {language: options} unless options.is_a? Hash
11
+ @from, @to, @options = from, to, {language: :en}.merge(options)
11
12
  end
12
13
 
13
14
  def method_missing(name, *args, &block)
@@ -17,21 +18,21 @@ module Google
17
18
  super
18
19
  end
19
20
  end
20
-
21
+
21
22
  def origin_latlong
22
23
  "#{self.start_location.lat},#{self.start_location.lng}"
23
24
  end
24
-
25
+
25
26
  def destination_latlong
26
27
  "#{self.end_location.lat},#{self.end_location.lng}"
27
28
  end
28
-
29
+
29
30
  private
30
31
  def route
31
32
  # default to the first returned route (the most efficient one)
32
- @response ||= API.query(:directions_service, :origin => from, :destination => to, :language => language).routes.first
33
+ @response ||= API.query(:directions_service, @options.merge(origin: from, destination: to)).routes.first
33
34
  end
34
35
  end
35
-
36
+
36
37
  end
37
- end
38
+ end
@@ -1,5 +1,5 @@
1
1
  module Google
2
2
  module Maps
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -6,47 +6,47 @@ describe Google::Maps::Route do
6
6
  stub_response("amsterdam-deventer-nl.json")
7
7
  @route = Google::Maps::Route.new("Science Park, Amsterdam", "Deventer", :nl)
8
8
  end
9
-
9
+
10
10
  it "should be able to calculate a route" do
11
11
  @route.distance.text.should == "104 km"
12
12
  @route.duration.text.should == "1 uur 12 min."
13
13
  @route.distance.value.should == 103712
14
14
  @route.duration.value.should == 4337
15
15
  end
16
-
16
+
17
17
  it "should be able to present the text in Dutch" do
18
- @route.language.should == :nl
18
+ @route.options[:language].should == :nl
19
19
  @route.end_address.should == "Deventer, Nederland"
20
20
  end
21
21
 
22
22
  it "should be able to return the address for the origin" do
23
23
  @route.start_address.should == "Science Park, 1098 Amsterdam, Nederland"
24
24
  end
25
-
25
+
26
26
  it "should be able to return the address for the destination" do
27
27
  @route.end_address.should == "Deventer, Nederland"
28
28
  end
29
-
29
+
30
30
  it "should be able to return the latiude and longitude for the origin" do
31
31
  @route.start_location.lat.should == 52.35445000000001
32
32
  @route.start_location.lng.should == 4.95420
33
33
  @route.origin_latlong.should == "52.35445000000001,4.9542"
34
34
  end
35
-
35
+
36
36
  it "should be able to return the latiude and longitude for the destination" do
37
37
  @route.end_location.lat.should == 52.25441000000001
38
38
  @route.end_location.lng.should == 6.160470
39
39
  @route.destination_latlong.should == "52.25441000000001,6.16047"
40
40
  end
41
41
  end
42
-
42
+
43
43
  describe "english" do
44
44
  it "should be able to present the text in English" do
45
45
  stub_response("amsterdam-deventer-en.json")
46
46
  route = Google::Maps::Route.new("Science Park, Amsterdam", "Deventer", :en)
47
- route.language.should == :en
47
+ route.options[:language].should == :en
48
48
  route.end_address.should == "Deventer, The Netherlands"
49
49
  end
50
50
  end
51
51
 
52
- end
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel van Hoesel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler