postcodeanywhere 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -25,11 +25,11 @@ module PostcodeAnywhere
25
25
  include HTTParty
26
26
  format :xml
27
27
 
28
- attr_accessor :postcode, :country_name, :fetch_id
28
+ attr_accessor :postcode, :country_code, :fetch_id
29
29
 
30
30
  def initialize(args={})
31
31
  self.postcode = args[:postcode]
32
- self.country_name = args[:country_name]
32
+ self.country_code = args[:country_code]
33
33
  end
34
34
 
35
35
  def lookup
@@ -45,14 +45,14 @@ module PostcodeAnywhere
45
45
  data = PostcodeSearch.get self.fetch_url
46
46
  formatted_data = data["NewDataSet"]["Data"]
47
47
  @address_lookup = AddressLookup.new
48
- if @postcode_search.country.name == 'United Kingdom'
48
+ if @postcode_search.country_code == 'GB'
49
49
  @address_lookup.postcode = formatted_data["postcode"]
50
50
  @address_lookup.address_line_1 = formatted_data["line1"]
51
51
  @address_lookup.address_line_2 = formatted_data["line2"]
52
52
  @address_lookup.address_line_3 = formatted_data["line3"]
53
53
  @address_lookup.post_town = formatted_data["post_town"]
54
54
  @address_lookup.county = formatted_data["county"].blank? ? formatted_data["post_town"] : formatted_data["county"]
55
- elsif @postcode_search.country.name == 'United States'
55
+ elsif @postcode_search.country_code == 'US'
56
56
  @address_lookup.postcode = formatted_data["zip4"].blank? ? @postcode_search.postcode : formatted_data["zip4"]
57
57
  @address_lookup.address_line_1 = formatted_data["line1"]
58
58
  @address_lookup.address_line_2 = formatted_data["line2"]
@@ -73,30 +73,23 @@ module PostcodeAnywhere
73
73
  ADDRESS_FETCH+"&"+self.address_fetch_id+"&"+self.country_code+"&"+self.license_information
74
74
  end
75
75
 
76
- def country
77
- Country.find_by_name(self.country_name)
78
- end
79
76
 
80
77
  def address_fetch_id
81
78
  "id="+self.fetch_id
82
79
  end
83
80
 
84
81
  def lookup_type
85
- if self.country.name == "United Kingdom"
82
+ if self.country_code == "GB"
86
83
  "action=lookup&type=by_postcode"
87
- elsif self.country.name == "United States"
84
+ elsif self.country.name == "US"
88
85
  "action=lookup&type=by_zip"
89
86
  else
90
87
  "action=international&type=fetch_streets"
91
88
  end
92
89
  end
93
90
 
94
- def country_code
95
- "country="+self.country.code
96
- end
97
-
98
91
  def postcode_with_no_spaces
99
- (self.country.name=="United States" ? "zip=" : "postcode=")+self.postcode.gsub(/\s/, '')
92
+ (self.country_code=="US" ? "zip=" : "postcode=")+self.postcode.gsub(/\s/, '')
100
93
  end
101
94
 
102
95
  def license_information
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{postcodeanywhere}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["basedotextend"]
12
+ s.date = %q{2010-08-31}
13
+ s.description = %q{Interface with postcodeanywhere.co.uk}
14
+ s.email = %q{sandeepvshetty@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/postcodeanywhere.rb",
27
+ "postcodeanywhere.gemspec",
28
+ "test/helper.rb",
29
+ "test/test_postcodeanywhere.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/basedotextend/postcodeanywhere}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Interface with postcodeanywhere.co.uk}
36
+ s.test_files = [
37
+ "test/helper.rb",
38
+ "test/test_postcodeanywhere.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<httparty>, [">= 0"])
47
+ else
48
+ s.add_dependency(%q<httparty>, [">= 0"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<httparty>, [">= 0"])
52
+ end
53
+ end
54
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - basedotextend
@@ -47,6 +47,7 @@ files:
47
47
  - Rakefile
48
48
  - VERSION
49
49
  - lib/postcodeanywhere.rb
50
+ - postcodeanywhere.gemspec
50
51
  - test/helper.rb
51
52
  - test/test_postcodeanywhere.rb
52
53
  has_rdoc: true