os_map_ref 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -3
- data/.rubocop.yml +122 -0
- data/.travis.yml +23 -17
- data/CHANGELOG.md +61 -0
- data/Gemfile +1 -4
- data/README.md +5 -3
- data/Rakefile +9 -5
- data/lib/os_map_ref/input_processor.rb +11 -11
- data/lib/os_map_ref/location.rb +11 -10
- data/lib/os_map_ref/version.rb +1 -1
- data/os_map_ref.gemspec +18 -11
- metadata +28 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e402a08b5f2575a30def6376c195855cdd1c4537
|
4
|
+
data.tar.gz: 82f882c3c5cf7c12c54519747deee392f0ecfdda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '079ba362e43f0993c800a7db2cde7ffddb1e1ba9ac2fb9a654cfb848dd129c5492952df2fa9fbf3f049560d0588fa06a49fc34f88925135f722e1681ddbaa892'
|
7
|
+
data.tar.gz: f49114adfdbbad429901f90e1df5b2050b2e778a487abadb76bdee5e753f12bd57d206a875806827e8521429ba4319085595e987865cc21e93d8f87a70430ab1
|
data/.codeclimate.yml
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
# Cop names are not displayed in offense messages by default. We find it useful to include this information so we can
|
4
|
+
# use it to investigate what the fix may be.
|
5
|
+
DisplayCopNames: true
|
6
|
+
# Style guide URLs are not displayed in offense messages by default. Again we find it useful to go straight to the
|
7
|
+
# documentation for a rule when investigating what the fix may be.
|
8
|
+
DisplayStyleGuide: true
|
9
|
+
Include:
|
10
|
+
- "**/*.gemspec"
|
11
|
+
- "**/*.rake"
|
12
|
+
- "**/*.rb"
|
13
|
+
- "**/Gemfile"
|
14
|
+
- "**/Rakefile"
|
15
|
+
Exclude:
|
16
|
+
- "**/bin/*"
|
17
|
+
|
18
|
+
# Rubymine disagrees and not sure how to fix Rubymine indentation right now
|
19
|
+
Layout/CaseIndentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# We believe it looks cluttered not having the ability to have empty lines after
|
23
|
+
# the module, class, and block declarations
|
24
|
+
Layout/EmptyLinesAroundBlockBody:
|
25
|
+
Enabled: false
|
26
|
+
Layout/EmptyLinesAroundModuleBody:
|
27
|
+
Enabled: false
|
28
|
+
Layout/EmptyLinesAroundClassBody:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
# Without this exclusion a line like this `expect { subject.call }` will get
|
32
|
+
# flagged as an error by Rubocop. This is a deliberate idiom in rspec so rather
|
33
|
+
# than add exceptions where it is used, we exclude spec's from this rule here.
|
34
|
+
# https://github.com/bbatsov/rubocop/issues/4222
|
35
|
+
Lint/AmbiguousBlockAssociation:
|
36
|
+
Exclude:
|
37
|
+
- "spec/**/*"
|
38
|
+
|
39
|
+
# TODO: Understand what the issue is and whether this needs to be more formally disabled (i.e. the dev team agree)
|
40
|
+
# We don't understand this for now - seems to prevent perfectly reasonable meta-programming
|
41
|
+
Lint/NestedMethodDefinition:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# We felt as a team that the default size of 15 was too low, and blocked what to us are sound methods which would not
|
45
|
+
# add any value if broken up, for exampler composer type methods. Therefore we agreed to up the score to 20 to allow
|
46
|
+
# for these types of methods
|
47
|
+
Metrics/AbcSize:
|
48
|
+
Max: 40
|
49
|
+
|
50
|
+
# We don't feel we can help having a large gemspec, hence we exclude it.
|
51
|
+
# We don't feel it makes sense to split specs and factories over multiple files,
|
52
|
+
# or when in a context be forced to try and come up with slightly different ones
|
53
|
+
# in order to reduce the block length. Hence we exclude specs and factories from
|
54
|
+
# this rule.
|
55
|
+
# Shared examples are the same as specs, but don't have the _spec.rb extension
|
56
|
+
# hence they are listed separately
|
57
|
+
Metrics/BlockLength:
|
58
|
+
Exclude:
|
59
|
+
- "**/*.gemspec"
|
60
|
+
- "**/spec/**/*_spec.rb"
|
61
|
+
- "**/spec/**/*_factory.rb"
|
62
|
+
- "**/spec/shared_examples/*.rb"
|
63
|
+
|
64
|
+
# We believe the default of 10 lines for a method length is too restrictive and often quickly hit just because we need
|
65
|
+
# to specify the namesspace, class and method before then doing something with it.
|
66
|
+
Metrics/MethodLength:
|
67
|
+
Max: 30
|
68
|
+
Metrics/ModuleLength:
|
69
|
+
Max: 400
|
70
|
+
Exclude:
|
71
|
+
- "**/spec/**/*_spec.rb"
|
72
|
+
|
73
|
+
# We believe the default 80 characters is too restrictive and that lines can still be readable and maintainable
|
74
|
+
# when no more than 120 characters. This also allows us to maximise our screen space.
|
75
|
+
Metrics/LineLength:
|
76
|
+
Max: 120
|
77
|
+
Exclude:
|
78
|
+
- "**spec/factories/**/*.rb"
|
79
|
+
- "**spec/features/**/*_spec.rb"
|
80
|
+
- "**spec/models/**/*_spec.rb"
|
81
|
+
- "**spec/policies/**/*_spec.rb"
|
82
|
+
- "**spec/routing/**/*_spec.rb"
|
83
|
+
|
84
|
+
# Turn these off as can totally mess with the expect{...}.to syntax
|
85
|
+
# Also reports on model validations using Proc.new { style blocks but trying to use do .. end raises invalid syntax
|
86
|
+
Style/BlockDelimiters:
|
87
|
+
Exclude:
|
88
|
+
- "**spec/**/*_spec.rb"
|
89
|
+
|
90
|
+
# As a web app, as long as the team commit to using well named classes for
|
91
|
+
# controllers, models etc it should not be necessary to add top-level class
|
92
|
+
# documentation.
|
93
|
+
Style/Documentation:
|
94
|
+
Enabled: false
|
95
|
+
|
96
|
+
# We've found the sprintf style for formatting strings can be useful when storing a formatted string as a template,
|
97
|
+
# and passing in strings that can vary with context. Therefore we chose to disable this rule.
|
98
|
+
Style/FormatString:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
# When using Ruby >= 2.3, Rubocop wants to add a comment to the top of *.rb
|
102
|
+
# to aid migration to frozen literals in Ruby 3.0. We are not interested in
|
103
|
+
# modifying every file at this point, so this cop is disabled for now.
|
104
|
+
Style/FrozenStringLiteralComment:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
# In specs we like to use the pattern of updating within an expect do block and
|
108
|
+
# then asserting a given attribute has changed as a result. This requires
|
109
|
+
# chaining hence we exclude specs from this rule
|
110
|
+
Style/MethodCalledOnDoEndBlock:
|
111
|
+
Exclude:
|
112
|
+
- "**/spec/**/*_spec.rb"
|
113
|
+
|
114
|
+
# There are no relative performance improvements using '' over "", therefore we believe there is more
|
115
|
+
# value in using "" for all strings irrespective of whether string interpolation is used
|
116
|
+
Style/StringLiterals:
|
117
|
+
EnforcedStyle: double_quotes
|
118
|
+
|
119
|
+
# Rubocop 0.42 introduced this cop - disabling for now until we have time to resolve
|
120
|
+
# the issues it raises.
|
121
|
+
Style/MethodMissing:
|
122
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,25 +1,31 @@
|
|
1
|
+
# Needed as part of submitting test coverage statistics to CodeClimate as part
|
2
|
+
# of the build
|
3
|
+
# https://docs.codeclimate.com/v1.0/docs/travis-ci-test-coverage
|
4
|
+
env:
|
5
|
+
global:
|
6
|
+
- CC_TEST_REPORTER_ID=df8a9d5af846f573eb944b1e7ba0ea40ec79efe0f3350af095054e2d5a6f2d56
|
7
|
+
|
1
8
|
language: ruby
|
2
9
|
cache: bundler
|
3
10
|
|
4
11
|
rvm:
|
5
12
|
- 2.2.3
|
6
13
|
|
7
|
-
|
14
|
+
# Travis CI clones repositories to a depth of 50 commits, which is only really
|
15
|
+
# useful if you are performing git operations.
|
16
|
+
# https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth
|
17
|
+
git:
|
18
|
+
depth: 3
|
8
19
|
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
20
|
+
before_script:
|
21
|
+
# Setup to support the CodeClimate test coverage submission
|
22
|
+
# As per CodeClimate's documentation, they suggest only running
|
23
|
+
# ./cc-test-reporter commands on travis-ci push builds only. Hence we wrap all
|
24
|
+
# the codeclimate test coverage related commands in a check that tests if we
|
25
|
+
# are in a pull request or not.
|
26
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; fi
|
27
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then chmod +x ./cc-test-reporter; fi
|
28
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter before-build; fi
|
17
29
|
|
18
|
-
|
19
|
-
|
20
|
-
# in the open we used this guide https://docs.travis-ci.com/user/encryption-keys/ to encryt the
|
21
|
-
# value. Essentially install travis gem, then run `travis encrypt <my_code_climate_api_key>`
|
22
|
-
addons:
|
23
|
-
code_climate:
|
24
|
-
repo_token:
|
25
|
-
secure: "G1IaZNDiJe95Ng3jvDeg4gToha86SNgDOu7JzNwb9+qV6I0R10vqKEhGwlYQ4eazoO3VE3vzzIWszY1gpbtkgVTkC4mkBawTyiZevhMtFRfXjbz2WTLmMszJf2ysIFaMmlnfNrjLwQWrGx7jhGm/nt7hsrhcg1MkO2EmuOhryKkT7Z9W2lnr1oIu/XwUDbY6ydqCfGq+e/a+bA+4LcQ20PCSGL0KnggcSJKSAX2O51GpeQ5Yofjm2XJ/Hagy3VSj1rGPCMnlEHLwydebqI/lYhQJUcv7rZAIUWDJ3Rg68sVd6WixpnY3n4GcTU+fnSYbUAqtLyNOoKGxBhXhljgoOyx/HjxWe8ymUX35xEswF0aq8Q0PoqUvRVBu50gsla0c7vhCm4sYF3KxxprzjTy5RHEokuow2Fe4Wa4ulM2U2PqQy6LzvFHjJzKMAfhx7thtstTRFF//buL9OBYIAtG/dnD+Jfh2K7zNTjnQf0pYMhTj/VPK78sR2h7SlP1yEYCyy+AqyFiEcq/49giJ/c7yLW16xIVENQsJ8dfR8SXW0d4MGOoVP0pPOh/+OiO3PY2Yb99A6uZAKP9l1+hkyAE6qDhLzoO1WutsKeX2IrZXbPrfi94JifVnqT9wJLpz6e57powESFAp1ROcJChFJfEWL/RKBK7dVzMWFt5WK0AWUIo="
|
30
|
+
after_script:
|
31
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.4.2](https://github.com/DEFRA/os_map_ref/tree/v0.4.2) (2017-10-30)
|
4
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.4.1...v0.4.2)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Bump version no. for release of v0.4.2 [\#19](https://github.com/DEFRA/os_map_ref/pull/19) ([Cruikshanks](https://github.com/Cruikshanks))
|
9
|
+
- Add changelog and ability to auto generate it [\#18](https://github.com/DEFRA/os_map_ref/pull/18) ([Cruikshanks](https://github.com/Cruikshanks))
|
10
|
+
- Fix badge links in README pointing 2 old EA Github [\#17](https://github.com/DEFRA/os_map_ref/pull/17) ([Cruikshanks](https://github.com/Cruikshanks))
|
11
|
+
- Fix and update codeclimate and travis-ci config [\#16](https://github.com/DEFRA/os_map_ref/pull/16) ([Cruikshanks](https://github.com/Cruikshanks))
|
12
|
+
- Add std rubocop config and resolve issues found [\#15](https://github.com/DEFRA/os_map_ref/pull/15) ([Cruikshanks](https://github.com/Cruikshanks))
|
13
|
+
- Correct details in gemspec [\#14](https://github.com/DEFRA/os_map_ref/pull/14) ([Cruikshanks](https://github.com/Cruikshanks))
|
14
|
+
- Integrate project with Hakiri [\#13](https://github.com/DEFRA/os_map_ref/pull/13) ([Cruikshanks](https://github.com/Cruikshanks))
|
15
|
+
|
16
|
+
## [v0.4.1](https://github.com/DEFRA/os_map_ref/tree/v0.4.1) (2016-05-17)
|
17
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.4.0...v0.4.1)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Confirm codeclimate api key [\#12](https://github.com/DEFRA/os_map_ref/pull/12) ([Cruikshanks](https://github.com/Cruikshanks))
|
22
|
+
- Integrate project with codeclimate [\#11](https://github.com/DEFRA/os_map_ref/pull/11) ([Cruikshanks](https://github.com/Cruikshanks))
|
23
|
+
- Add version badge to README [\#10](https://github.com/DEFRA/os_map_ref/pull/10) ([Cruikshanks](https://github.com/Cruikshanks))
|
24
|
+
|
25
|
+
## [v0.4.0](https://github.com/DEFRA/os_map_ref/tree/v0.4.0) (2016-04-05)
|
26
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.3.0...v0.4.0)
|
27
|
+
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- Correct error in grid: skipped K instead of I in right-hand portion [\#9](https://github.com/DEFRA/os_map_ref/pull/9) ([reggieb](https://github.com/reggieb))
|
31
|
+
- Fix/improve range of inputs accepted [\#8](https://github.com/DEFRA/os_map_ref/pull/8) ([reggieb](https://github.com/reggieb))
|
32
|
+
|
33
|
+
## [v0.3.0](https://github.com/DEFRA/os_map_ref/tree/v0.3.0) (2016-04-04)
|
34
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.2.0...v0.3.0)
|
35
|
+
|
36
|
+
**Closed issues:**
|
37
|
+
|
38
|
+
- Convert tests to Rspec [\#2](https://github.com/DEFRA/os_map_ref/issues/2)
|
39
|
+
|
40
|
+
**Merged pull requests:**
|
41
|
+
|
42
|
+
- Changes tests over to rspec [\#7](https://github.com/DEFRA/os_map_ref/pull/7) ([reggieb](https://github.com/reggieb))
|
43
|
+
- Update contribution section in README [\#6](https://github.com/DEFRA/os_map_ref/pull/6) ([Cruikshanks](https://github.com/Cruikshanks))
|
44
|
+
- Update travis configuration for repo [\#5](https://github.com/DEFRA/os_map_ref/pull/5) ([Cruikshanks](https://github.com/Cruikshanks))
|
45
|
+
- Bump version to 0.2.0 [\#4](https://github.com/DEFRA/os_map_ref/pull/4) ([reggieb](https://github.com/reggieb))
|
46
|
+
|
47
|
+
## [v0.2.0](https://github.com/DEFRA/os_map_ref/tree/v0.2.0) (2016-03-30)
|
48
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.1.1...v0.2.0)
|
49
|
+
|
50
|
+
**Merged pull requests:**
|
51
|
+
|
52
|
+
- fixed typo in prefix matrix [\#3](https://github.com/DEFRA/os_map_ref/pull/3) ([kennyevil](https://github.com/kennyevil))
|
53
|
+
- Add license details to README [\#1](https://github.com/DEFRA/os_map_ref/pull/1) ([Cruikshanks](https://github.com/Cruikshanks))
|
54
|
+
|
55
|
+
## [v0.1.1](https://github.com/DEFRA/os_map_ref/tree/v0.1.1) (2016-03-24)
|
56
|
+
[Full Changelog](https://github.com/DEFRA/os_map_ref/compare/v0.1.0...v0.1.1)
|
57
|
+
|
58
|
+
## [v0.1.0](https://github.com/DEFRA/os_map_ref/tree/v0.1.0) (2016-03-23)
|
59
|
+
|
60
|
+
|
61
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# OsMapRef
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
4
|
-
[![
|
5
|
-
[![Test Coverage](https://codeclimate.com/
|
3
|
+
[![Build Status](https://travis-ci.org/DEFRA/os_map_ref.svg?branch=master)](https://travis-ci.org/DEFRA/os_map_ref)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/759edb337395f3c0e9d2/maintainability)](https://codeclimate.com/github/DEFRA/os_map_ref/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/759edb337395f3c0e9d2/test_coverage)](https://codeclimate.com/github/DEFRA/os_map_ref/test_coverage)
|
6
|
+
[![security](https://hakiri.io/github/DEFRA/os_map_ref/master.svg)](https://hakiri.io/github/DEFRA/os_map_ref/master)
|
7
|
+
[![Dependency Status](https://dependencyci.com/github/DEFRA/os_map_ref/badge)](https://dependencyci.com/github/DEFRA/os_map_ref)
|
6
8
|
[![Gem Version](https://badge.fury.io/rb/os_map_ref.svg)](https://badge.fury.io/rb/os_map_ref)
|
7
9
|
|
8
10
|
This gem allows you to gather U.K. Ordnance Survey Eastings, North, and Map
|
data/Rakefile
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "github_changelog_generator/task"
|
3
3
|
|
4
4
|
begin
|
5
|
-
require
|
5
|
+
require "rspec/core/rake_task"
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
rescue LoadError
|
7
|
+
rescue LoadError => err
|
8
|
+
puts "Load error: #{err}"
|
8
9
|
end
|
9
10
|
|
10
|
-
task :
|
11
|
+
task test: :spec
|
11
12
|
|
12
|
-
task :
|
13
|
+
task default: :test
|
14
|
+
|
15
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
16
|
+
end
|
@@ -18,7 +18,7 @@ module OsMapRef
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def map_reference_params
|
21
|
-
{map_reference: processed_map_reference}
|
21
|
+
{ map_reference: processed_map_reference }
|
22
22
|
end
|
23
23
|
|
24
24
|
def easting_northing_params
|
@@ -33,20 +33,20 @@ module OsMapRef
|
|
33
33
|
grid_letters.upcase,
|
34
34
|
padded_map_reference_easting,
|
35
35
|
padded_map_reference_northing
|
36
|
-
].join(
|
36
|
+
].join(" ")
|
37
37
|
end
|
38
38
|
|
39
39
|
def map_reference_elements
|
40
|
-
@map_reference_elements ||=
|
40
|
+
@map_reference_elements ||= determine_map_reference_elements
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def determine_map_reference_elements
|
44
44
|
match = map_reference_pattern.match input
|
45
|
-
(1..3).collect{|n| match[n]}
|
45
|
+
(1..3).collect { |n| match[n] }
|
46
46
|
end
|
47
47
|
|
48
48
|
def grid_letters
|
49
|
-
|
49
|
+
map_reference_elements[0]
|
50
50
|
end
|
51
51
|
|
52
52
|
def map_reference_easting
|
@@ -75,10 +75,10 @@ module OsMapRef
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def easting_and_northing
|
78
|
-
@easting_and_northing ||=
|
78
|
+
@easting_and_northing ||= determine_easting_and_northing
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
81
|
+
def determine_easting_and_northing
|
82
82
|
match = easting_northing_pattern.match input
|
83
83
|
easting = match[1]
|
84
84
|
northing = match[3]
|
@@ -98,7 +98,7 @@ module OsMapRef
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def padding
|
101
|
-
|
101
|
+
"0"
|
102
102
|
end
|
103
103
|
|
104
104
|
# Matches are:
|
@@ -110,8 +110,8 @@ module OsMapRef
|
|
110
110
|
# "1234.5, 6789.0" --> 1: "1234.5", 2: ".5", 3: "6789.0", 4: ".0"
|
111
111
|
# "1234 6789" --> 1: "1234", 2: nil, 3: "6789", 4: nil
|
112
112
|
def easting_northing_pattern
|
113
|
-
eastings = /\d{3,6}/
|
114
|
-
northings = /\d{3,7}/
|
113
|
+
eastings = /\d{3,6}/ # 3 to 6 digits
|
114
|
+
northings = /\d{3,7}/ # 3 to 7 digits
|
115
115
|
decimals = /\.\d+/ # decimal point and trailing digits
|
116
116
|
separator = /[\,\s]+/ # commas or spaces
|
117
117
|
/(#{eastings}(#{decimals})?)#{separator}(#{northings}(#{decimals})?)/
|
data/lib/os_map_ref/location.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "matrix"
|
2
|
+
|
2
3
|
module OsMapRef
|
3
4
|
class Location
|
4
5
|
|
@@ -7,14 +8,14 @@ module OsMapRef
|
|
7
8
|
new input_processor.params
|
8
9
|
end
|
9
10
|
|
10
|
-
def initialize(args={})
|
11
|
+
def initialize(args = {})
|
11
12
|
@map_reference = args[:map_reference].freeze if args[:map_reference]
|
12
13
|
@easting = remove_decimals(args[:easting]) if args[:easting]
|
13
14
|
@northing = remove_decimals(args[:northing]) if args[:northing]
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
def remove_decimals(number)
|
17
|
-
number.to_s.sub
|
18
|
+
number.to_s.sub(/\.\d*/, "")
|
18
19
|
end
|
19
20
|
|
20
21
|
def map_reference
|
@@ -22,7 +23,7 @@ module OsMapRef
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def build_map_reference
|
25
|
-
[grid_reference_prefix, short_easting, short_northing].join(
|
26
|
+
[grid_reference_prefix, short_easting, short_northing].join(" ")
|
26
27
|
end
|
27
28
|
|
28
29
|
def grid_easting
|
@@ -74,7 +75,7 @@ module OsMapRef
|
|
74
75
|
def map_reference_parts
|
75
76
|
@map_reference_parts ||= map_reference.split
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
def prefix
|
79
80
|
map_reference_parts[0]
|
80
81
|
end
|
@@ -83,13 +84,13 @@ module OsMapRef
|
|
83
84
|
# matching the map reference prefix. So 'ST 58901 71053' will return [1, 3]
|
84
85
|
# which are the coordinates of the prefix 'ST' in the grid.
|
85
86
|
def prefix_coordinates
|
86
|
-
@prefix_coordinates ||=
|
87
|
+
@prefix_coordinates ||= determine_prefix_coordinates
|
87
88
|
end
|
88
|
-
|
89
|
-
def
|
89
|
+
|
90
|
+
def determine_prefix_coordinates
|
90
91
|
matrix.index(prefix) || raise_prefix_error(prefix)
|
91
92
|
end
|
92
|
-
|
93
|
+
|
93
94
|
def raise_prefix_error(prefix)
|
94
95
|
raise OsMapRef::Error, "Unable to process map reference #{@map_reference}: #{prefix} not found"
|
95
96
|
end
|
data/lib/os_map_ref/version.rb
CHANGED
data/os_map_ref.gemspec
CHANGED
@@ -1,26 +1,33 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
3
|
+
|
4
|
+
require "os_map_ref/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "os_map_ref"
|
8
8
|
spec.version = OsMapRef::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Environment Agency"]
|
10
|
+
spec.email = ["alan.cruikshanks@environment-agency.gov.uk"]
|
11
11
|
|
12
|
-
|
13
|
-
spec.
|
14
|
-
spec.
|
12
|
+
# rubocop:disable Metrics/LineLength
|
13
|
+
spec.summary = "A tool to help handle UK Ordnance Survey map references, in particular to convert them to other coordinate systems"
|
14
|
+
spec.description = "This gem allows you to gather U.K. Ordnance Survey Eastings, North, and Map References from a range of text inputs; and output them in a consistent manner"
|
15
|
+
# rubocop:enable Metrics/LineLength
|
16
|
+
spec.homepage = "https://github.com/DEFRA/os_map_ref"
|
17
|
+
spec.license = "Nonstandard"
|
15
18
|
|
16
|
-
spec.files = `git ls-files -z
|
19
|
+
spec.files = `git ls-files -z`
|
20
|
+
.split("\x0")
|
21
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
22
|
spec.bindir = "exe"
|
18
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
24
|
spec.require_paths = ["lib"]
|
20
|
-
|
25
|
+
|
26
|
+
spec.required_ruby_version = ">= 1.9"
|
21
27
|
|
22
28
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
25
30
|
spec.add_development_dependency "rspec"
|
31
|
+
spec.add_development_dependency "simplecov", "~> 0.13"
|
32
|
+
spec.add_development_dependency "github_changelog_generator"
|
26
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: os_map_ref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Environment Agency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,21 +39,35 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0.13'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0.13'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: github_changelog_generator
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -69,7 +83,7 @@ dependencies:
|
|
69
83
|
description: This gem allows you to gather U.K. Ordnance Survey Eastings, North, and
|
70
84
|
Map References from a range of text inputs; and output them in a consistent manner
|
71
85
|
email:
|
72
|
-
-
|
86
|
+
- alan.cruikshanks@environment-agency.gov.uk
|
73
87
|
executables: []
|
74
88
|
extensions: []
|
75
89
|
extra_rdoc_files: []
|
@@ -77,7 +91,9 @@ files:
|
|
77
91
|
- ".codeclimate.yml"
|
78
92
|
- ".gitignore"
|
79
93
|
- ".rspec"
|
94
|
+
- ".rubocop.yml"
|
80
95
|
- ".travis.yml"
|
96
|
+
- CHANGELOG.md
|
81
97
|
- Gemfile
|
82
98
|
- LICENSE
|
83
99
|
- README.md
|
@@ -90,9 +106,9 @@ files:
|
|
90
106
|
- lib/os_map_ref/location.rb
|
91
107
|
- lib/os_map_ref/version.rb
|
92
108
|
- os_map_ref.gemspec
|
93
|
-
homepage: https://github.com/
|
109
|
+
homepage: https://github.com/DEFRA/os_map_ref
|
94
110
|
licenses:
|
95
|
-
-
|
111
|
+
- Nonstandard
|
96
112
|
metadata: {}
|
97
113
|
post_install_message:
|
98
114
|
rdoc_options: []
|
@@ -102,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
118
|
requirements:
|
103
119
|
- - ">="
|
104
120
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
121
|
+
version: '1.9'
|
106
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
123
|
requirements:
|
108
124
|
- - ">="
|
@@ -110,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
126
|
version: '0'
|
111
127
|
requirements: []
|
112
128
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.6.11
|
114
130
|
signing_key:
|
115
131
|
specification_version: 4
|
116
132
|
summary: A tool to help handle UK Ordnance Survey map references, in particular to
|