postcodeapi 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -4
- data/lib/postcodeapi/api.rb +5 -0
- data/lib/postcodeapi/version.rb +1 -1
- data/spec/postcodeapi/api_spec.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 086780903cb3fcc7b346d4b7590f8fa4248ace1e
|
4
|
+
data.tar.gz: c2856c4476339f2ca47b347d19ac3b888b7d6a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94393668ff6c3db3b09b6b3a56f96448eac1d74d49878f9a8655b0140f895050802e57c0e62b9d88bb091e9748d3acddc90c9b7bb68d7ae37835d61f2d218769
|
7
|
+
data.tar.gz: 23c03337847c5d51492d7a20ecbf677b510c637586a8dd2c86e5a5d852b44eedcfad4cfe15bf5588ccae45365bff268985964a8c5b2643151326a50182e96947
|
data/.travis.yml
CHANGED
data/lib/postcodeapi/api.rb
CHANGED
@@ -8,6 +8,7 @@ module Postcode
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def postcode(postcode, house_number = nil, options = {})
|
11
|
+
postcode = sanitize(postcode)
|
11
12
|
uri = URI.parse([BASE_URI, postcode, house_number].compact.join('/'))
|
12
13
|
|
13
14
|
req = Net::HTTP::Get.new(uri.path)
|
@@ -19,5 +20,9 @@ module Postcode
|
|
19
20
|
|
20
21
|
Hashie::Mash.new(JSON.parse(res.body))
|
21
22
|
end
|
23
|
+
|
24
|
+
def sanitize(postcode)
|
25
|
+
postcode.gsub(/\s+/, '').upcase
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/postcodeapi/version.rb
CHANGED
@@ -40,6 +40,13 @@ describe Postcode::API do
|
|
40
40
|
result.resource.latitude.should eq(51.9401)
|
41
41
|
result.resource.longitude.should eq(5.61531)
|
42
42
|
end
|
43
|
+
|
44
|
+
it 'sanitizes input before lookup' do
|
45
|
+
result = api.postcode('5041 eb')
|
46
|
+
|
47
|
+
result.success.should be_true
|
48
|
+
result.resource.postcode.should eq("5041EB")
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
context "with postcode and house number" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postcodeapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ariejan de Vroom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.4.5
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Wrapper around the postcodeapi.nu API.
|