compass_point 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +73 -0
- data/Guardfile +52 -0
- data/LICENSE +20 -0
- data/README.md +60 -0
- data/compass_point.gemspec +22 -0
- data/lib/compass_point.rb +55 -0
- data/spec/compass_point_spec.rb +14 -0
- data/spec/spec_helper.rb +6 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 572d6a5c62a94371ac1cfc51a9159a6210a4a7c6
|
4
|
+
data.tar.gz: 662e06d62053664bdce6e7077dd705677a8a22bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d513cf9a90db8df32d9610fd57c44f2fd3f32d54ca2f98799cf144ca35511a4962fe6f8fb8c5d756bb2641c13efd5292544392d5646cccdad9de70da4d4a6462
|
7
|
+
data.tar.gz: be80b30a04996483a29afc9cb55678f215ac2522f6c49804a43afc3147131e73f215f60342b9cdc34a1c4728649bbd93d0697d7c151deb6f4b9a5ac70c31cba3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
compass_point (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
celluloid (0.16.0)
|
10
|
+
timers (~> 4.0.0)
|
11
|
+
coderay (1.1.0)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
ffi (1.9.8)
|
14
|
+
formatador (0.2.5)
|
15
|
+
guard (2.12.5)
|
16
|
+
formatador (>= 0.2.4)
|
17
|
+
listen (~> 2.7)
|
18
|
+
lumberjack (~> 1.0)
|
19
|
+
nenv (~> 0.1)
|
20
|
+
notiffany (~> 0.0)
|
21
|
+
pry (>= 0.9.12)
|
22
|
+
shellany (~> 0.0)
|
23
|
+
thor (>= 0.18.1)
|
24
|
+
guard-compat (1.2.1)
|
25
|
+
guard-rspec (4.5.0)
|
26
|
+
guard (~> 2.1)
|
27
|
+
guard-compat (~> 1.1)
|
28
|
+
rspec (>= 2.99.0, < 4.0)
|
29
|
+
hitimes (1.2.2)
|
30
|
+
listen (2.10.0)
|
31
|
+
celluloid (~> 0.16.0)
|
32
|
+
rb-fsevent (>= 0.9.3)
|
33
|
+
rb-inotify (>= 0.9)
|
34
|
+
lumberjack (1.0.9)
|
35
|
+
method_source (0.8.2)
|
36
|
+
nenv (0.2.0)
|
37
|
+
notiffany (0.0.6)
|
38
|
+
nenv (~> 0.1)
|
39
|
+
shellany (~> 0.0)
|
40
|
+
pry (0.10.1)
|
41
|
+
coderay (~> 1.1.0)
|
42
|
+
method_source (~> 0.8.1)
|
43
|
+
slop (~> 3.4)
|
44
|
+
rb-fsevent (0.9.4)
|
45
|
+
rb-inotify (0.9.5)
|
46
|
+
ffi (>= 0.5.0)
|
47
|
+
rspec (3.2.0)
|
48
|
+
rspec-core (~> 3.2.0)
|
49
|
+
rspec-expectations (~> 3.2.0)
|
50
|
+
rspec-mocks (~> 3.2.0)
|
51
|
+
rspec-core (3.2.3)
|
52
|
+
rspec-support (~> 3.2.0)
|
53
|
+
rspec-expectations (3.2.1)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.2.0)
|
56
|
+
rspec-mocks (3.2.1)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.2.0)
|
59
|
+
rspec-support (3.2.2)
|
60
|
+
shellany (0.0.1)
|
61
|
+
slop (3.6.0)
|
62
|
+
thor (0.19.1)
|
63
|
+
timers (4.0.1)
|
64
|
+
hitimes
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
compass_point!
|
71
|
+
guard
|
72
|
+
guard-rspec
|
73
|
+
rspec
|
data/Guardfile
ADDED
@@ -0,0 +1,52 @@
|
|
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/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2006-2014 Keith Morrison <keithm@infused.org>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Compass Point
|
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)
|
4
|
+
[![Code Quality](http://img.shields.io/codeclimate/github/infused/compass_point.svg?style=flat)](https://codeclimate.com/github/infused/compass_point)
|
5
|
+
[![Test Coverage](http://img.shields.io/codeclimate/coverage/github/infused/compass_point.svg?style=flat)](https://codeclimate.com/github/infused/compass_point)
|
6
|
+
[![Dependency Status](http://img.shields.io/gemnasium/infused/compass_point.svg?style=flat)](https://gemnasium.com/infused/compass_point)
|
7
|
+
|
8
|
+
A Ruby library for working with compass points
|
9
|
+
|
10
|
+
* Project page: <http://github.com/infused/compass_point>
|
11
|
+
* API Documentation: <http://rubydoc.info/github/infused/compass_point/>
|
12
|
+
* Report bugs: <http://github.com/infused/compass_point/issues>
|
13
|
+
|
14
|
+
## Compatibility
|
15
|
+
|
16
|
+
Compass Point is tested to work with the following versions of ruby:
|
17
|
+
|
18
|
+
* MRI Ruby 1.9.3, 2.0.x, 2.1.x, 2.2.x
|
19
|
+
* JRuby 1.7.x
|
20
|
+
* Rubinius 2.1+
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
```
|
25
|
+
gem install compass_point
|
26
|
+
```
|
27
|
+
|
28
|
+
## Basic Usage
|
29
|
+
|
30
|
+
require 'compass_point'
|
31
|
+
|
32
|
+
CompassPoint.azimuth('N') #=> 0.0
|
33
|
+
CompassPoint.azimuth('S') #=> 180.0
|
34
|
+
CompassPoint.azimuth('swbs') #=> 213.75
|
35
|
+
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2015 Keith Morrison <<keithm@infused.org>>
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person
|
42
|
+
obtaining a copy of this software and associated documentation
|
43
|
+
files (the "Software"), to deal in the Software without
|
44
|
+
restriction, including without limitation the rights to use,
|
45
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
46
|
+
copies of the Software, and to permit persons to whom the
|
47
|
+
Software is furnished to do so, subject to the following
|
48
|
+
conditions:
|
49
|
+
|
50
|
+
The above copyright notice and this permission notice shall be
|
51
|
+
included in all copies or substantial portions of the Software.
|
52
|
+
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
54
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
55
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
56
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
57
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
58
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
59
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
60
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.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.test_files = Dir.glob('spec/**/*_spec.rb')
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.required_rubygems_version = '>= 1.3.0'
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class CompassPoint
|
2
|
+
VERSION = '1.0.0'
|
3
|
+
|
4
|
+
POINTS = {
|
5
|
+
n: {min: 354.38, mid: 0.0, max: 5.62},
|
6
|
+
nbe: {min: 5.63, mid: 11.25, max: 16.87},
|
7
|
+
nne: {min: 16.88, mid: 22.5, max: 28.12},
|
8
|
+
nebn: {min: 28.13, mid: 33.75, max: 39.37},
|
9
|
+
ne: {min: 39.38, mid: 45.0, max: 50.62},
|
10
|
+
nebe: {min: 50.63, mid: 56.25, max: 61.87},
|
11
|
+
ene: {min: 61.88, mid: 67.5, max: 73.12},
|
12
|
+
ebn: {min: 73.13, mid: 78.75, max: 84.37},
|
13
|
+
e: {min: 84.38, mid: 90.0, max: 95.62},
|
14
|
+
ebs: {min: 95.63, mid: 101.25, max: 106.87},
|
15
|
+
ese: {min: 106.88, mid: 112.5, max: 118.12},
|
16
|
+
sebe: {min: 118.13, mid: 123.75, max: 129.37},
|
17
|
+
se: {min: 129.38, mid: 135.0, max: 140.62},
|
18
|
+
sebs: {min: 140.63, mid: 146.25, max: 151.87},
|
19
|
+
sse: {min: 151.88, mid: 157.5, max: 163.12},
|
20
|
+
sbe: {min: 163.13, mid: 168.75, max: 174.37},
|
21
|
+
s: {min: 174.38, mid: 180.0, max: 185.62},
|
22
|
+
sbw: {min: 185.63, mid: 191.25, max: 196.87},
|
23
|
+
ssw: {min: 196.88, mid: 202.5, max: 208.12},
|
24
|
+
swbs: {min: 208.13, mid: 213.75, max: 219.37},
|
25
|
+
sw: {min: 219.38, mid: 225.0, max: 230.62},
|
26
|
+
swbw: {min: 230.63, mid: 236.25, max: 241.87},
|
27
|
+
wsw: {min: 241.88, mid: 247.5, max: 253.12},
|
28
|
+
wbs: {min: 253.13, mid: 258.75, max: 264.37},
|
29
|
+
w: {min: 264.38, mid: 270.0, max: 275.62},
|
30
|
+
wbn: {min: 275.63, mid: 281.25, max: 286.87},
|
31
|
+
wnw: {min: 286.88, mid: 292.5, max: 298.12},
|
32
|
+
nwbw: {min: 298.13, mid: 303.75, max: 309.37},
|
33
|
+
nw: {min: 309.38, mid: 315.0, max: 320.62},
|
34
|
+
nwbn: {min: 320.63, mid: 326.25, max: 331.87},
|
35
|
+
nnw: {min: 331.88, mid: 337.50, max: 343.12},
|
36
|
+
nbw: {min: 343.13, mid: 348.75, max: 354.37}
|
37
|
+
}
|
38
|
+
|
39
|
+
class << self
|
40
|
+
def azimuth(compass_point)
|
41
|
+
key = normalize_key(compass_point)
|
42
|
+
point = POINTS[key]
|
43
|
+
point && point[:mid]
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def normalize_key(compass_point)
|
49
|
+
compass_point.to_s.downcase.to_sym
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CompassPoint do
|
4
|
+
describe '.azimuth' do
|
5
|
+
|
6
|
+
it 'returns mid point' do
|
7
|
+
expect(CompassPoint.azimuth('N')).to eq 0.0
|
8
|
+
expect(CompassPoint.azimuth(:nw)).to eq 315.0
|
9
|
+
expect(CompassPoint.azimuth('sbw')).to eq 191.25
|
10
|
+
expect(CompassPoint.azimuth('X')).to be_nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compass_point
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keith Morrison
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ruby library for working with compass points
|
14
|
+
email: keithm@infused.org
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.md
|
19
|
+
- LICENSE
|
20
|
+
files:
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- Guardfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- compass_point.gemspec
|
27
|
+
- lib/compass_point.rb
|
28
|
+
- spec/compass_point_spec.rb
|
29
|
+
- spec/spec_helper.rb
|
30
|
+
homepage: http://github.com/infused/compass_point
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- "--charset=UTF-8"
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.3.0
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 2.4.6
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: A Ruby library for working with compass points
|
55
|
+
test_files:
|
56
|
+
- spec/compass_point_spec.rb
|