compass_point 1.2.1 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29afdaca55d9941d699c163cac5545b2adb7151c20bf17ca7fa0716ba5d274eb
4
- data.tar.gz: c7bf9b39285b1202642fec3fe215c5b604d83da9df58a11e6483a8326021c927
3
+ metadata.gz: fbb3e7bab2d5ddc4cc246aeea5c02714a16713feb1646c86ec89a4015ecd753e
4
+ data.tar.gz: cc30e1b188cfac483650b97556f6baff583de196872f7eda132384e47eae4560
5
5
  SHA512:
6
- metadata.gz: f8d5d5cccb2694d5f4d5d66e8dd1a326d9d942ef3e0c9a941658f14b2a0fefa0495f30fdc411e46c594f4b0155307cf1b8da65e3d2d235c8a3a055169bf55fb2
7
- data.tar.gz: 31488e6a4d21c87a5d0f3cf42a9f4504374e8fc0c3ffdfba1fcdc784eeb279b52babb40323ba7b021bf9b5c74a6eb65aa0a740274e2f35aede8dba210ec0cd05
6
+ metadata.gz: 43c9378298e358659a9874c23b8e341d8edcb319ca69a79d6fd83403cb19fc8a701fecd2b46bd5f1632efd6e99556280106fe05e63c2c9e17e321010f0f9d470
7
+ data.tar.gz: 99f9b3b30d78b3f0d0564b329e8ae2adcca6da6c6306582b700c370f4cad3c858b1339e98370062d5be6c384f44370ca96b00f93e50746d00387746900a3e30d
data/Gemfile CHANGED
@@ -5,7 +5,8 @@ group :development, :test do
5
5
  gem 'guard'
6
6
  gem 'guard-rspec'
7
7
  gem 'irb'
8
+ gem 'rake'
8
9
  gem 'rspec'
9
- gem 'rubocop-rspec'
10
10
  gem 'rubocop-performance'
11
+ gem 'rubocop-rspec'
11
12
  end
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compass_point (1.2.1)
4
+ compass_point (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
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)
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.9.12)
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
- 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)
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.1)
38
+ notiffany (0.1.3)
38
39
  nenv (~> 0.1)
39
40
  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)
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
- 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)
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.8.0)
59
- rspec-mocks (3.8.0)
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.8.0)
62
- rspec-support (3.8.0)
63
- rubocop (0.71.0)
64
- jaro_winkler (~> 1.5.1)
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.6)
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 (>= 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)
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 (0.20.3)
78
- unicode-display_width (1.6.0)
94
+ thor (1.2.2)
95
+ unicode-display_width (2.4.2)
79
96
 
80
97
  PLATFORMS
81
- ruby
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
- 1.17.2
111
+ 2.4.13
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2019 Keith Morrison <keithm@infused.org>
1
+ Copyright (c) 2015-2023 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
@@ -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](http://img.shields.io/travis/infused/compass_point/master.svg?style=flat)](http://travis-ci.org/infused/compass_point)
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 tested to work with the following versions of ruby:
17
+ Compass Point is compatible 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, 2.6.x
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-2019 Keith Morrison <<keithm@infused.org>>
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(--color)
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(-fl)
10
+ t.rspec_opts = %w[-fl]
11
11
  end
12
12
 
13
- task :default => :spec
13
+ task default: :spec
14
14
 
15
- desc "Open an irb session preloaded with this library"
15
+ desc 'Open an irb session preloaded with this library'
16
16
  task :console do
17
- sh "irb -rubygems -I lib -r compass_point.rb"
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 = '1.2.1'.freeze
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: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
6
- nbe: {min: 5.63, mid: 11.25, max: 16.87, name: 'North by east'},
7
- nne: {min: 16.88, mid: 22.5, max: 28.12, name: 'North-northeast'},
8
- nebn: {min: 28.13, mid: 33.75, max: 39.37, name: 'Northeast by north'},
9
- ne: {min: 39.38, mid: 45.0, max: 50.62, name: 'Northeast'},
10
- nebe: {min: 50.63, mid: 56.25, max: 61.87, name: 'Northeast by east'},
11
- ene: {min: 61.88, mid: 67.5, max: 73.12, name: 'East-northeast'},
12
- ebn: {min: 73.13, mid: 78.75, max: 84.37, name: 'East by north'},
13
- e: {min: 84.38, mid: 90.0, max: 95.62, name: 'East'},
14
- ebs: {min: 95.63, mid: 101.25, max: 106.87, name: 'East by south'},
15
- ese: {min: 106.88, mid: 112.5, max: 118.12, name: 'East-southeast'},
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: {min: 129.38, mid: 135.0, max: 140.62, name: 'Southeast'},
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: {min: 151.88, mid: 157.5, max: 163.12, name: 'South-southeast'},
20
- sbe: {min: 163.13, mid: 168.75, max: 174.37, name: 'South by east'},
21
- s: {min: 174.38, mid: 180.0, max: 185.62, name: 'South'},
22
- sbw: {min: 185.63, mid: 191.25, max: 196.87, name: 'South by west'},
23
- ssw: {min: 196.88, mid: 202.5, max: 208.12, name: 'South southwest'},
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: {min: 219.38, mid: 225.0, max: 230.62, name: 'Southwest'},
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: {min: 241.88, mid: 247.5, max: 253.12, name: 'West-southwest'},
28
- wbs: {min: 253.13, mid: 258.75, max: 264.37, name: 'West by south'},
29
- w: {min: 264.38, mid: 270.0, max: 275.62, name: 'West'},
30
- wbn: {min: 275.63, mid: 281.25, max: 286.87, name: 'West by north'},
31
- wnw: {min: 286.88, mid: 292.5, max: 298.12, name: 'West-northwest'},
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: {min: 309.38, mid: 315.0, max: 320.62, name: 'Northwest'},
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: {min: 331.88, mid: 337.50, max: 343.12, name: 'North northwest'},
36
- nbw: {min: 343.13, mid: 348.75, max: 354.37, name: 'North by west'}
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(/(n|s)\s(\d{1,3}).?\s(e|w)/)
45
- base = if match[1] == 'n'
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: 1.2.1
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: 2019-06-07 00:00:00.000000000 Z
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
- post_install_message:
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: 1.9.3
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: 1.3.0
50
+ version: '0'
50
51
  requirements: []
51
- rubygems_version: 3.0.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: []
data/Gemfile.travis DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem 'rspec'
7
- end