navigate 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +22 -0
- data/README.md +85 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/navigate/conversions.rb +16 -0
- data/lib/navigate/position.rb +29 -0
- data/lib/navigate.rb +47 -0
- data/test/helper.rb +34 -0
- data/test/test_navigate.rb +71 -0
- data/test/test_position.rb +27 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53412925eb7c7c776e1e618bd00427542eed887e
|
4
|
+
data.tar.gz: 91ff503dde1685f6188940b5aa915179918e365b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2811b9ca2835e6ed8dfc9c0ee5036fbb4fb5b0b6644050f684f2dd88b34123b81be158e0bdce25b907f0326774256b626bb61ab5631ec98f214cb46c0a1c3469
|
7
|
+
data.tar.gz: 92b950abfda34c7be652384aac5c12e1639dd9be5b282fcd0e6e5010417f45998a3df1d2dfe436290e3bdc7dcda83accb08e6e8d5766efa8e62e3d5433051922
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'rake'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.2.1)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.8)
|
11
|
+
builder (3.2.2)
|
12
|
+
descendants_tracker (0.0.4)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
+
docile (1.1.5)
|
15
|
+
faraday (0.9.1)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
git (1.2.9.1)
|
18
|
+
github_api (0.12.3)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
descendants_tracker (~> 0.0.4)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 3.3)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
nokogiri (~> 1.6.3)
|
25
|
+
oauth2
|
26
|
+
hashie (3.4.1)
|
27
|
+
highline (1.7.2)
|
28
|
+
i18n (0.7.0)
|
29
|
+
jeweler (2.0.1)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.0)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
json (1.8.2)
|
39
|
+
jwt (1.4.1)
|
40
|
+
mini_portile (0.6.2)
|
41
|
+
minitest (5.6.1)
|
42
|
+
multi_json (1.11.0)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.6.6.2)
|
46
|
+
mini_portile (~> 0.6.0)
|
47
|
+
oauth2 (1.0.0)
|
48
|
+
faraday (>= 0.8, < 0.10)
|
49
|
+
jwt (~> 1.0)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (~> 1.2)
|
53
|
+
rack (1.6.0)
|
54
|
+
rake (10.4.2)
|
55
|
+
rdoc (3.12.2)
|
56
|
+
json (~> 1.4)
|
57
|
+
shoulda (3.5.0)
|
58
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
59
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
60
|
+
shoulda-context (1.2.1)
|
61
|
+
shoulda-matchers (2.8.0)
|
62
|
+
activesupport (>= 3.0.0)
|
63
|
+
simplecov (0.10.0)
|
64
|
+
docile (~> 1.1.0)
|
65
|
+
json (~> 1.8)
|
66
|
+
simplecov-html (~> 0.10.0)
|
67
|
+
simplecov-html (0.10.0)
|
68
|
+
thread_safe (0.3.5)
|
69
|
+
tzinfo (1.2.2)
|
70
|
+
thread_safe (~> 0.1)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
bundler (~> 1.0)
|
77
|
+
jeweler (~> 2.0.1)
|
78
|
+
rake
|
79
|
+
rdoc (~> 3.12)
|
80
|
+
shoulda
|
81
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jônatas Rancan de Souza
|
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,85 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/jonatasrancan/navigate.svg?branch=master)](https://travis-ci.org/jonatasrancan/navigate)
|
2
|
+
## navigate
|
3
|
+
|
4
|
+
A simple gem with some functions, to calculate the distance, bearing between two positions or
|
5
|
+
the next position considering a initial position, distance and bearing.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
In your Gemfile
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'navigate'
|
13
|
+
```
|
14
|
+
or just install
|
15
|
+
```ruby
|
16
|
+
gem install navigate
|
17
|
+
```
|
18
|
+
|
19
|
+
###Distance between 2 positions
|
20
|
+
```ruby
|
21
|
+
# the firs param is the latitude, second is the longitude
|
22
|
+
position1 = Navigate::Position.new(80.0, 120.0)
|
23
|
+
position2 = Navigate::Position.new(90.0, 45.0)
|
24
|
+
|
25
|
+
Navigate::distance_between(position1, position2)
|
26
|
+
# => 1111.9508372419155
|
27
|
+
```
|
28
|
+
By default the function will return the distane in kilometers
|
29
|
+
|
30
|
+
It has a third optional param, to define the unit of the return
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Navigate::distance_between(position1, position2, 'NM')
|
34
|
+
# => 600.4054799908141
|
35
|
+
```
|
36
|
+
Available units
|
37
|
+
```ruby
|
38
|
+
{ 'KM', 'MI', 'NM', 'YD', 'FT' }
|
39
|
+
```
|
40
|
+
|
41
|
+
### Bearing between two positions
|
42
|
+
```ruby
|
43
|
+
position1 = Navigate::Position.new(-90.0, 180.0)
|
44
|
+
position2 = Navigate::Position.new(90.0, 45.0)
|
45
|
+
|
46
|
+
Navigate::bearing(position1, position2)
|
47
|
+
# => 292.5
|
48
|
+
```
|
49
|
+
|
50
|
+
### Return a new position based on a initial position, bearing and distance
|
51
|
+
```ruby
|
52
|
+
position1 = Navigate::Position.new(-90.0, 180.0)
|
53
|
+
|
54
|
+
Navigate::bearing(position1)
|
55
|
+
# => #<Navigate::Position:0x00000003edc7b0 @latitude=-89.10067966450693, @longitude=-90.0>
|
56
|
+
```
|
57
|
+
By default the function will use a bearing = 90.0, distance = 100 KM
|
58
|
+
|
59
|
+
It receive a hash of options to pass the bearing, distance and the unit of the distance
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Navigate::bearing(position1, bearing: 180.0, distance: 150, radius_unit: 'FT')
|
63
|
+
# => #<Navigate::Position:0x00000003e9b198 @latitude=-90.0, @longitude=-180.0>
|
64
|
+
```
|
65
|
+
|
66
|
+
Contributing to navigate
|
67
|
+
------------------------
|
68
|
+
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
69
|
+
|
70
|
+
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
71
|
+
|
72
|
+
Fork the project.
|
73
|
+
|
74
|
+
Start a feature/bugfix branch.
|
75
|
+
|
76
|
+
Commit and push until you are happy with your contribution.
|
77
|
+
|
78
|
+
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
79
|
+
|
80
|
+
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
81
|
+
|
82
|
+
License
|
83
|
+
-------
|
84
|
+
The navigate gem is distributed under the MIT License.
|
85
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "navigate"
|
18
|
+
gem.homepage = "http://github.com/jonatasrancan/navigate"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A gem to help you calculate the distance, bearing or the next position on the globe}
|
21
|
+
gem.description = %Q{A gem to help you calculate the distance, bearing or the next position on the globe}
|
22
|
+
gem.email = "jonatasrancan@gmail.com"
|
23
|
+
gem.authors = ["Jônatas Rancan de Souza"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "navigate #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Float
|
2
|
+
# degrees to radians
|
3
|
+
def to_radians
|
4
|
+
self * Math::PI / 180.0
|
5
|
+
end
|
6
|
+
|
7
|
+
# radians to bearing
|
8
|
+
def to_bearing
|
9
|
+
(self.to_degrees + 360.0) % 360.0
|
10
|
+
end
|
11
|
+
|
12
|
+
# radians to degree
|
13
|
+
def to_degrees
|
14
|
+
self * 180 / Math::PI
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Navigate
|
2
|
+
class Position
|
3
|
+
attr_accessor :latitude, :longitude
|
4
|
+
|
5
|
+
def initialize(latitude, longitude)
|
6
|
+
@latitude = latitude
|
7
|
+
@longitude = longitude
|
8
|
+
|
9
|
+
valid?
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def valid_latitude?
|
15
|
+
raise 'Latitude must be between -90.0 and 90.0' unless (-90.0..90.0).include? latitude
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid_longitude?
|
19
|
+
raise 'Longitude must be between -180.0 and 180.0' unless (-180.0..180.0).include? longitude
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid?
|
23
|
+
valid_latitude?
|
24
|
+
valid_longitude?
|
25
|
+
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/navigate.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Navigate
|
2
|
+
EARTH_RADIUS = { 'KM' => 6371.009, 'MI' => 3958.761, 'NM' => 3440.070, 'YD' => 6967420, 'FT' => 20902260 }
|
3
|
+
|
4
|
+
def self.distance_between(position1, position2, radius_unit = 'KM')
|
5
|
+
Math::acos(
|
6
|
+
Math::sin(position1.latitude.to_radians) * Math::sin(position2.latitude.to_radians) +
|
7
|
+
Math::cos(position1.latitude.to_radians) * Math::cos(position2.latitude.to_radians) *
|
8
|
+
Math::cos((position2.longitude - position1.longitude).to_radians)
|
9
|
+
) * EARTH_RADIUS[radius_unit]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.bearing(position1, position2)
|
13
|
+
dLon = (position2.longitude - position1.longitude).to_radians
|
14
|
+
|
15
|
+
y = Math::sin(dLon) * Math::cos(position2.latitude.to_radians)
|
16
|
+
x = Math::cos(position1.latitude.to_radians) * Math::sin(position2.latitude.to_radians) -
|
17
|
+
Math::sin(position1.latitude.to_radians) * Math::cos(position2.latitude.to_radians) * Math::cos(dLon)
|
18
|
+
|
19
|
+
Math::atan2(y, x).to_bearing
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.destination(position, options = {})
|
23
|
+
radius = EARTH_RADIUS[options[:radius_unit] || 'KM']
|
24
|
+
distance = options[:distance] || 100.0
|
25
|
+
brng = options[:bearing] || 90.0
|
26
|
+
|
27
|
+
new_lat = Math::asin(
|
28
|
+
Math::sin(position.latitude.to_radians) * Math::cos(distance / radius) +
|
29
|
+
Math::cos(position.latitude.to_radians) * Math::sin(distance / radius) *
|
30
|
+
Math::cos(brng)
|
31
|
+
)
|
32
|
+
|
33
|
+
new_lon = position.longitude.to_radians + Math::atan2(
|
34
|
+
Math::sin(brng) * Math::sin(distance / radius) * Math::cos(position.latitude.to_radians),
|
35
|
+
Math::cos(distance / radius) - Math::sin(position.latitude.to_radians) * Math::sin(new_lat)
|
36
|
+
)
|
37
|
+
|
38
|
+
new_lon = (new_lon + Math::PI) % (2 * Math::PI) - Math::PI
|
39
|
+
|
40
|
+
Position.new new_lat.to_degrees, new_lon.to_degrees
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
path = File.expand_path(File.dirname(__FILE__))
|
45
|
+
$:.unshift path unless $:.include?(path)
|
46
|
+
require 'navigate/conversions'
|
47
|
+
require 'navigate/position'
|
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_profile 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
17
|
+
require 'rubygems'
|
18
|
+
require 'bundler'
|
19
|
+
begin
|
20
|
+
Bundler.setup(:default, :development)
|
21
|
+
rescue Bundler::BundlerError => e
|
22
|
+
$stderr.puts e.message
|
23
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
+
exit e.status_code
|
25
|
+
end
|
26
|
+
require 'minitest/autorun'
|
27
|
+
require 'shoulda'
|
28
|
+
|
29
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
+
require 'navigate'
|
32
|
+
|
33
|
+
class MiniTest::Test
|
34
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Navigate do
|
4
|
+
context "#distance" do
|
5
|
+
it 'calculates the distance between 2 positions in kilometers' do
|
6
|
+
position1 = Navigate::Position.new(90.0, 120.0)
|
7
|
+
position2 = Navigate::Position.new(90.0, 120.0)
|
8
|
+
|
9
|
+
Navigate::distance_between(position1, position2).must_equal 0
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'calculates the distance between 2 positions in kilometers' do
|
13
|
+
position1 = Navigate::Position.new(90.0, 120.0)
|
14
|
+
position2 = Navigate::Position.new(80.0, 120.0)
|
15
|
+
|
16
|
+
km = Navigate::distance_between(position1, position2).round(2)
|
17
|
+
|
18
|
+
km.must_equal 1111.95
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'calculates the distance between 2 positions in nautic miles' do
|
22
|
+
position1 = Navigate::Position.new(90.0, 120.0)
|
23
|
+
position2 = Navigate::Position.new(80.0, 120.0)
|
24
|
+
|
25
|
+
nm = Navigate::distance_between(position1, position2, 'NM').round(2)
|
26
|
+
|
27
|
+
nm.must_equal 600.41
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#bearing' do
|
32
|
+
before do
|
33
|
+
@position1 = Navigate::Position.new(90.0, 120.0)
|
34
|
+
@position2 = Navigate::Position.new(80.0, 120.0)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calculates the bearing between 2 positions' do
|
38
|
+
bearing = Navigate::bearing(@position1, @position2)
|
39
|
+
|
40
|
+
bearing.must_equal 180
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'calculates the bearing between 2 positions' do
|
44
|
+
bearing = Navigate::bearing(@position2, @position1)
|
45
|
+
|
46
|
+
bearing.must_equal 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#destination' do
|
51
|
+
it 'returns a final position, using default radius unit, distance and bearing' do
|
52
|
+
position1 = Navigate::Position.new(90.0, 120.0)
|
53
|
+
|
54
|
+
destination = Navigate::destination(position1)
|
55
|
+
|
56
|
+
assert_kind_of Navigate::Position, destination
|
57
|
+
|
58
|
+
destination.longitude.round(2).must_equal -150.0
|
59
|
+
destination.latitude.round(2).must_equal 89.1
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns a final positions, passing custom radius unit, distance and bearing' do
|
63
|
+
position1 = Navigate::Position.new(90.0, 120.0)
|
64
|
+
|
65
|
+
destination = Navigate::destination(position1, bearing: 270, radius_unit: 'NM', distance: 200)
|
66
|
+
|
67
|
+
destination.longitude.round(2).must_equal 30.0
|
68
|
+
destination.latitude.round(2).must_equal 86.67
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Navigate::Position do
|
4
|
+
context 'validations fails' do
|
5
|
+
it "raise an exception when latitude isn't between -90 and 90" do
|
6
|
+
|
7
|
+
exception = assert_raises(RuntimeError) { Navigate::Position.new(200, 100) }
|
8
|
+
|
9
|
+
assert_match /Latitude must be between -90.0 and 90.0/, exception.message
|
10
|
+
end
|
11
|
+
|
12
|
+
it "raise an exception when longitude isn't between -180 and 180" do
|
13
|
+
|
14
|
+
exception = assert_raises(RuntimeError) { Navigate::Position.new(50, 200) }
|
15
|
+
|
16
|
+
assert_match /Longitude must be between -180.0 and 180.0/, exception.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'validations pass' do
|
21
|
+
it "create a new Navigate::Positions" do
|
22
|
+
position = Navigate::Position.new(90.0, 100.0)
|
23
|
+
|
24
|
+
assert_kind_of Navigate::Position, position
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: navigate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jônatas Rancan de Souza
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shoulda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A gem to help you calculate the distance, bearing or the next position
|
84
|
+
on the globe
|
85
|
+
email: jonatasrancan@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.md
|
91
|
+
files:
|
92
|
+
- ".document"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- VERSION
|
99
|
+
- lib/navigate.rb
|
100
|
+
- lib/navigate/conversions.rb
|
101
|
+
- lib/navigate/position.rb
|
102
|
+
- test/helper.rb
|
103
|
+
- test/test_navigate.rb
|
104
|
+
- test/test_position.rb
|
105
|
+
homepage: http://github.com/jonatasrancan/navigate
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: A gem to help you calculate the distance, bearing or the next position on
|
129
|
+
the globe
|
130
|
+
test_files: []
|
131
|
+
has_rdoc:
|