compass_point 1.2.1 → 2.0.1
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 +4 -4
- data/LICENSE +1 -1
- data/README.md +4 -5
- data/lib/compass_point.rb +49 -43
- metadata +11 -16
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -93
- data/Gemfile.travis +0 -7
- data/Guardfile +0 -52
- data/Rakefile +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b99e6078b6e214a2020224b1420066e768a682e57b51d9ef069c82ec65a3b4e
|
4
|
+
data.tar.gz: f1f6db879f7ec39b11a10e52a912b49772ebc8223206643cc36f9638cc79494e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5db222ac44ce803126e681b326da623baf170ced90d019f561ba89ee218c04e5732c38806aa31c44b1c17e6b8ae560d9d8485dde75a7408561cd7d75bee8b3
|
7
|
+
data.tar.gz: 2e4c15921705aad607528930b87726ba180aa49f28b05bd2d68daa3e1bde908dfe04b252e705871067fbd44738e6d34ce0a2c50c04973949f5e1afdc8bfaa123
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Compass Point
|
2
2
|
[](https://rubygems.org/gems/compass_point)
|
3
|
-
[](https://github.com/infused/compass_point/actions/workflows/build.yml)
|
4
4
|
[](https://rubygems.org/gems/compass_point/)
|
5
5
|
[](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/lib/compass_point.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
class CompassPoint
|
2
|
-
VERSION = '
|
2
|
+
VERSION = '2.0.1'.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.1
|
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-30 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
|
@@ -18,21 +18,17 @@ extra_rdoc_files:
|
|
18
18
|
- README.md
|
19
19
|
- LICENSE
|
20
20
|
files:
|
21
|
-
- Gemfile
|
22
|
-
- Gemfile.lock
|
23
|
-
- Gemfile.travis
|
24
|
-
- Guardfile
|
25
21
|
- LICENSE
|
26
22
|
- README.md
|
27
|
-
- Rakefile
|
28
23
|
- lib/compass_point.rb
|
29
24
|
- spec/compass_point_spec.rb
|
30
25
|
- spec/spec_helper.rb
|
31
26
|
homepage: http://github.com/infused/compass_point
|
32
27
|
licenses:
|
33
28
|
- MIT
|
34
|
-
metadata:
|
35
|
-
|
29
|
+
metadata:
|
30
|
+
rubygems_mfa_required: 'true'
|
31
|
+
post_install_message:
|
36
32
|
rdoc_options:
|
37
33
|
- "--charset=UTF-8"
|
38
34
|
require_paths:
|
@@ -41,16 +37,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
37
|
requirements:
|
42
38
|
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
40
|
+
version: 3.0.0
|
45
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
42
|
requirements:
|
47
43
|
- - ">="
|
48
44
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
45
|
+
version: '0'
|
50
46
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
52
|
-
signing_key:
|
47
|
+
rubygems_version: 3.4.13
|
48
|
+
signing_key:
|
53
49
|
specification_version: 4
|
54
50
|
summary: A Ruby library for working with compass points
|
55
|
-
test_files:
|
56
|
-
- spec/compass_point_spec.rb
|
51
|
+
test_files: []
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
compass_point (1.2.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.0)
|
10
|
-
coderay (1.1.2)
|
11
|
-
diff-lcs (1.3)
|
12
|
-
ffi (1.11.1)
|
13
|
-
formatador (0.2.5)
|
14
|
-
guard (2.15.0)
|
15
|
-
formatador (>= 0.2.4)
|
16
|
-
listen (>= 2.7, < 4.0)
|
17
|
-
lumberjack (>= 1.0.12, < 2.0)
|
18
|
-
nenv (~> 0.1)
|
19
|
-
notiffany (~> 0.0)
|
20
|
-
pry (>= 0.9.12)
|
21
|
-
shellany (~> 0.0)
|
22
|
-
thor (>= 0.18.1)
|
23
|
-
guard-compat (1.2.1)
|
24
|
-
guard-rspec (4.7.3)
|
25
|
-
guard (~> 2.1)
|
26
|
-
guard-compat (~> 1.1)
|
27
|
-
rspec (>= 2.99.0, < 4.0)
|
28
|
-
irb (1.0.0)
|
29
|
-
jaro_winkler (1.5.2)
|
30
|
-
listen (3.1.5)
|
31
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
32
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
33
|
-
ruby_dep (~> 1.2)
|
34
|
-
lumberjack (1.0.13)
|
35
|
-
method_source (0.9.2)
|
36
|
-
nenv (0.3.0)
|
37
|
-
notiffany (0.1.1)
|
38
|
-
nenv (~> 0.1)
|
39
|
-
shellany (~> 0.0)
|
40
|
-
parallel (1.17.0)
|
41
|
-
parser (2.6.3.0)
|
42
|
-
ast (~> 2.4.0)
|
43
|
-
pry (0.12.2)
|
44
|
-
coderay (~> 1.1.0)
|
45
|
-
method_source (~> 0.9.0)
|
46
|
-
rainbow (3.0.0)
|
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)
|
57
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
-
rspec-support (~> 3.8.0)
|
59
|
-
rspec-mocks (3.8.0)
|
60
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
-
rspec-support (~> 3.8.0)
|
62
|
-
rspec-support (3.8.0)
|
63
|
-
rubocop (0.71.0)
|
64
|
-
jaro_winkler (~> 1.5.1)
|
65
|
-
parallel (~> 1.10)
|
66
|
-
parser (>= 2.6)
|
67
|
-
rainbow (>= 2.2.2, < 4.0)
|
68
|
-
ruby-progressbar (~> 1.7)
|
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)
|
75
|
-
ruby_dep (1.5.0)
|
76
|
-
shellany (0.0.1)
|
77
|
-
thor (0.20.3)
|
78
|
-
unicode-display_width (1.6.0)
|
79
|
-
|
80
|
-
PLATFORMS
|
81
|
-
ruby
|
82
|
-
|
83
|
-
DEPENDENCIES
|
84
|
-
compass_point!
|
85
|
-
guard
|
86
|
-
guard-rspec
|
87
|
-
irb
|
88
|
-
rspec
|
89
|
-
rubocop-performance
|
90
|
-
rubocop-rspec
|
91
|
-
|
92
|
-
BUNDLED WITH
|
93
|
-
1.17.2
|
data/Gemfile.travis
DELETED
data/Guardfile
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
## Uncomment and set this to only include directories you want to watch
|
5
|
-
# directories %w(app lib config test spec features)
|
6
|
-
|
7
|
-
## Uncomment to clear the screen before every task
|
8
|
-
# clearing :on
|
9
|
-
|
10
|
-
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
-
## If you want Guard to automatically start up again, run guard in a
|
12
|
-
## shell loop, e.g.:
|
13
|
-
##
|
14
|
-
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
-
##
|
16
|
-
## Note: if you are using the `directories` clause above and you are not
|
17
|
-
## watching the project directory ('.'), then you will want to move
|
18
|
-
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
-
#
|
20
|
-
# $ mkdir config
|
21
|
-
# $ mv Guardfile config/
|
22
|
-
# $ ln -s config/Guardfile .
|
23
|
-
#
|
24
|
-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
-
|
26
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
-
# rspec may be run, below are examples of the most common uses.
|
28
|
-
# * bundler: 'bundle exec rspec'
|
29
|
-
# * bundler binstubs: 'bin/rspec'
|
30
|
-
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
-
# installed the spring binstubs per the docs)
|
32
|
-
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
-
# * 'just' rspec: 'rspec'
|
34
|
-
|
35
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
36
|
-
require 'guard/rspec/dsl'
|
37
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
38
|
-
|
39
|
-
# RSpec files
|
40
|
-
rspec = dsl.rspec
|
41
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
42
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
43
|
-
watch(rspec.spec_files)
|
44
|
-
|
45
|
-
# Ruby files
|
46
|
-
ruby = dsl.ruby
|
47
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
48
|
-
|
49
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
50
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
51
|
-
watch('Guardfile') { 'spec' }
|
52
|
-
end
|
data/Rakefile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
Bundler.setup(:default, :development)
|
3
|
-
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new :spec do |t|
|
6
|
-
t.rspec_opts = %w(--color)
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new :specdoc do |t|
|
10
|
-
t.rspec_opts = %w(-fl)
|
11
|
-
end
|
12
|
-
|
13
|
-
task :default => :spec
|
14
|
-
|
15
|
-
desc "Open an irb session preloaded with this library"
|
16
|
-
task :console do
|
17
|
-
sh "irb -rubygems -I lib -r compass_point.rb"
|
18
|
-
end
|