compass_point 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbb3e7bab2d5ddc4cc246aeea5c02714a16713feb1646c86ec89a4015ecd753e
4
- data.tar.gz: cc30e1b188cfac483650b97556f6baff583de196872f7eda132384e47eae4560
3
+ metadata.gz: 58dc6a0e428a79c4f324f8203b4bd263b79e83a2bc27ed2b9275d737579f5b49
4
+ data.tar.gz: 6f7747c5f2298d8801a6f4c28636237c5ced151c5439826ec6db0aaa92cd5e14
5
5
  SHA512:
6
- metadata.gz: 43c9378298e358659a9874c23b8e341d8edcb319ca69a79d6fd83403cb19fc8a701fecd2b46bd5f1632efd6e99556280106fe05e63c2c9e17e321010f0f9d470
7
- data.tar.gz: 99f9b3b30d78b3f0d0564b329e8ae2adcca6da6c6306582b700c370f4cad3c858b1339e98370062d5be6c384f44370ca96b00f93e50746d00387746900a3e30d
6
+ metadata.gz: 1afe4228022af269623dcdf5d0918ae87bd805773d6b08f1bc043197cc6d8b45c4bb7e569f56717b2ae3c42dcd861f7113c8d46d7bac1546155e10e0bc0a72b4
7
+ data.tar.gz: 6222b9724ca875db38cd2cf2213e53233463ce9e02cef98ee5664211bbc3212769bd4e25c524b0485380b798999a7b6c7563948508fa077ce5b71fa2a6c547ed
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023 Keith Morrison <keithm@infused.org>
1
+ Copyright (c) 2015-2024 Keith Morrison <keithm@infused.org>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -16,7 +16,7 @@ A Ruby library for working with compass points.
16
16
 
17
17
  Compass Point is compatible with the following versions of Ruby:
18
18
 
19
- * MRI Ruby 3.0.x, 3.1.x, 3.2.x, and 3.3.x
19
+ * MRI Ruby 3.1.x, 3.2.x, and 3.3.x
20
20
 
21
21
  ## Installation
22
22
 
@@ -68,7 +68,7 @@ example:
68
68
 
69
69
  ## License
70
70
 
71
- Copyright (c) 2015-2023 Keith Morrison <<keithm@infused.org>>
71
+ Copyright (c) 2015-2024 Keith Morrison <<keithm@infused.org>>
72
72
 
73
73
  Permission is hereby granted, free of charge, to any person
74
74
  obtaining a copy of this software and associated documentation
data/lib/compass_point.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class CompassPoint
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
 
4
- COMPASS_BEARING_REGEX = /(n|s)\s(\d{1,3}).?\s(e|w)/.freeze
4
+ COMPASS_BEARING_REGEX = /(n|s)\s(\d{1,3}).?\s(e|w)/
5
5
 
6
6
  POINTS = {
7
7
  n: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
@@ -41,9 +41,9 @@ class CompassPoint
41
41
  class << self
42
42
  def azimuth(s)
43
43
  input = normalize_input(s)
44
- if point = find_point(input)
44
+ if (point = find_point(input))
45
45
  point[:mid]
46
- elsif match = input.match(COMPASS_BEARING_REGEX)
46
+ elsif (match = input.match(COMPASS_BEARING_REGEX))
47
47
  azimuth_from_match(match)
48
48
  end
49
49
  end
@@ -96,15 +96,13 @@ class CompassPoint
96
96
  180
97
97
  end
98
98
 
99
- adjust = match[2].to_i
100
-
101
99
  operation = if (match[1] == 'n' && match[3] == 'w') || (match[1] == 's' && match[3] == 'e')
102
100
  :-
103
101
  else
104
102
  :+
105
103
  end
106
104
 
107
- base.send(operation, adjust)
105
+ base.send(operation, match[2].to_i)
108
106
  end
109
107
 
110
108
  def generate_compass_quadrant_bearing(b)
@@ -3,88 +3,87 @@ require 'spec_helper'
3
3
  describe CompassPoint do
4
4
  describe '.azimuth' do
5
5
  it 'returns mid point in degrees' do
6
- expect(CompassPoint.azimuth('N')).to eq 0.0
7
- expect(CompassPoint.azimuth(:nw)).to eq 315.0
8
- expect(CompassPoint.azimuth('sbw')).to eq 191.25
9
- expect(CompassPoint.azimuth('X')).to be_nil
10
- expect(CompassPoint.azimuth('Northeast by east')).to eq 56.25
11
- expect(CompassPoint.azimuth('N 27° E')).to eq 27
12
- expect(CompassPoint.azimuth('S 77° E')).to eq 103
13
- expect(CompassPoint.azimuth('S 2° E')).to eq 178
14
- expect(CompassPoint.azimuth('N 77° W')).to eq 283
15
- expect(CompassPoint.azimuth('N 20 W')).to eq 340
16
- expect(CompassPoint.azimuth('S 30° W')).to eq 210
6
+ expect(described_class.azimuth('N')).to eq 0.0
7
+ expect(described_class.azimuth(:nw)).to eq 315.0
8
+ expect(described_class.azimuth('sbw')).to eq 191.25
9
+ expect(described_class.azimuth('X')).to be_nil
10
+ expect(described_class.azimuth('Northeast by east')).to eq 56.25
11
+ expect(described_class.azimuth('N 27° E')).to eq 27
12
+ expect(described_class.azimuth('S 77° E')).to eq 103
13
+ expect(described_class.azimuth('S 2° E')).to eq 178
14
+ expect(described_class.azimuth('N 77° W')).to eq 283
15
+ expect(described_class.azimuth('N 20 W')).to eq 340
16
+ expect(described_class.azimuth('S 30° W')).to eq 210
17
17
  end
18
18
  end
19
19
 
20
20
  describe '.back_azimuth' do
21
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
22
+ expect(described_class.back_azimuth('N')).to eq 180.0
23
+ expect(described_class.back_azimuth(:nw)).to eq 135.0
24
+ expect(described_class.back_azimuth('sbw')).to eq 11.25
25
+ expect(described_class.back_azimuth('X')).to be_nil
26
+ expect(described_class.back_azimuth('Northeast by east')).to eq 236.25
27
+ expect(described_class.back_azimuth('N 27° E')).to eq 207
28
+ expect(described_class.back_azimuth('S 77° E')).to eq 283
29
+ expect(described_class.back_azimuth('S 2° E')).to eq 358
30
+ expect(described_class.back_azimuth('N 77° W')).to eq 103
31
+ expect(described_class.back_azimuth('N 20 W')).to eq 160
32
+ expect(described_class.back_azimuth('S 30° W')).to eq 30
33
33
  end
34
34
  end
35
35
 
36
36
  describe '.min' do
37
37
  it 'returns min point in degrees' do
38
- expect(CompassPoint.min('N')).to eq 354.38
39
- expect(CompassPoint.min(:nw)).to eq 309.38
40
- expect(CompassPoint.min('sbw')).to eq 185.63
41
- expect(CompassPoint.min('X')).to be_nil
42
- expect(CompassPoint.min('Northeast by east')).to eq 50.63
38
+ expect(described_class.min('N')).to eq 354.38
39
+ expect(described_class.min(:nw)).to eq 309.38
40
+ expect(described_class.min('sbw')).to eq 185.63
41
+ expect(described_class.min('X')).to be_nil
42
+ expect(described_class.min('Northeast by east')).to eq 50.63
43
43
  end
44
44
  end
45
45
 
46
46
  describe '.max' do
47
47
  it 'returns max point in degrees' do
48
- expect(CompassPoint.max('N')).to eq 5.62
49
- expect(CompassPoint.max(:nw)).to eq 320.62
50
- expect(CompassPoint.max('sbw')).to eq 196.87
51
- expect(CompassPoint.max('X')).to be_nil
52
- expect(CompassPoint.max('Northeast by east')).to eq 61.87
48
+ expect(described_class.max('N')).to eq 5.62
49
+ expect(described_class.max(:nw)).to eq 320.62
50
+ expect(described_class.max('sbw')).to eq 196.87
51
+ expect(described_class.max('X')).to be_nil
52
+ expect(described_class.max('Northeast by east')).to eq 61.87
53
53
  end
54
54
  end
55
55
 
56
56
  describe '.min_max' do
57
57
  it 'returns [min, max]' do
58
- expect(CompassPoint.min_max('N')).to eq [354.38, 5.62]
59
- expect(CompassPoint.min_max(:nw)).to eq [309.38, 320.62]
60
- expect(CompassPoint.min_max('sbw')).to eq [185.63, 196.87]
61
- expect(CompassPoint.min_max('X')).to be_nil
62
- expect(CompassPoint.min_max('Northeast by east')).to eq [50.63, 61.87]
58
+ expect(described_class.min_max('N')).to eq [354.38, 5.62]
59
+ expect(described_class.min_max(:nw)).to eq [309.38, 320.62]
60
+ expect(described_class.min_max('sbw')).to eq [185.63, 196.87]
61
+ expect(described_class.min_max('X')).to be_nil
62
+ expect(described_class.min_max('Northeast by east')).to eq [50.63, 61.87]
63
63
  end
64
64
  end
65
65
 
66
66
  describe '.name' do
67
67
  it 'returns the points full name' do
68
- expect(CompassPoint.name('nnw')).to eq 'North northwest'
68
+ expect(described_class.name('nnw')).to eq 'North northwest'
69
69
  end
70
70
  end
71
71
 
72
72
  describe '.compass_quadrant_bearing' do
73
73
  it 'is' do
74
- expect(CompassPoint.compass_quadrant_bearing(0)).to eq 'N'
75
- expect(CompassPoint.compass_quadrant_bearing(27)).to eq 'N 27° E'
76
- expect(CompassPoint.compass_quadrant_bearing(27.4)).to eq 'N 27° E'
77
- expect(CompassPoint.compass_quadrant_bearing(27.7)).to eq 'N 28° E'
78
- expect(CompassPoint.compass_quadrant_bearing(90)).to eq 'E'
79
- expect(CompassPoint.compass_quadrant_bearing(103)).to eq 'S 77° E'
80
- expect(CompassPoint.compass_quadrant_bearing(178)).to eq 'S 2° E'
81
- expect(CompassPoint.compass_quadrant_bearing(180)).to eq 'S'
82
- expect(CompassPoint.compass_quadrant_bearing(210)).to eq 'S 30° W'
83
- expect(CompassPoint.compass_quadrant_bearing(270)).to eq 'W'
84
- expect(CompassPoint.compass_quadrant_bearing(283)).to eq 'N 77° W'
85
- expect(CompassPoint.compass_quadrant_bearing(340)).to eq 'N 20° W'
86
- expect(CompassPoint.compass_quadrant_bearing(360)).to eq 'N'
74
+ expect(described_class.compass_quadrant_bearing(0)).to eq 'N'
75
+ expect(described_class.compass_quadrant_bearing(27)).to eq 'N 27° E'
76
+ expect(described_class.compass_quadrant_bearing(27.4)).to eq 'N 27° E'
77
+ expect(described_class.compass_quadrant_bearing(27.7)).to eq 'N 28° E'
78
+ expect(described_class.compass_quadrant_bearing(90)).to eq 'E'
79
+ expect(described_class.compass_quadrant_bearing(103)).to eq 'S 77° E'
80
+ expect(described_class.compass_quadrant_bearing(178)).to eq 'S 2° E'
81
+ expect(described_class.compass_quadrant_bearing(180)).to eq 'S'
82
+ expect(described_class.compass_quadrant_bearing(210)).to eq 'S 30° W'
83
+ expect(described_class.compass_quadrant_bearing(270)).to eq 'W'
84
+ expect(described_class.compass_quadrant_bearing(283)).to eq 'N 77° W'
85
+ expect(described_class.compass_quadrant_bearing(340)).to eq 'N 20° W'
86
+ expect(described_class.compass_quadrant_bearing(360)).to eq 'N'
87
87
  end
88
88
  end
89
-
90
89
  end
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: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-12-28 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,13 +18,8 @@ extra_rdoc_files:
18
18
  - README.md
19
19
  - LICENSE
20
20
  files:
21
- - Gemfile
22
- - Gemfile.lock
23
- - Guardfile
24
21
  - LICENSE
25
22
  - README.md
26
- - Rakefile
27
- - compass_point.gemspec
28
23
  - lib/compass_point.rb
29
24
  - spec/compass_point_spec.rb
30
25
  - spec/spec_helper.rb
@@ -42,14 +37,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
37
  requirements:
43
38
  - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: 3.0.0
40
+ version: 3.1.0
46
41
  required_rubygems_version: !ruby/object:Gem::Requirement
47
42
  requirements:
48
43
  - - ">="
49
44
  - !ruby/object:Gem::Version
50
45
  version: '0'
51
46
  requirements: []
52
- rubygems_version: 3.4.13
47
+ rubygems_version: 3.5.3
53
48
  signing_key:
54
49
  specification_version: 4
55
50
  summary: A Ruby library for working with compass points
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- gemspec
2
- source 'https://rubygems.org'
3
-
4
- group :development, :test do
5
- gem 'guard'
6
- gem 'guard-rspec'
7
- gem 'irb'
8
- gem 'rake'
9
- gem 'rspec'
10
- gem 'rubocop-performance'
11
- gem 'rubocop-rspec'
12
- end
data/Gemfile.lock DELETED
@@ -1,111 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- compass_point (2.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
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
- 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.13.0)
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
- 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)
37
- nenv (0.3.0)
38
- notiffany (0.1.3)
39
- nenv (~> 0.1)
40
- shellany (~> 0.0)
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)
51
- ffi (~> 1.0)
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)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.12.0)
65
- rspec-mocks (3.12.5)
66
- diff-lcs (>= 1.2.0, < 2.0)
67
- rspec-support (~> 3.12.0)
68
- rspec-support (3.12.0)
69
- rubocop (1.51.0)
70
- json (~> 2.3)
71
- parallel (~> 1.10)
72
- parser (>= 3.2.0.0)
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)
77
- ruby-progressbar (~> 1.7)
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)
93
- shellany (0.0.1)
94
- thor (1.2.2)
95
- unicode-display_width (2.4.2)
96
-
97
- PLATFORMS
98
- arm64-darwin-22
99
-
100
- DEPENDENCIES
101
- compass_point!
102
- guard
103
- guard-rspec
104
- irb
105
- rake
106
- rspec
107
- rubocop-performance
108
- rubocop-rspec
109
-
110
- BUNDLED WITH
111
- 2.4.13
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
@@ -1,22 +0,0 @@
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