ruby-postcodeanywhere 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +20 -9
- data/Postcode Anywhere.tmproj +3 -3
- data/lib/ruby-postcodeanywhere.rb +43 -35
- data/ruby-postcodeanywhere.gemspec +1 -1
- data/spec/ruby-postcodeanywhere_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -8
- metadata +73 -69
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGM3ZTQ2ZTY4Yjg0MGM4ZDUwOTU0OTBkYjQ0MTZmOWIxYWRkZDQ5Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTU0NDk5YzU3NjVjYTA5YTE2MDc3NWVhZDlkMDBjYmM3YmMzZjI5MQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzM3NmVkNGNjZGYxNDc5NmY4ZDU1MmMwY2JjODgzYTM1Mjk4M2NlY2E1OGQz
|
10
|
+
N2MwZjlkMmQ0NGU4M2NlYmY1YjIzZWU5YjUxOWIwZTMyMzQ0YmIyNGM4N2Yw
|
11
|
+
NTA2YjI5NzQyY2JhNjZiYThhMjI3NjRjZmM2MzVmNGQ0M2VmY2U=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjhhNjE5ZTlkNjkzYjgxMWQ4NzYyYTRjNzhhZmYzYmIwY2JkOGVhOWZmN2Jh
|
14
|
+
MzI4M2FlMjU0ZTY5ZjNiMjkwYjVhMDY2MmE2ZjhlOWFlYTZiNGUwODY0MTc5
|
15
|
+
YzExNGRkMGFmODBiOWZkYzQzNzE2YTYwY2IzM2IzNjdlMDM2MWE=
|
data/Gemfile
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
3
|
gem "httparty"
|
7
4
|
|
8
|
-
|
9
|
-
|
5
|
+
gem "activesupport"
|
6
|
+
gem "i18n"
|
7
|
+
|
10
8
|
group :development do
|
11
|
-
gem "rspec"
|
9
|
+
gem "rspec"
|
12
10
|
gem "bundler"
|
13
11
|
gem "jeweler", "~> 1.6.2"
|
14
12
|
gem "rcov", ">= 0"
|
13
|
+
gem "webmock", :require => false
|
15
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,43 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.1.1)
|
5
|
+
multi_json (~> 1.0)
|
6
|
+
addressable (2.2.7)
|
4
7
|
crack (0.1.8)
|
5
|
-
diff-lcs (1.1.
|
8
|
+
diff-lcs (1.1.3)
|
6
9
|
git (1.2.5)
|
7
10
|
httparty (0.7.8)
|
8
11
|
crack (= 0.1.8)
|
12
|
+
i18n (0.6.0)
|
9
13
|
jeweler (1.6.2)
|
10
14
|
bundler (~> 1.0)
|
11
15
|
git (>= 1.2.5)
|
12
16
|
rake
|
17
|
+
multi_json (1.0.4)
|
13
18
|
rake (0.9.2)
|
14
19
|
rcov (0.9.9)
|
15
|
-
rspec (2.
|
16
|
-
rspec-core (~> 2.
|
17
|
-
rspec-expectations (~> 2.
|
18
|
-
rspec-mocks (~> 2.
|
19
|
-
rspec-core (2.
|
20
|
-
rspec-expectations (2.
|
20
|
+
rspec (2.8.0)
|
21
|
+
rspec-core (~> 2.8.0)
|
22
|
+
rspec-expectations (~> 2.8.0)
|
23
|
+
rspec-mocks (~> 2.8.0)
|
24
|
+
rspec-core (2.8.0)
|
25
|
+
rspec-expectations (2.8.0)
|
21
26
|
diff-lcs (~> 1.1.2)
|
22
|
-
rspec-mocks (2.
|
27
|
+
rspec-mocks (2.8.0)
|
28
|
+
webmock (1.8.0)
|
29
|
+
addressable (>= 2.2.7)
|
30
|
+
crack (>= 0.1.7)
|
23
31
|
|
24
32
|
PLATFORMS
|
25
33
|
ruby
|
26
34
|
|
27
35
|
DEPENDENCIES
|
36
|
+
activesupport
|
28
37
|
bundler
|
29
38
|
httparty
|
39
|
+
i18n
|
30
40
|
jeweler (~> 1.6.2)
|
31
41
|
rcov
|
32
|
-
rspec
|
42
|
+
rspec
|
43
|
+
webmock
|
data/Postcode Anywhere.tmproj
CHANGED
@@ -112,14 +112,14 @@
|
|
112
112
|
<key>caret</key>
|
113
113
|
<dict>
|
114
114
|
<key>column</key>
|
115
|
-
<integer>
|
115
|
+
<integer>60</integer>
|
116
116
|
<key>line</key>
|
117
|
-
<integer>
|
117
|
+
<integer>21</integer>
|
118
118
|
</dict>
|
119
119
|
<key>firstVisibleColumn</key>
|
120
120
|
<integer>0</integer>
|
121
121
|
<key>firstVisibleLine</key>
|
122
|
-
<integer>
|
122
|
+
<integer>0</integer>
|
123
123
|
</dict>
|
124
124
|
<key>ruby-postcodeanywhere.gemspec</key>
|
125
125
|
<dict>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
2
3
|
|
3
4
|
module PostcodeAnywhere
|
5
|
+
autoload :BankAccountValidation, 'postcode_anywhere/bank_account_validation'
|
4
6
|
|
5
7
|
# Account codes to access the PostcodeAnywhere Service
|
6
8
|
mattr_accessor :account_code
|
@@ -11,39 +13,39 @@ module PostcodeAnywhere
|
|
11
13
|
def self.setup
|
12
14
|
yield self
|
13
15
|
end
|
14
|
-
|
15
|
-
class PostcodeSearch
|
16
|
+
|
17
|
+
class PostcodeSearch
|
16
18
|
include HTTParty
|
17
|
-
|
19
|
+
|
18
20
|
base_uri 'https://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive'
|
19
|
-
|
21
|
+
|
20
22
|
ADDRESS_LOOKUP = "/Find/v1.10/xmla.ws"
|
21
23
|
ADDRESS_FETCH = "/RetrieveById/v1.20/xmla.ws"
|
22
24
|
RETRIEVE_BY_PARTS_URL = "/RetrieveByParts/v1.00/xmla.ws"
|
23
25
|
|
24
26
|
def lookup(postcode)
|
25
|
-
|
27
|
+
|
26
28
|
raise "Postcode is Required" if postcode.blank? || postcode.nil?
|
27
|
-
|
29
|
+
|
28
30
|
options={ "SearchTerm" => postcode.gsub(/\s/, '') }
|
29
31
|
options.merge!(self.license_information)
|
30
|
-
|
32
|
+
|
31
33
|
data = PostcodeSearch.get( ADDRESS_LOOKUP, {:query => options} )
|
32
34
|
formatted_data = []
|
33
|
-
|
35
|
+
|
34
36
|
return formatted_data if data.parsed_response['Table']['Columns']['Column'][0]['Name'] == "Error"
|
35
|
-
|
37
|
+
|
36
38
|
puts formatted_data
|
37
|
-
|
39
|
+
|
38
40
|
unless data.parsed_response['Table']['Columns']['Column'][0]['Name'] == "Error"
|
39
|
-
|
41
|
+
|
40
42
|
begin
|
41
43
|
data.parsed_response["Table"]["Rows"]["Row"].each do |item|
|
42
44
|
data_item = AddressListItem.new
|
43
45
|
data_item.id = item['Id']
|
44
46
|
data_item.street_address = item['StreetAddress']
|
45
47
|
data_item.place = item['Place']
|
46
|
-
|
48
|
+
|
47
49
|
formatted_data << data_item
|
48
50
|
end
|
49
51
|
rescue
|
@@ -52,7 +54,7 @@ module PostcodeAnywhere
|
|
52
54
|
data_item.id = item['Id']
|
53
55
|
data_item.street_address = item['StreetAddress']
|
54
56
|
data_item.place = item['Place']
|
55
|
-
|
57
|
+
|
56
58
|
formatted_data << data_item
|
57
59
|
end
|
58
60
|
end
|
@@ -61,43 +63,43 @@ module PostcodeAnywhere
|
|
61
63
|
|
62
64
|
def fetch_by_parts(options={})
|
63
65
|
options.merge!(self.license_information)
|
64
|
-
|
66
|
+
|
65
67
|
if options['postcode']
|
66
68
|
options['postcode'] = options['postcode'].gsub(/\s/, '')
|
67
69
|
end
|
68
|
-
|
70
|
+
|
69
71
|
data = PostcodeSearch.get( RETRIEVE_BY_PARTS_URL, {:query => options} )
|
70
|
-
|
72
|
+
|
71
73
|
process_address(data)
|
72
74
|
end
|
73
75
|
|
74
76
|
def fetch(id)
|
75
77
|
options={ :id => id }
|
76
78
|
options.merge!(self.license_information)
|
77
|
-
|
79
|
+
|
78
80
|
data = PostcodeSearch.get( ADDRESS_FETCH, {:query => options} )
|
79
|
-
|
81
|
+
|
80
82
|
process_address(data)
|
81
83
|
end
|
82
84
|
|
83
85
|
def license_information
|
84
86
|
{:account_code => PostcodeAnywhere.account_code, :license_code => PostcodeAnywhere.license_code}
|
85
87
|
end
|
86
|
-
|
87
|
-
|
88
|
-
private
|
89
|
-
def process_address(data)
|
90
|
-
|
88
|
+
|
89
|
+
|
90
|
+
private
|
91
|
+
def process_address(data)
|
92
|
+
|
91
93
|
raise 'No Data Found' if data.parsed_response['Table']['Columns']['Column'][0]['Name'] == "Error"
|
92
|
-
|
94
|
+
|
93
95
|
formatted_data = data.parsed_response["Table"]["Rows"]["Row"]
|
94
|
-
|
96
|
+
|
95
97
|
address_lookup = AddressLookup.new
|
96
|
-
|
98
|
+
|
97
99
|
address_lookup.mailsort = formatted_data["Mailsort"]
|
98
100
|
address_lookup.barcode = formatted_data["Barcode"]
|
99
101
|
address_lookup.type = formatted_data["Type"]
|
100
|
-
|
102
|
+
|
101
103
|
address_lookup.udprn = formatted_data["Udprn"]
|
102
104
|
address_lookup.company = formatted_data["Company"]
|
103
105
|
address_lookup.department = formatted_data["Department"]
|
@@ -107,28 +109,34 @@ module PostcodeAnywhere
|
|
107
109
|
address_lookup.address_line_3 = formatted_data["Line3"]
|
108
110
|
address_lookup.address_line_4 = formatted_data["Line4"]
|
109
111
|
address_lookup.address_line_5 = formatted_data["Line5"]
|
112
|
+
address_lookup.building_name = formatted_data["BuildingName"]
|
113
|
+
address_lookup.building_number = formatted_data["BuildingNumber"]
|
114
|
+
address_lookup.street = formatted_data["PrimaryStreet"]
|
115
|
+
address_lookup.flat = formatted_data["SubBuilding"]
|
116
|
+
address_lookup.district = formatted_data["DependentLocality"]
|
110
117
|
address_lookup.post_town = formatted_data["PostTown"]
|
111
118
|
address_lookup.county = formatted_data["County"].blank? ? formatted_data["PostTown"] : formatted_data["County"]
|
112
119
|
|
113
120
|
|
114
121
|
address_lookup
|
115
122
|
end
|
116
|
-
|
117
|
-
|
123
|
+
|
124
|
+
|
118
125
|
end
|
119
126
|
|
120
127
|
class AddressLookup
|
121
|
-
|
128
|
+
|
129
|
+
attr_accessor :building_name, :building_number, :street, :flat, :district
|
122
130
|
attr_accessor :postcode, :address_line_1, :address_line_2, :address_line_3, :address_line_4, :address_line_5
|
123
131
|
attr_accessor :post_town, :county, :city, :county_name, :zip4, :state, :udprn, :company, :department
|
124
132
|
attr_accessor :mailsort, :barcode, :type
|
125
|
-
|
126
|
-
end
|
127
|
-
|
133
|
+
|
134
|
+
end
|
135
|
+
|
128
136
|
class AddressListItem
|
129
137
|
|
130
138
|
attr_accessor :id, :street_address, :place
|
131
139
|
|
132
140
|
end
|
133
|
-
|
134
|
-
|
141
|
+
end
|
142
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
require 'ruby-postcodeanywhere'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'webmock/rspec'
|
5
4
|
|
6
|
-
|
7
|
-
# in ./support/ and its subdirectories.
|
8
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
5
|
+
require 'ruby-postcodeanywhere'
|
9
6
|
|
10
7
|
RSpec.configure do |config|
|
11
|
-
|
12
8
|
end
|
9
|
+
|
metadata
CHANGED
@@ -1,82 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-postcodeanywhere
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Chris Norman
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2011-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: httparty
|
17
|
-
requirement:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
27
28
|
name: rspec
|
28
|
-
requirement:
|
29
|
-
|
30
|
-
requirements:
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
31
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
32
|
+
- !ruby/object:Gem::Version
|
33
33
|
version: 2.3.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
38
42
|
name: bundler
|
39
|
-
requirement:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
version: "0"
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
45
48
|
type: :development
|
46
49
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
49
56
|
name: jeweler
|
50
|
-
requirement:
|
51
|
-
|
52
|
-
requirements:
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
53
59
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
60
|
+
- !ruby/object:Gem::Version
|
55
61
|
version: 1.6.2
|
56
62
|
type: :development
|
57
63
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
60
70
|
name: rcov
|
61
|
-
requirement:
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
version: "0"
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
67
76
|
type: :development
|
68
77
|
prerelease: false
|
69
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
70
83
|
description: Gem to provide basic access to PostcodeAnywhere services
|
71
84
|
email: chris@norman.me
|
72
85
|
executables: []
|
73
|
-
|
74
86
|
extensions: []
|
75
|
-
|
76
|
-
extra_rdoc_files:
|
87
|
+
extra_rdoc_files:
|
77
88
|
- LICENSE.txt
|
78
89
|
- README.rdoc
|
79
|
-
files:
|
90
|
+
files:
|
80
91
|
- .document
|
81
92
|
- .rspec
|
82
93
|
- Gemfile
|
@@ -91,34 +102,27 @@ files:
|
|
91
102
|
- spec/ruby-postcodeanywhere_spec.rb
|
92
103
|
- spec/spec_helper.rb
|
93
104
|
homepage: http://github.com/intothefire/ruby-postcodeanywhere
|
94
|
-
licenses:
|
105
|
+
licenses:
|
95
106
|
- MIT
|
107
|
+
metadata: {}
|
96
108
|
post_install_message:
|
97
109
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
110
|
+
require_paths:
|
100
111
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: "0"
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
116
122
|
requirements: []
|
117
|
-
|
118
123
|
rubyforge_project:
|
119
|
-
rubygems_version:
|
124
|
+
rubygems_version: 2.0.3
|
120
125
|
signing_key:
|
121
126
|
specification_version: 3
|
122
127
|
summary: Gem to provide basic access to PostcodeAnywhere services
|
123
128
|
test_files: []
|
124
|
-
|