ideal_postcodes 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c34b866375b1eb59033c3c9f4139ed49e1f91bd1
4
+ data.tar.gz: 48da9070ca6d8cb2af643879f1837d697c3a89af
5
+ SHA512:
6
+ metadata.gz: 11b659c4e56fb6188874468b2c2e8363eb7088ca13672540ced297f762f5a096f53f49f51d6b2144bc6af0a3006596e2be9e550291aff14ef15d28e6ea2e04ce
7
+ data.tar.gz: b64a4e49837cfad1410b382600f2af5eff9ee1fbea7a833689f1b34c021c10a75154f445e6363c0e6cc9f50ce79e2082af292f3c995b084b670301b9b12b3195
data/README.md CHANGED
@@ -10,32 +10,78 @@ __Install it__
10
10
  gem install ideal_postcodes
11
11
  ```
12
12
 
13
+ Alternatively for rails, include this in your gemfile and bundle install
14
+
15
+ ```ruby
16
+ gem 'ideal_postcodes'
17
+ ```
18
+
13
19
  __Get an API Key__
14
20
 
15
- Get a key [Ideal-Postcodes.co.uk](https://ideal-postcodes.co.uk). Try out the service with the test postcode 'ID1 1QD'
21
+ Get a key at [Ideal-Postcodes.co.uk](https://ideal-postcodes.co.uk). Try out the service with the test postcode 'ID1 1QD'
16
22
 
17
- __Use it__
23
+ __Configuration__
18
24
 
19
- Do address lookups with a few lines of Ruby
25
+ In order to perform lookups, you'll need to configure the gem by passing in your api key by doing the following:
20
26
 
21
27
  ```ruby
22
28
  require 'ideal_postcodes'
23
29
 
24
30
  IdealPostcodes.api_key = "your_key_goes_here"
31
+ ```
32
+
33
+ **For Rails**, the best way to do this is create a file in your initializers folder and drop in your key with this line of code:
25
34
 
35
+ ```ruby
36
+ IdealPostcodes.api_key = "<your key goes here>"
37
+ ```
38
+
39
+ __Usage__
40
+
41
+ Simply call #lookup class method on IdealPostcodes::Postcode. This will return a Postcode object containing the complete list of addresses if the postcode exists.
42
+
43
+ ```ruby
26
44
  postcode = IdealPostcodes::Postcode.lookup "ID1 1QD"
27
45
 
28
- # postcode.addresses =>
46
+ if postcode.empty?
47
+ puts "Your postcode doesn't have a match"
48
+ else
49
+ postcode.addresses
50
+ end
51
+
52
+ # postcode.addresses =>
29
53
  #
30
54
  # [
31
- # {
32
- # :postcode=>"ID1 1QD",
33
- # :post_town=>"LONDON",
34
- # :line_1=>"Kingsley Hall",
35
- # :line_2=>"Powis Road",
36
- # :line_3=>""
37
- # },
38
- # ... and so on
55
+ # {
56
+ # :postcode => "ID1 1QD",
57
+ # :post_town => "LONDON",
58
+ # :line_1 => "Kingsley Hall",
59
+ # :line_2 => "Powis Road",
60
+ # :line_3 => "",
61
+ # :organisation_name => "",
62
+ # :building_name => "Kingsley Hall",
63
+ # :udprn => 12345678
64
+ # }, ... and so on
65
+ ```
66
+
67
+ __Exceptions__
68
+
69
+ The wrapper will raise an exception for anything other than a 200 response or an empty 404 response (which means no addresses at postcode).
70
+
71
+ ```ruby
72
+ begin
73
+ IdealPostcodes::Postcode.lookup "ID1 1QD"
74
+ rescue IdealPostcodes::AuthenticationError => e
75
+ # Invalid API Key
76
+ rescue IdealPostcodes::TokenExhaustedError => e
77
+ # Token has run out of lookups
78
+ rescue IdealPostcodes::LimitReachedError => e
79
+ # One of your predefinied limits has been reached
80
+ rescue IdealPostcodes::IdealPostcodesError => e
81
+ # API Error
82
+ rescue => e
83
+ # An unexpected error
84
+ end
39
85
  ```
40
86
 
41
87
  ## Registering
@@ -46,4 +92,13 @@ We charge _2p_ per [external](https://ideal-postcodes.co.uk/termsandconditions#e
46
92
 
47
93
  ## Documentation
48
94
 
49
- More documentation can be found [here](https://ideal-postcodes.co.uk/documentation/ruby-wrapper)
95
+ More documentation can be found [here](https://ideal-postcodes.co.uk/documentation/ruby-wrapper)
96
+
97
+ ## Testing
98
+
99
+ ```
100
+ bundle exec rake test
101
+ ```
102
+
103
+ ## License
104
+ MIT
@@ -14,7 +14,7 @@ module IdealPostcodes
14
14
 
15
15
  def to_s
16
16
  status = @http_code.nil? ? "" : "#{@http_code} error."
17
- ideal_code = @response_code.nil ? "" : "(#{@response_code})"
17
+ ideal_code = @response_code.nil? ? "" : "(#{@response_code})"
18
18
  "#{status} error. (#{ideal_code}) #{message}"
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module IdealPostcodes
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideal_postcodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Blanchard
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-20 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: mocha
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,23 +55,20 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: test-unit
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: shoulda
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,17 +83,15 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: Ideal Postcodes is a simple postcode lookup API for UK addresses. See
@@ -129,27 +116,26 @@ files:
129
116
  - test/test_ideal_postcodes.rb
130
117
  homepage: https://ideal-postcodes.co.uk/documentation
131
118
  licenses: []
119
+ metadata: {}
132
120
  post_install_message:
133
121
  rdoc_options: []
134
122
  require_paths:
135
123
  - lib
136
124
  required_ruby_version: !ruby/object:Gem::Requirement
137
- none: false
138
125
  requirements:
139
- - - ! '>='
126
+ - - '>='
140
127
  - !ruby/object:Gem::Version
141
128
  version: '0'
142
129
  required_rubygems_version: !ruby/object:Gem::Requirement
143
- none: false
144
130
  requirements:
145
- - - ! '>='
131
+ - - '>='
146
132
  - !ruby/object:Gem::Version
147
133
  version: '0'
148
134
  requirements: []
149
135
  rubyforge_project:
150
- rubygems_version: 1.8.24
136
+ rubygems_version: 2.2.2
151
137
  signing_key:
152
- specification_version: 3
138
+ specification_version: 4
153
139
  summary: Wrapper for the Ideal-Postcodes.co.uk API
154
140
  test_files:
155
141
  - test/test_helper.rb