google_maps_api-core 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92e13cb81580741c5fd0f99da21e10c8083b2055
4
+ data.tar.gz: 9255ae47eacef468b6448fcf1d6718a5627686cc
5
+ SHA512:
6
+ metadata.gz: c5cec562cf685dfe692622fb505d76a3eebb79e31bd23ee33951b86a5823903e32875454acb00daa4e9254301c7e89f0ada35a9fc853b127d01a2a030eed2048
7
+ data.tar.gz: b04427693f8a58665d837978345645dfdaa1ce0b476c70adbaa73a7a9851ae98c539d490c167d43820f1fdf0e9dddde30341aa6246a57ed2e7facbaa64fd51df
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in google_maps_api-core.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Felipe Zavan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # GoogleMapsAPI::Core
2
+
3
+ Common stuff used by the google_maps_api gem components.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'google_maps_api-core'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install google_maps_api-core
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/zavan/google_maps_api-core/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
26
+
27
+ ### Important
28
+
29
+ * Do not touch the version;
30
+ * Write specs for new features;
31
+ * Be independent of Rails stuff;
32
+ * All specs must pass.
33
+
34
+ ## Also see
35
+
36
+ * [http://github.com/zavan/google_maps_api-directions](http://github.com/zavan/google_maps_api-directions)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'google_maps_api/core/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "google_maps_api-core"
8
+ spec.version = GoogleMapsAPI::Core::VERSION
9
+ spec.authors = ["Felipe Zavan"]
10
+ spec.email = ["zavan@outlook.com"]
11
+ spec.summary = %q{Common stuff used by the google_maps_api gem components.}
12
+ spec.homepage = "https://github.com/zavan/google_maps_api-core"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta2", "< 4"
23
+ end
@@ -0,0 +1,9 @@
1
+ require "google_maps_api/core/metric"
2
+ require "google_maps_api/core/duration"
3
+ require "google_maps_api/core/distance"
4
+ require "google_maps_api/core/coordinate"
5
+ require "google_maps_api/core/version"
6
+
7
+ module GoogleMapsAPI
8
+ module Core; end
9
+ end
@@ -0,0 +1,40 @@
1
+ class GoogleMapsAPI::Core::Coordinate
2
+ attr_reader :lat, :lng
3
+
4
+ def initialize(lat, lng)
5
+ @lat = lat.to_f
6
+ @lng = lng.to_f
7
+ end
8
+
9
+ def latitude
10
+ lat
11
+ end
12
+
13
+ def longitude
14
+ lng
15
+ end
16
+
17
+ def lon
18
+ lng
19
+ end
20
+
21
+ def to_a
22
+ [lat, lng]
23
+ end
24
+
25
+ def to_ary
26
+ to_a
27
+ end
28
+
29
+ def to_h
30
+ {"lat" => lat, "lng" => lng}
31
+ end
32
+
33
+ def self.from_hash(hash)
34
+ self.new(hash["lat"], hash["lng"])
35
+ end
36
+
37
+ def self.from_array(array)
38
+ self.new(array[0], array[1])
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ class GoogleMapsAPI::Core::Distance < GoogleMapsAPI::Core::Metric; end
@@ -0,0 +1 @@
1
+ class GoogleMapsAPI::Core::Duration < GoogleMapsAPI::Core::Metric; end
@@ -0,0 +1,20 @@
1
+ class GoogleMapsAPI::Core::Metric
2
+ attr_reader :text, :value
3
+
4
+ def initialize(text, value)
5
+ @text = text.to_s
6
+ @value = value.to_i
7
+ end
8
+
9
+ def to_s
10
+ text
11
+ end
12
+
13
+ def to_i
14
+ value
15
+ end
16
+
17
+ def self.from_hash(hash)
18
+ self.new(hash["text"], hash["value"])
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module GoogleMapsAPI
2
+ module Core
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe GoogleMapsAPI::Core::Coordinate do
4
+
5
+ subject { GoogleMapsAPI::Core::Coordinate.new(1.0, -1.0) }
6
+
7
+ describe "#latitude" do
8
+ it "returns lat" do
9
+ expect(subject.latitude).to eq(subject.lat)
10
+ end
11
+ end
12
+
13
+ describe "#longitude" do
14
+ it "returns lng" do
15
+ expect(subject.longitude).to eq(subject.lng)
16
+ end
17
+ end
18
+
19
+ describe "#to_a" do
20
+ it "returns an array" do
21
+ expect(subject.to_a).to eq([subject.lat, subject.lng])
22
+ end
23
+ end
24
+
25
+ describe "#to_h" do
26
+ it "returns a hash" do
27
+ expect(subject.to_h).to eq({"lat" => subject.lat, "lng" => subject.lng})
28
+ end
29
+ end
30
+
31
+ describe ".from_hash" do
32
+ subject { GoogleMapsAPI::Core::Coordinate }
33
+
34
+ it "returns a new coordinate" do
35
+ expect(subject.from_hash({"lat" => 1.0, "lng" => 1.0})).to be_a(subject)
36
+ end
37
+ end
38
+
39
+ describe ".from_array" do
40
+ subject { GoogleMapsAPI::Core::Coordinate }
41
+
42
+ it "returns a new coordinate" do
43
+ expect(subject.from_array([1.0, 1.0])).to be_a(subject)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe GoogleMapsAPI::Core::Metric do
4
+ subject { GoogleMapsAPI::Core::Metric.new("1.0 mi", 1) }
5
+
6
+ describe "#to_s" do
7
+ it "returns the text" do
8
+ expect(subject.to_s).to eq(subject.text)
9
+ end
10
+ end
11
+
12
+ describe "#to_i" do
13
+ it "returns the value" do
14
+ expect(subject.to_i).to eq(subject.value)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,84 @@
1
+ require "google_maps_api/core"
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
6
+ # file to always be loaded, without a need to explicitly require it in any files.
7
+ #
8
+ # Given that it is always loaded, you are encouraged to keep this file as
9
+ # light-weight as possible. Requiring heavyweight dependencies from this file
10
+ # (such as loading up an entire rails app) will add to the boot time of your
11
+ # test suite on EVERY test run, even for an individual file that may not need
12
+ # all of that loaded.
13
+ #
14
+ # The `.rspec` file also contains a few flags that are not defaults but that
15
+ # users commonly want.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # The settings below are suggested to provide a good initial experience
20
+ # with RSpec, but feel free to customize to your heart's content.
21
+ =begin
22
+ # These two settings work together to allow you to limit a spec run
23
+ # to individual examples or groups you care about by tagging them with
24
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
25
+ # get run.
26
+ config.filter_run :focus
27
+ config.run_all_when_everything_filtered = true
28
+
29
+ # Many RSpec users commonly either run the entire suite or an individual
30
+ # file, and it's useful to allow more verbose output when running an
31
+ # individual spec file.
32
+ if config.files_to_run.one?
33
+ # RSpec filters the backtrace by default so as not to be so noisy.
34
+ # This causes the full backtrace to be printed when running a single
35
+ # spec file (e.g. to troubleshoot a particular spec failure).
36
+ config.full_backtrace = true
37
+
38
+ # Use the documentation formatter for detailed output,
39
+ # unless a formatter has already been configured
40
+ # (e.g. via a command-line flag).
41
+ config.formatter = 'doc' if config.formatters.none?
42
+ end
43
+
44
+ # Print the 10 slowest examples and example groups at the
45
+ # end of the spec run, to help surface which specs are running
46
+ # particularly slow.
47
+ config.profile_examples = 10
48
+
49
+ # Run specs in random order to surface order dependencies. If you find an
50
+ # order dependency and want to debug it, you can fix the order by providing
51
+ # the seed, which is printed after each run.
52
+ # --seed 1234
53
+ config.order = :random
54
+
55
+ # Seed global randomization in this process using the `--seed` CLI option.
56
+ # Setting this allows you to use `--seed` to deterministically reproduce
57
+ # test failures related to randomization by passing the same `--seed` value
58
+ # as the one that triggered the failure.
59
+ Kernel.srand config.seed
60
+
61
+ # rspec-expectations config goes here. You can use an alternate
62
+ # assertion/expectation library such as wrong or the stdlib/minitest
63
+ # assertions if you prefer.
64
+ config.expect_with :rspec do |expectations|
65
+ # Enable only the newer, non-monkey-patching expect syntax.
66
+ # For more details, see:
67
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
68
+ expectations.syntax = :expect
69
+ end
70
+
71
+ # rspec-mocks config goes here. You can use an alternate test double
72
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
73
+ config.mock_with :rspec do |mocks|
74
+ # Enable only the newer, non-monkey-patching expect syntax.
75
+ # For more details, see:
76
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
77
+ mocks.syntax = :expect
78
+
79
+ # Prevents you from mocking or stubbing a method that does not exist on
80
+ # a real object. This is generally recommended.
81
+ mocks.verify_partial_doubles = true
82
+ end
83
+ =end
84
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_maps_api-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felipe Zavan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0.beta2
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '4'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.0.0.beta2
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '4'
61
+ description:
62
+ email:
63
+ - zavan@outlook.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - ".rspec"
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - google_maps_api-core.gemspec
75
+ - lib/google_maps_api/core.rb
76
+ - lib/google_maps_api/core/coordinate.rb
77
+ - lib/google_maps_api/core/distance.rb
78
+ - lib/google_maps_api/core/duration.rb
79
+ - lib/google_maps_api/core/metric.rb
80
+ - lib/google_maps_api/core/version.rb
81
+ - spec/google_maps_api/core/coordinate_spec.rb
82
+ - spec/google_maps_api/core/metric_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/zavan/google_maps_api-core
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Common stuff used by the google_maps_api gem components.
108
+ test_files:
109
+ - spec/google_maps_api/core/coordinate_spec.rb
110
+ - spec/google_maps_api/core/metric_spec.rb
111
+ - spec/spec_helper.rb