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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29afdaca55d9941d699c163cac5545b2adb7151c20bf17ca7fa0716ba5d274eb
4
- data.tar.gz: c7bf9b39285b1202642fec3fe215c5b604d83da9df58a11e6483a8326021c927
3
+ metadata.gz: 7b99e6078b6e214a2020224b1420066e768a682e57b51d9ef069c82ec65a3b4e
4
+ data.tar.gz: f1f6db879f7ec39b11a10e52a912b49772ebc8223206643cc36f9638cc79494e
5
5
  SHA512:
6
- metadata.gz: f8d5d5cccb2694d5f4d5d66e8dd1a326d9d942ef3e0c9a941658f14b2a0fefa0495f30fdc411e46c594f4b0155307cf1b8da65e3d2d235c8a3a055169bf55fb2
7
- data.tar.gz: 31488e6a4d21c87a5d0f3cf42a9f4504374e8fc0c3ffdfba1fcdc784eeb279b52babb40323ba7b021bf9b5c74a6eb65aa0a740274e2f35aede8dba210ec0cd05
6
+ metadata.gz: 2d5db222ac44ce803126e681b326da623baf170ced90d019f561ba89ee218c04e5732c38806aa31c44b1c17e6b8ae560d9d8485dde75a7408561cd7d75bee8b3
7
+ data.tar.gz: 2e4c15921705aad607528930b87726ba180aa49f28b05bd2d68daa3e1bde908dfe04b252e705871067fbd44738e6d34ce0a2c50c04973949f5e1afdc8bfaa123
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/lib/compass_point.rb CHANGED
@@ -1,39 +1,41 @@
1
1
  class CompassPoint
2
- VERSION = '1.2.1'.freeze
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: {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.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: 2019-06-07 00:00:00.000000000 Z
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
- post_install_message:
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: 1.9.3
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: 1.3.0
45
+ version: '0'
50
46
  requirements: []
51
- rubygems_version: 3.0.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
@@ -1,11 +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 'rspec'
9
- gem 'rubocop-rspec'
10
- gem 'rubocop-performance'
11
- end
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
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem 'rspec'
7
- end
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