compass_point 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +69 -51
- data/LICENSE +1 -1
- data/README.md +4 -5
- data/Rakefile +5 -5
- data/compass_point.gemspec +22 -0
- data/lib/compass_point.rb +49 -43
- metadata +12 -12
- data/Gemfile.travis +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbb3e7bab2d5ddc4cc246aeea5c02714a16713feb1646c86ec89a4015ecd753e
|
4
|
+
data.tar.gz: cc30e1b188cfac483650b97556f6baff583de196872f7eda132384e47eae4560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c9378298e358659a9874c23b8e341d8edcb319ca69a79d6fd83403cb19fc8a701fecd2b46bd5f1632efd6e99556280106fe05e63c2c9e17e321010f0f9d470
|
7
|
+
data.tar.gz: 99f9b3b30d78b3f0d0564b329e8ae2adcca6da6c6306582b700c370f4cad3c858b1339e98370062d5be6c384f44370ca96b00f93e50746d00387746900a3e30d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
compass_point (
|
4
|
+
compass_point (2.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
coderay (1.1.
|
11
|
-
diff-lcs (1.
|
12
|
-
ffi (1.
|
13
|
-
formatador (
|
14
|
-
guard (2.
|
9
|
+
ast (2.4.2)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
ffi (1.15.5)
|
13
|
+
formatador (1.1.0)
|
14
|
+
guard (2.18.0)
|
15
15
|
formatador (>= 0.2.4)
|
16
16
|
listen (>= 2.7, < 4.0)
|
17
17
|
lumberjack (>= 1.0.12, < 2.0)
|
18
18
|
nenv (~> 0.1)
|
19
19
|
notiffany (~> 0.0)
|
20
|
-
pry (>= 0.
|
20
|
+
pry (>= 0.13.0)
|
21
21
|
shellany (~> 0.0)
|
22
22
|
thor (>= 0.18.1)
|
23
23
|
guard-compat (1.2.1)
|
@@ -25,69 +25,87 @@ GEM
|
|
25
25
|
guard (~> 2.1)
|
26
26
|
guard-compat (~> 1.1)
|
27
27
|
rspec (>= 2.99.0, < 4.0)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
io-console (0.6.0)
|
29
|
+
irb (1.6.4)
|
30
|
+
reline (>= 0.3.0)
|
31
|
+
json (2.6.3)
|
32
|
+
listen (3.8.0)
|
33
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
34
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
35
|
+
lumberjack (1.2.8)
|
36
|
+
method_source (1.0.0)
|
36
37
|
nenv (0.3.0)
|
37
|
-
notiffany (0.1.
|
38
|
+
notiffany (0.1.3)
|
38
39
|
nenv (~> 0.1)
|
39
40
|
shellany (~> 0.0)
|
40
|
-
parallel (1.
|
41
|
-
parser (2.
|
42
|
-
ast (~> 2.4.
|
43
|
-
pry (0.
|
44
|
-
coderay (~> 1.1
|
45
|
-
method_source (~>
|
46
|
-
rainbow (3.
|
47
|
-
|
48
|
-
rb-
|
41
|
+
parallel (1.23.0)
|
42
|
+
parser (3.2.2.1)
|
43
|
+
ast (~> 2.4.1)
|
44
|
+
pry (0.14.2)
|
45
|
+
coderay (~> 1.1)
|
46
|
+
method_source (~> 1.0)
|
47
|
+
rainbow (3.1.1)
|
48
|
+
rake (13.0.6)
|
49
|
+
rb-fsevent (0.11.2)
|
50
|
+
rb-inotify (0.10.1)
|
49
51
|
ffi (~> 1.0)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rspec
|
55
|
-
rspec-
|
56
|
-
|
52
|
+
regexp_parser (2.8.0)
|
53
|
+
reline (0.3.3)
|
54
|
+
io-console (~> 0.5)
|
55
|
+
rexml (3.2.5)
|
56
|
+
rspec (3.12.0)
|
57
|
+
rspec-core (~> 3.12.0)
|
58
|
+
rspec-expectations (~> 3.12.0)
|
59
|
+
rspec-mocks (~> 3.12.0)
|
60
|
+
rspec-core (3.12.2)
|
61
|
+
rspec-support (~> 3.12.0)
|
62
|
+
rspec-expectations (3.12.3)
|
57
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
-
rspec-support (~> 3.
|
59
|
-
rspec-mocks (3.
|
64
|
+
rspec-support (~> 3.12.0)
|
65
|
+
rspec-mocks (3.12.5)
|
60
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-support (3.
|
63
|
-
rubocop (
|
64
|
-
|
67
|
+
rspec-support (~> 3.12.0)
|
68
|
+
rspec-support (3.12.0)
|
69
|
+
rubocop (1.51.0)
|
70
|
+
json (~> 2.3)
|
65
71
|
parallel (~> 1.10)
|
66
|
-
parser (>= 2.
|
72
|
+
parser (>= 3.2.0.0)
|
67
73
|
rainbow (>= 2.2.2, < 4.0)
|
74
|
+
regexp_parser (>= 1.8, < 3.0)
|
75
|
+
rexml (>= 3.2.5, < 4.0)
|
76
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
68
77
|
ruby-progressbar (~> 1.7)
|
69
|
-
unicode-display_width (>=
|
70
|
-
rubocop-
|
71
|
-
|
72
|
-
rubocop-
|
73
|
-
rubocop (
|
74
|
-
|
75
|
-
|
78
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
79
|
+
rubocop-ast (1.28.1)
|
80
|
+
parser (>= 3.2.1.0)
|
81
|
+
rubocop-capybara (2.18.0)
|
82
|
+
rubocop (~> 1.41)
|
83
|
+
rubocop-factory_bot (2.23.1)
|
84
|
+
rubocop (~> 1.33)
|
85
|
+
rubocop-performance (1.17.1)
|
86
|
+
rubocop (>= 1.7.0, < 2.0)
|
87
|
+
rubocop-ast (>= 0.4.0)
|
88
|
+
rubocop-rspec (2.22.0)
|
89
|
+
rubocop (~> 1.33)
|
90
|
+
rubocop-capybara (~> 2.17)
|
91
|
+
rubocop-factory_bot (~> 2.22)
|
92
|
+
ruby-progressbar (1.13.0)
|
76
93
|
shellany (0.0.1)
|
77
|
-
thor (
|
78
|
-
unicode-display_width (
|
94
|
+
thor (1.2.2)
|
95
|
+
unicode-display_width (2.4.2)
|
79
96
|
|
80
97
|
PLATFORMS
|
81
|
-
|
98
|
+
arm64-darwin-22
|
82
99
|
|
83
100
|
DEPENDENCIES
|
84
101
|
compass_point!
|
85
102
|
guard
|
86
103
|
guard-rspec
|
87
104
|
irb
|
105
|
+
rake
|
88
106
|
rspec
|
89
107
|
rubocop-performance
|
90
108
|
rubocop-rspec
|
91
109
|
|
92
110
|
BUNDLED WITH
|
93
|
-
|
111
|
+
2.4.13
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
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
|
-
[![Build Status](
|
3
|
+
[![Build Status](https://github.com/infused/compass_point/actions/workflows/build.yml/badge.svg)](https://github.com/infused/compass_point/actions/workflows/build.yml)
|
4
4
|
[![Total Downloads](https://img.shields.io/gem/dt/compass_point.svg)](https://rubygems.org/gems/compass_point/)
|
5
5
|
[![License](https://img.shields.io/github/license/infused/compass_point.svg)](https://github.com/infused/compass_point)
|
6
6
|
|
@@ -14,10 +14,9 @@ A Ruby library for working with compass points.
|
|
14
14
|
|
15
15
|
## Compatibility
|
16
16
|
|
17
|
-
Compass Point is
|
17
|
+
Compass Point is compatible with the following versions of Ruby:
|
18
18
|
|
19
|
-
* MRI Ruby
|
20
|
-
* JRuby 1.7.x
|
19
|
+
* MRI Ruby 3.0.x, 3.1.x, 3.2.x, and 3.3.x
|
21
20
|
|
22
21
|
## Installation
|
23
22
|
|
@@ -69,7 +68,7 @@ example:
|
|
69
68
|
|
70
69
|
## License
|
71
70
|
|
72
|
-
Copyright (c) 2015-
|
71
|
+
Copyright (c) 2015-2023 Keith Morrison <<keithm@infused.org>>
|
73
72
|
|
74
73
|
Permission is hereby granted, free of charge, to any person
|
75
74
|
obtaining a copy of this software and associated documentation
|
data/Rakefile
CHANGED
@@ -3,16 +3,16 @@ Bundler.setup(:default, :development)
|
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
RSpec::Core::RakeTask.new :spec do |t|
|
6
|
-
t.rspec_opts = %w
|
6
|
+
t.rspec_opts = %w[--color]
|
7
7
|
end
|
8
8
|
|
9
9
|
RSpec::Core::RakeTask.new :specdoc do |t|
|
10
|
-
t.rspec_opts = %w
|
10
|
+
t.rspec_opts = %w[-fl]
|
11
11
|
end
|
12
12
|
|
13
|
-
task :
|
13
|
+
task default: :spec
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc 'Open an irb session preloaded with this library'
|
16
16
|
task :console do
|
17
|
-
sh
|
17
|
+
sh 'irb -rubygems -I lib -r compass_point.rb'
|
18
18
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'compass_point'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'compass_point'
|
7
|
+
s.version = CompassPoint::VERSION
|
8
|
+
s.authors = ['Keith Morrison']
|
9
|
+
s.email = 'keithm@infused.org'
|
10
|
+
s.homepage = 'http://github.com/infused/compass_point'
|
11
|
+
s.summary = 'A Ruby library for working with compass points'
|
12
|
+
s.description = 'A Ruby library for working with compass points'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.rdoc_options = ['--charset=UTF-8']
|
16
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
17
|
+
s.files = Dir['[A-Z]*', '{lib,spec}/**/*', 'compass_points.gemspec']
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.required_ruby_version = '>= 3.0.0'
|
21
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
22
|
+
end
|
data/lib/compass_point.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
class CompassPoint
|
2
|
-
VERSION = '
|
2
|
+
VERSION = '2.0.0'.freeze
|
3
|
+
|
4
|
+
COMPASS_BEARING_REGEX = /(n|s)\s(\d{1,3}).?\s(e|w)/.freeze
|
3
5
|
|
4
6
|
POINTS = {
|
5
|
-
n:
|
6
|
-
nbe:
|
7
|
-
nne:
|
8
|
-
nebn: {min: 28.13,
|
9
|
-
ne:
|
10
|
-
nebe: {min: 50.63,
|
11
|
-
ene:
|
12
|
-
ebn:
|
13
|
-
e:
|
14
|
-
ebs:
|
15
|
-
ese:
|
7
|
+
n: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
|
8
|
+
nbe: {min: 5.63, mid: 11.25, max: 16.87, name: 'North by east'},
|
9
|
+
nne: {min: 16.88, mid: 22.5, max: 28.12, name: 'North-northeast'},
|
10
|
+
nebn: {min: 28.13, mid: 33.75, max: 39.37, name: 'Northeast by north'},
|
11
|
+
ne: {min: 39.38, mid: 45.0, max: 50.62, name: 'Northeast'},
|
12
|
+
nebe: {min: 50.63, mid: 56.25, max: 61.87, name: 'Northeast by east'},
|
13
|
+
ene: {min: 61.88, mid: 67.5, max: 73.12, name: 'East-northeast'},
|
14
|
+
ebn: {min: 73.13, mid: 78.75, max: 84.37, name: 'East by north'},
|
15
|
+
e: {min: 84.38, mid: 90.0, max: 95.62, name: 'East'},
|
16
|
+
ebs: {min: 95.63, mid: 101.25, max: 106.87, name: 'East by south'},
|
17
|
+
ese: {min: 106.88, mid: 112.5, max: 118.12, name: 'East-southeast'},
|
16
18
|
sebe: {min: 118.13, mid: 123.75, max: 129.37, name: 'Southeast by east'},
|
17
|
-
se:
|
19
|
+
se: {min: 129.38, mid: 135.0, max: 140.62, name: 'Southeast'},
|
18
20
|
sebs: {min: 140.63, mid: 146.25, max: 151.87, name: 'Southeast by south'},
|
19
|
-
sse:
|
20
|
-
sbe:
|
21
|
-
s:
|
22
|
-
sbw:
|
23
|
-
ssw:
|
21
|
+
sse: {min: 151.88, mid: 157.5, max: 163.12, name: 'South-southeast'},
|
22
|
+
sbe: {min: 163.13, mid: 168.75, max: 174.37, name: 'South by east'},
|
23
|
+
s: {min: 174.38, mid: 180.0, max: 185.62, name: 'South'},
|
24
|
+
sbw: {min: 185.63, mid: 191.25, max: 196.87, name: 'South by west'},
|
25
|
+
ssw: {min: 196.88, mid: 202.5, max: 208.12, name: 'South southwest'},
|
24
26
|
swbs: {min: 208.13, mid: 213.75, max: 219.37, name: 'Southwest by south'},
|
25
|
-
sw:
|
27
|
+
sw: {min: 219.38, mid: 225.0, max: 230.62, name: 'Southwest'},
|
26
28
|
swbw: {min: 230.63, mid: 236.25, max: 241.87, name: 'Southwest by west'},
|
27
|
-
wsw:
|
28
|
-
wbs:
|
29
|
-
w:
|
30
|
-
wbn:
|
31
|
-
wnw:
|
29
|
+
wsw: {min: 241.88, mid: 247.5, max: 253.12, name: 'West-southwest'},
|
30
|
+
wbs: {min: 253.13, mid: 258.75, max: 264.37, name: 'West by south'},
|
31
|
+
w: {min: 264.38, mid: 270.0, max: 275.62, name: 'West'},
|
32
|
+
wbn: {min: 275.63, mid: 281.25, max: 286.87, name: 'West by north'},
|
33
|
+
wnw: {min: 286.88, mid: 292.5, max: 298.12, name: 'West-northwest'},
|
32
34
|
nwbw: {min: 298.13, mid: 303.75, max: 309.37, name: 'Northwest by west'},
|
33
|
-
nw:
|
35
|
+
nw: {min: 309.38, mid: 315.0, max: 320.62, name: 'Northwest'},
|
34
36
|
nwbn: {min: 320.63, mid: 326.25, max: 331.87, name: 'Northwest by north'},
|
35
|
-
nnw:
|
36
|
-
nbw:
|
37
|
+
nnw: {min: 331.88, mid: 337.50, max: 343.12, name: 'North northwest'},
|
38
|
+
nbw: {min: 343.13, mid: 348.75, max: 354.37, name: 'North by west'}
|
37
39
|
}.freeze
|
38
40
|
|
39
41
|
class << self
|
@@ -41,22 +43,8 @@ class CompassPoint
|
|
41
43
|
input = normalize_input(s)
|
42
44
|
if point = find_point(input)
|
43
45
|
point[:mid]
|
44
|
-
elsif match = input.match(
|
45
|
-
|
46
|
-
match[3] == 'w' ? 360 : 0
|
47
|
-
else
|
48
|
-
180
|
49
|
-
end
|
50
|
-
|
51
|
-
adjust = match[2].to_i
|
52
|
-
|
53
|
-
operation = if (match[1] == 'n' && match[3] == 'w') || (match[1] == 's' && match[3] == 'e')
|
54
|
-
:-
|
55
|
-
else
|
56
|
-
:+
|
57
|
-
end
|
58
|
-
|
59
|
-
base.send(operation, adjust)
|
46
|
+
elsif match = input.match(COMPASS_BEARING_REGEX)
|
47
|
+
azimuth_from_match(match)
|
60
48
|
end
|
61
49
|
end
|
62
50
|
|
@@ -101,6 +89,24 @@ class CompassPoint
|
|
101
89
|
|
102
90
|
private
|
103
91
|
|
92
|
+
def azimuth_from_match(match)
|
93
|
+
base = if match[1] == 'n'
|
94
|
+
match[3] == 'w' ? 360 : 0
|
95
|
+
else
|
96
|
+
180
|
97
|
+
end
|
98
|
+
|
99
|
+
adjust = match[2].to_i
|
100
|
+
|
101
|
+
operation = if (match[1] == 'n' && match[3] == 'w') || (match[1] == 's' && match[3] == 'e')
|
102
|
+
:-
|
103
|
+
else
|
104
|
+
:+
|
105
|
+
end
|
106
|
+
|
107
|
+
base.send(operation, adjust)
|
108
|
+
end
|
109
|
+
|
104
110
|
def generate_compass_quadrant_bearing(b)
|
105
111
|
s = []
|
106
112
|
s << north_or_south(b)
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-18 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
|
@@ -20,19 +20,20 @@ extra_rdoc_files:
|
|
20
20
|
files:
|
21
21
|
- Gemfile
|
22
22
|
- Gemfile.lock
|
23
|
-
- Gemfile.travis
|
24
23
|
- Guardfile
|
25
24
|
- LICENSE
|
26
25
|
- README.md
|
27
26
|
- Rakefile
|
27
|
+
- compass_point.gemspec
|
28
28
|
- lib/compass_point.rb
|
29
29
|
- spec/compass_point_spec.rb
|
30
30
|
- spec/spec_helper.rb
|
31
31
|
homepage: http://github.com/infused/compass_point
|
32
32
|
licenses:
|
33
33
|
- MIT
|
34
|
-
metadata:
|
35
|
-
|
34
|
+
metadata:
|
35
|
+
rubygems_mfa_required: 'true'
|
36
|
+
post_install_message:
|
36
37
|
rdoc_options:
|
37
38
|
- "--charset=UTF-8"
|
38
39
|
require_paths:
|
@@ -41,16 +42,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
42
|
requirements:
|
42
43
|
- - ">="
|
43
44
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
45
|
+
version: 3.0.0
|
45
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
+
version: '0'
|
50
51
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
52
|
-
signing_key:
|
52
|
+
rubygems_version: 3.4.13
|
53
|
+
signing_key:
|
53
54
|
specification_version: 4
|
54
55
|
summary: A Ruby library for working with compass points
|
55
|
-
test_files:
|
56
|
-
- spec/compass_point_spec.rb
|
56
|
+
test_files: []
|