un_locode 0.0.4 → 0.0.5
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 +4 -4
- data/.hound.yml +2 -0
- data/.ruby-style.yml +25 -0
- data/README.md +1 -1
- data/lib/un_locode/locode.rb +2 -3
- data/lib/un_locode/version.rb +1 -1
- data/spec/un_locode_spec.rb +15 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77e82eda82d1196c613e18cb50e64e6dc8decc29
|
4
|
+
data.tar.gz: f1342cfbdd1deba5f104214229804585e0bb4763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1bb35412af0bae937672e59a74ecb4776d2753873bcffb0865726a79eeaf26671afe38b3be1f3ad854f027b76fe9c3a633de709807e3cfc2c45fce96d851569
|
7
|
+
data.tar.gz: 33fa3890ec41ee225a694dcca692e6245206952f9a7ddac0df4482ebcd343e37e00b3e1c866ca148d2f879e87ff531f7e11e7565524b16f9a716e061026c3f57
|
data/.hound.yml
ADDED
data/.ruby-style.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Description: Limit lines to 80 characters.
|
3
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
|
4
|
+
Enabled: true
|
5
|
+
Max: 120
|
6
|
+
AllowURI: true
|
7
|
+
URISchemes:
|
8
|
+
- http
|
9
|
+
- https
|
10
|
+
Style/StringLiterals:
|
11
|
+
Description: Checks if uses of quotes match the configured preference.
|
12
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: single_quotes
|
15
|
+
SupportedStyles:
|
16
|
+
- single_quotes
|
17
|
+
- double_quotes
|
18
|
+
Style/StringLiteralsInInterpolation:
|
19
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
20
|
+
match the configured preference.
|
21
|
+
Enabled: true
|
22
|
+
EnforcedStyle: single_quotes
|
23
|
+
SupportedStyles:
|
24
|
+
- single_quotes
|
25
|
+
- double_quotes
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Locode
|
2
2
|
|
3
|
-
[](https://travis-ci.org/kabisa/un_locode)
|
4
4
|
[](http://badge.fury.io/rb/un_locode)
|
5
5
|
|
6
6
|
The un_locode gem gives you the ability to lookup UN/LOCODE codes. You can read more about the UN/LOCODE specifications here: [wiki](http://en.wikipedia.org/wiki/UN/LOCODE) and [UNECE](http://www.unece.org/fileadmin/DAM/cefact/locode/Service/LocodeColumn.htm).
|
data/lib/un_locode/locode.rb
CHANGED
@@ -29,9 +29,8 @@ module UnLocode
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.find_by_locode(locode)
|
32
|
-
locode = locode.
|
33
|
-
includes(:country).
|
34
|
-
.where(countries: { code: locode.first }).first
|
32
|
+
locode = locode.gsub(' ', '').upcase
|
33
|
+
includes(:country).find_by(city_code: locode[2..4], countries: { code: locode[0..1] })
|
35
34
|
end
|
36
35
|
|
37
36
|
def as_json options = {}
|
data/lib/un_locode/version.rb
CHANGED
data/spec/un_locode_spec.rb
CHANGED
@@ -94,13 +94,26 @@ describe UnLocode::Locode do
|
|
94
94
|
let!(:country) { UnLocode::Country.create name: 'NETHERLANDS', code: 'NL' }
|
95
95
|
let!(:location) { UnLocode::Locode.create name: 'Venlo', city_code: 'VEN', country: country }
|
96
96
|
|
97
|
-
context 'with supported functions' do
|
97
|
+
context 'with supported functions and space in search' do
|
98
98
|
subject { UnLocode::Locode.find_by_locode(search_term) }
|
99
99
|
let(:search_term) { 'NL VEN' }
|
100
|
-
|
100
|
+
its(:city_code) { should eql('VEN') }
|
101
101
|
its(:name) { should eql('Venlo') }
|
102
102
|
its(:country) { should eql(country) }
|
103
103
|
end
|
104
|
+
context 'with supported functions with actual space-less locode' do
|
105
|
+
subject { UnLocode::Locode.find_by_locode(search_term) }
|
106
|
+
let(:search_term) { 'NLVEN' }
|
107
|
+
its(:city_code) { should eql('VEN') }
|
108
|
+
its(:name) { should eql('Venlo') }
|
109
|
+
its(:country) { should eql(country) }
|
110
|
+
end
|
111
|
+
context 'with supported functions with mixed case locode' do
|
112
|
+
subject { UnLocode::Locode.find_by_locode(search_term) }
|
113
|
+
let(:search_term) { 'NlVen' }
|
114
|
+
its(:city_code) { should eql('VEN') }
|
115
|
+
end
|
116
|
+
|
104
117
|
end
|
105
118
|
end
|
106
119
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: un_locode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel de Graaf
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-07-
|
15
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -125,7 +125,9 @@ extra_rdoc_files: []
|
|
125
125
|
files:
|
126
126
|
- ".DS_Store"
|
127
127
|
- ".gitignore"
|
128
|
+
- ".hound.yml"
|
128
129
|
- ".rspec"
|
130
|
+
- ".ruby-style.yml"
|
129
131
|
- ".ruby-version"
|
130
132
|
- ".travis.yml"
|
131
133
|
- Gemfile
|