compass_point 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +40 -33
- data/LICENSE +1 -1
- data/README.md +9 -3
- data/lib/compass_point.rb +8 -1
- data/spec/compass_point_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29afdaca55d9941d699c163cac5545b2adb7151c20bf17ca7fa0716ba5d274eb
|
4
|
+
data.tar.gz: c7bf9b39285b1202642fec3fe215c5b604d83da9df58a11e6483a8326021c927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8d5d5cccb2694d5f4d5d66e8dd1a326d9d942ef3e0c9a941658f14b2a0fefa0495f30fdc411e46c594f4b0155307cf1b8da65e3d2d235c8a3a055169bf55fb2
|
7
|
+
data.tar.gz: 31488e6a4d21c87a5d0f3cf42a9f4504374e8fc0c3ffdfba1fcdc784eeb279b52babb40323ba7b021bf9b5c74a6eb65aa0a740274e2f35aede8dba210ec0cd05
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
compass_point (1.2.
|
4
|
+
compass_point (1.2.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -9,9 +9,9 @@ GEM
|
|
9
9
|
ast (2.4.0)
|
10
10
|
coderay (1.1.2)
|
11
11
|
diff-lcs (1.3)
|
12
|
-
ffi (1.
|
12
|
+
ffi (1.11.1)
|
13
13
|
formatador (0.2.5)
|
14
|
-
guard (2.
|
14
|
+
guard (2.15.0)
|
15
15
|
formatador (>= 0.2.4)
|
16
16
|
listen (>= 2.7, < 4.0)
|
17
17
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -25,52 +25,57 @@ GEM
|
|
25
25
|
guard (~> 2.1)
|
26
26
|
guard-compat (~> 1.1)
|
27
27
|
rspec (>= 2.99.0, < 4.0)
|
28
|
+
irb (1.0.0)
|
29
|
+
jaro_winkler (1.5.2)
|
28
30
|
listen (3.1.5)
|
29
31
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
30
32
|
rb-inotify (~> 0.9, >= 0.9.7)
|
31
33
|
ruby_dep (~> 1.2)
|
32
|
-
lumberjack (1.0.
|
33
|
-
method_source (0.9.
|
34
|
+
lumberjack (1.0.13)
|
35
|
+
method_source (0.9.2)
|
34
36
|
nenv (0.3.0)
|
35
37
|
notiffany (0.1.1)
|
36
38
|
nenv (~> 0.1)
|
37
39
|
shellany (~> 0.0)
|
38
|
-
parallel (1.
|
39
|
-
parser (2.
|
40
|
-
ast (~> 2.
|
41
|
-
|
42
|
-
pry (0.11.3)
|
40
|
+
parallel (1.17.0)
|
41
|
+
parser (2.6.3.0)
|
42
|
+
ast (~> 2.4.0)
|
43
|
+
pry (0.12.2)
|
43
44
|
coderay (~> 1.1.0)
|
44
45
|
method_source (~> 0.9.0)
|
45
46
|
rainbow (3.0.0)
|
46
|
-
rb-fsevent (0.10.
|
47
|
-
rb-inotify (0.
|
48
|
-
ffi (
|
49
|
-
rspec (3.
|
50
|
-
rspec-core (~> 3.
|
51
|
-
rspec-expectations (~> 3.
|
52
|
-
rspec-mocks (~> 3.
|
53
|
-
rspec-core (3.
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-expectations (3.
|
47
|
+
rb-fsevent (0.10.3)
|
48
|
+
rb-inotify (0.10.0)
|
49
|
+
ffi (~> 1.0)
|
50
|
+
rspec (3.8.0)
|
51
|
+
rspec-core (~> 3.8.0)
|
52
|
+
rspec-expectations (~> 3.8.0)
|
53
|
+
rspec-mocks (~> 3.8.0)
|
54
|
+
rspec-core (3.8.0)
|
55
|
+
rspec-support (~> 3.8.0)
|
56
|
+
rspec-expectations (3.8.3)
|
56
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
-
rspec-support (~> 3.
|
58
|
-
rspec-mocks (3.
|
58
|
+
rspec-support (~> 3.8.0)
|
59
|
+
rspec-mocks (3.8.0)
|
59
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
-
rspec-support (~> 3.
|
61
|
-
rspec-support (3.
|
62
|
-
rubocop (0.
|
61
|
+
rspec-support (~> 3.8.0)
|
62
|
+
rspec-support (3.8.0)
|
63
|
+
rubocop (0.71.0)
|
64
|
+
jaro_winkler (~> 1.5.1)
|
63
65
|
parallel (~> 1.10)
|
64
|
-
parser (>= 2.
|
65
|
-
powerpack (~> 0.1)
|
66
|
+
parser (>= 2.6)
|
66
67
|
rainbow (>= 2.2.2, < 4.0)
|
67
68
|
ruby-progressbar (~> 1.7)
|
68
|
-
unicode-display_width (
|
69
|
-
|
69
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
70
|
+
rubocop-performance (1.3.0)
|
71
|
+
rubocop (>= 0.68.0)
|
72
|
+
rubocop-rspec (1.33.0)
|
73
|
+
rubocop (>= 0.60.0)
|
74
|
+
ruby-progressbar (1.10.1)
|
70
75
|
ruby_dep (1.5.0)
|
71
76
|
shellany (0.0.1)
|
72
|
-
thor (0.20.
|
73
|
-
unicode-display_width (1.
|
77
|
+
thor (0.20.3)
|
78
|
+
unicode-display_width (1.6.0)
|
74
79
|
|
75
80
|
PLATFORMS
|
76
81
|
ruby
|
@@ -79,8 +84,10 @@ DEPENDENCIES
|
|
79
84
|
compass_point!
|
80
85
|
guard
|
81
86
|
guard-rspec
|
87
|
+
irb
|
82
88
|
rspec
|
83
|
-
rubocop
|
89
|
+
rubocop-performance
|
90
|
+
rubocop-rspec
|
84
91
|
|
85
92
|
BUNDLED WITH
|
86
|
-
1.
|
93
|
+
1.17.2
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Compass Point
|
2
2
|
[![Version](http://img.shields.io/gem/v/compass_point.svg?style=flat)](https://rubygems.org/gems/compass_point)
|
3
3
|
[![Build Status](http://img.shields.io/travis/infused/compass_point/master.svg?style=flat)](http://travis-ci.org/infused/compass_point)
|
4
|
-
[![Dependency Status](http://img.shields.io/gemnasium/infused/compass_point.svg?style=flat)](https://gemnasium.com/infused/compass_point)
|
5
4
|
[![Total Downloads](https://img.shields.io/gem/dt/compass_point.svg)](https://rubygems.org/gems/compass_point/)
|
5
|
+
[![License](https://img.shields.io/github/license/infused/compass_point.svg)](https://github.com/infused/compass_point)
|
6
6
|
|
7
7
|
A Ruby library for working with compass points.
|
8
8
|
|
@@ -16,7 +16,7 @@ A Ruby library for working with compass points.
|
|
16
16
|
|
17
17
|
Compass Point is tested to work with the following versions of ruby:
|
18
18
|
|
19
|
-
* MRI Ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x
|
19
|
+
* MRI Ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x
|
20
20
|
* JRuby 1.7.x
|
21
21
|
|
22
22
|
## Installation
|
@@ -36,6 +36,12 @@ return the corresponding azimuth in degrees from 0 to 360:
|
|
36
36
|
CompassPoint.azimuth('Northeast by east') #=> 56.25
|
37
37
|
CompassPoint.azimuth('N 20° W') #=> 340
|
38
38
|
|
39
|
+
Use `back_azimuth` to find the opposite azimuth:
|
40
|
+
|
41
|
+
CompassPoint.azimuth('N') #=> 180.0
|
42
|
+
CompassPoint.azimuth('S') #=> 0.0
|
43
|
+
CompassPoint.azimuth('swbs') #=> 33.75
|
44
|
+
|
39
45
|
You can also get the minimum and maximum azimuths for any
|
40
46
|
abbreviation with `min`, `max` and `min_max`:
|
41
47
|
|
@@ -63,7 +69,7 @@ example:
|
|
63
69
|
|
64
70
|
## License
|
65
71
|
|
66
|
-
Copyright (c) 2015-
|
72
|
+
Copyright (c) 2015-2019 Keith Morrison <<keithm@infused.org>>
|
67
73
|
|
68
74
|
Permission is hereby granted, free of charge, to any person
|
69
75
|
obtaining a copy of this software and associated documentation
|
data/lib/compass_point.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class CompassPoint
|
2
|
-
VERSION = '1.2.
|
2
|
+
VERSION = '1.2.1'.freeze
|
3
3
|
|
4
4
|
POINTS = {
|
5
5
|
n: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
|
@@ -60,6 +60,13 @@ class CompassPoint
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def back_azimuth(s)
|
64
|
+
azm = azimuth(s)
|
65
|
+
return if azm.nil?
|
66
|
+
|
67
|
+
azm > 180 ? azm - 180 : azm + 180
|
68
|
+
end
|
69
|
+
|
63
70
|
def min(s)
|
64
71
|
point = find_point(normalize_input(s))
|
65
72
|
point && point[:min]
|
data/spec/compass_point_spec.rb
CHANGED
@@ -17,6 +17,22 @@ describe CompassPoint do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
describe '.back_azimuth' do
|
21
|
+
it 'returns opposite of azimuth' do
|
22
|
+
expect(CompassPoint.back_azimuth('N')).to eq 180.0
|
23
|
+
expect(CompassPoint.back_azimuth(:nw)).to eq 135.0
|
24
|
+
expect(CompassPoint.back_azimuth('sbw')).to eq 11.25
|
25
|
+
expect(CompassPoint.back_azimuth('X')).to be_nil
|
26
|
+
expect(CompassPoint.back_azimuth('Northeast by east')).to eq 236.25
|
27
|
+
expect(CompassPoint.back_azimuth('N 27° E')).to eq 207
|
28
|
+
expect(CompassPoint.back_azimuth('S 77° E')).to eq 283
|
29
|
+
expect(CompassPoint.back_azimuth('S 2° E')).to eq 358
|
30
|
+
expect(CompassPoint.back_azimuth('N 77° W')).to eq 103
|
31
|
+
expect(CompassPoint.back_azimuth('N 20 W')).to eq 160
|
32
|
+
expect(CompassPoint.back_azimuth('S 30° W')).to eq 30
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
20
36
|
describe '.min' do
|
21
37
|
it 'returns min point in degrees' do
|
22
38
|
expect(CompassPoint.min('N')).to eq 354.38
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compass_point
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby library for working with compass points
|
14
14
|
email: keithm@infused.org
|
@@ -48,8 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 1.3.0
|
50
50
|
requirements: []
|
51
|
-
|
52
|
-
rubygems_version: 2.7.3
|
51
|
+
rubygems_version: 3.0.3
|
53
52
|
signing_key:
|
54
53
|
specification_version: 4
|
55
54
|
summary: A Ruby library for working with compass points
|