dcentralized 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -31,15 +31,15 @@ Add file `config/initializers/dcentralized.rb`.
31
31
 
32
32
  Dcentralized.auto_complete("2564AZ")
33
33
  # => {
34
- "nl_sixpp":["2564AZ"],
35
- "street":["Laan van Meerdervoort"],
36
- "city":["'s-Gravenhage"],
37
- "municipality":["'s-Gravenhage"],
38
- "province":["Zuid-Holland"],
39
- "streetnumbers":["1096-1126"],
40
- "lat":["52.06751"],
41
- "lng":["4.24733"],
42
- "areacode":["070"]
34
+ :nl_sixpp => "2564AZ",
35
+ :street => "Laan van Meerdervoort",
36
+ :city => "'s-Gravenhage",
37
+ :municipality => "'s-Gravenhage",
38
+ :province => "Zuid-Holland",
39
+ :streetnumbers => "1096-1126",
40
+ :lat => "52.06751",
41
+ :lng => "4.24733",
42
+ :areacode => "070"
43
43
  }
44
44
 
45
45
  ## Contributing
data/dcentralized.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["nickdenengelsman@codedrops.nl"]
11
11
  gem.description = %q{API wrapper for d-centralize.nl}
12
12
  gem.summary = %q{Retreive data from the Pro6PP zipcode database}
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/nicka/dcentralized"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_runtime_dependency "rest-client", "~> 1.6.7"
21
21
  gem.add_runtime_dependency "xml-simple", "~> 1.1.2"
22
+ gem.add_runtime_dependency "hash_symbolizer", "~> 1.0.1"
22
23
 
23
24
  gem.add_development_dependency "rspec", "~> 2.13.0"
24
25
  gem.add_development_dependency "capybara", "~> 2.1.0"
@@ -1,3 +1,3 @@
1
1
  module Dcentralized
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/dcentralized.rb CHANGED
@@ -1,6 +1,6 @@
1
- require "xmlsimple"
2
- require "json"
3
1
  require "rest-client"
2
+ require "xmlsimple"
3
+ require "hash_symbolizer"
4
4
  require "dcentralized/version"
5
5
 
6
6
  module Dcentralized
@@ -18,7 +18,7 @@ module Dcentralized
18
18
  params.merge!(format: 'xml', pretty: 'True')
19
19
  # Perform request and return output
20
20
  response = RestClient.get "#{@api_url}/autocomplete", {params: params}
21
- XmlSimple.xml_in(response)["results"][0]["result"][0].to_json
21
+ stringify(XmlSimple.xml_in(response)["results"][0]["result"][0].symbolize_keys(true))
22
22
  end
23
23
 
24
24
  def self.format_zipcode(zipcode = nil)
@@ -31,6 +31,14 @@ module Dcentralized
31
31
  end
32
32
  end
33
33
 
34
+ def self.stringify(obj)
35
+ if obj.is_a? Array
36
+ obj.join
37
+ elsif obj.is_a? Hash
38
+ obj.merge( obj ) {|k, val| stringify val }
39
+ end
40
+ end
41
+
34
42
  def self.version_string
35
43
  "Dcentralized version #{Dcentralized::VERSION}"
36
44
  end
@@ -21,17 +21,35 @@ describe Dcentralized do
21
21
 
22
22
  it 'should return high detailed result' do
23
23
  VCR.use_cassette('auto_complete_high') do
24
- xml_response_mock = '{"nl_sixpp":["2564AZ"],"street":["Laan van Meerdervoort"],"city":["\'s-Gravenhage"],"municipality":["\'s-Gravenhage"],"province":["Zuid-Holland"],"streetnumbers":["1096-1126"],"lat":["52.06751"],"lng":["4.24733"],"areacode":["070"]}'
24
+ xml_response_mock = {
25
+ :nl_sixpp => "2564AZ",
26
+ :street => "Laan van Meerdervoort",
27
+ :city => "'s-Gravenhage",
28
+ :municipality => "'s-Gravenhage",
29
+ :province => "Zuid-Holland",
30
+ :streetnumbers => "1096-1126",
31
+ :lat => "52.06751",
32
+ :lng => "4.24733",
33
+ :areacode => "070"
34
+ }
25
35
  Dcentralized.auto_complete("2564AZ").should eq xml_response_mock
26
- Dcentralized.auto_complete("2564AZ").should include('"street":[')
36
+ Dcentralized.auto_complete("2564AZ").should include(:street)
27
37
  end
28
38
  end
29
39
 
30
40
  it 'should return low detailed result' do
31
41
  VCR.use_cassette('auto_complete_low') do
32
- xml_response_mock = '{"nl_fourpp":["2564"],"city":["\'s-Gravenhage"],"municipality":["\'s-Gravenhage"],"province":["Zuid-Holland"],"areacode":["070"],"lat":["52.068"],"lng":["4.25724"]}'
42
+ xml_response_mock = {
43
+ :nl_fourpp => "2564",
44
+ :city => "'s-Gravenhage",
45
+ :municipality => "'s-Gravenhage",
46
+ :province => "Zuid-Holland",
47
+ :areacode => "070",
48
+ :lat => "52.068",
49
+ :lng => "4.25724"
50
+ }
33
51
  Dcentralized.auto_complete("2564").should eq xml_response_mock
34
- Dcentralized.auto_complete("2564").should_not include('"street":[')
52
+ Dcentralized.auto_complete("2564").should_not include(:street)
35
53
  end
36
54
  end
37
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcentralized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.1.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: hash_symbolizer
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.1
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rspec
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +158,7 @@ files:
142
158
  - spec/spec_helper.rb
143
159
  - spec/vcr/auto_complete_high.yml
144
160
  - spec/vcr/auto_complete_low.yml
145
- homepage: ''
161
+ homepage: https://github.com/nicka/dcentralized
146
162
  licenses: []
147
163
  post_install_message:
148
164
  rdoc_options: []