openkvk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/openkvk.rb +2 -2
- data/lib/openkvk/api.rb +1 -7
- data/lib/openkvk/version.rb +1 -1
- data/openkvk.gemspec +2 -2
- data/spec/openkvk_spec.rb +3 -3
- metadata +4 -4
data/lib/openkvk.rb
CHANGED
@@ -7,7 +7,7 @@ module OpenKVK
|
|
7
7
|
class << self
|
8
8
|
def find(options={})
|
9
9
|
if options.is_a?(String)
|
10
|
-
options = {:conditions => ["bedrijfsnaam
|
10
|
+
options = {:conditions => ["bedrijfsnaam ILIKE '%#{options}%'"]}
|
11
11
|
end
|
12
12
|
options = {:limit => 1000, :select => ["*"], :count => :all, :match_condition => :all}.merge(options)
|
13
13
|
|
@@ -19,7 +19,7 @@ module OpenKVK
|
|
19
19
|
|
20
20
|
%w{kvk bedrijfsnaam kvks adres postcode plaats type website}.each do |field|
|
21
21
|
define_method("find_by_#{field}") do |value, options={}|
|
22
|
-
options = {:conditions => ["#{field}
|
22
|
+
options = {:conditions => ["#{field} ILIKE '%#{value}%'"]}.merge(options)
|
23
23
|
find(options)
|
24
24
|
end
|
25
25
|
end
|
data/lib/openkvk/api.rb
CHANGED
@@ -9,14 +9,8 @@ module OpenKVK
|
|
9
9
|
class API
|
10
10
|
class << self
|
11
11
|
def query(query)
|
12
|
-
#puts query
|
13
12
|
result = JSON.parse(get(query)).first["RESULT"]
|
14
|
-
|
15
|
-
records = []
|
16
|
-
result["ROWS"].each do |row|
|
17
|
-
records << Hashie::Mash.new(Hash[*result["HEADER"].zip(row).flatten])
|
18
|
-
end
|
19
|
-
records
|
13
|
+
result["ROWS"].map { |row| Hashie::Mash.new(Hash[*result["HEADER"].zip(row).flatten]) }
|
20
14
|
end
|
21
15
|
|
22
16
|
private
|
data/lib/openkvk/version.rb
CHANGED
data/openkvk.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.add_development_dependency('simplecov', '~> 0.3')
|
11
11
|
s.add_development_dependency('maruku', '~> 0.6')
|
12
12
|
s.add_development_dependency('yard', '~> 0.6')
|
13
|
-
s.
|
14
|
-
s.
|
13
|
+
s.add_dependency('hashie', '~> 1.0.0')
|
14
|
+
s.add_dependency('json', '~> 1.5.1')
|
15
15
|
|
16
16
|
s.name = "openkvk"
|
17
17
|
s.version = OpenKVK::VERSION
|
data/spec/openkvk_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe OpenKVK do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should find multiple companies" do
|
20
|
-
expect_query("SELECT * FROM kvk WHERE bedrijfsnaam
|
20
|
+
expect_query("SELECT * FROM kvk WHERE bedrijfsnaam ILIKE '%Zilverline%' LIMIT 1000", '[{"RESULT":{"TYPES":["bigint","varchar","int","int","varchar","varchar","varchar","varchar","varchar"],"HEADER":["kvk","bedrijfsnaam","kvks","sub","adres","postcode","plaats","type","website"],"ROWS":[["342838240000","Zilverline Beheer B.V.","34283824","0","Finsenstraat 56","1098RJ","Amsterdam","Hoofdvestiging",null],["343774520000","Zilverline B.V.","34377452","0","Molukkenstraat 200 E4","1098TW","Amsterdam","Hoofdvestiging",null]]}}]')
|
21
21
|
|
22
22
|
companies = OpenKVK.find("Zilverline")
|
23
23
|
companies.size.should == 2
|
@@ -63,7 +63,7 @@ describe OpenKVK do
|
|
63
63
|
|
64
64
|
describe ".find_by_bedrijfsnaam" do
|
65
65
|
it "should find a company" do
|
66
|
-
expect_query("SELECT * FROM kvk WHERE bedrijfsnaam
|
66
|
+
expect_query("SELECT * FROM kvk WHERE bedrijfsnaam ILIKE '%Zilverline B.V.%' LIMIT 1", '[{"RESULT":{"TYPES":["bigint","varchar","int","int","varchar","varchar","varchar","varchar","varchar"],"HEADER":["kvk","bedrijfsnaam","kvks","sub","adres","postcode","plaats","type","website"],"ROWS":[["343774520000","Zilverline B.V.","34377452","0","Molukkenstraat 200 E4","1098TW","Amsterdam","Hoofdvestiging",null]]}}]')
|
67
67
|
|
68
68
|
OpenKVK.find_by_bedrijfsnaam("Zilverline B.V.", :count => :first).bedrijfsnaam.should == "Zilverline B.V."
|
69
69
|
end
|
@@ -71,7 +71,7 @@ describe OpenKVK do
|
|
71
71
|
|
72
72
|
describe ".find_by_kvk" do
|
73
73
|
it "should find a company" do
|
74
|
-
expect_query("SELECT * FROM kvk WHERE kvk
|
74
|
+
expect_query("SELECT * FROM kvk WHERE kvk ILIKE '%343774520000%' LIMIT 1", '[{"RESULT":{"TYPES":["bigint","varchar","int","int","varchar","varchar","varchar","varchar","varchar"],"HEADER":["kvk","bedrijfsnaam","kvks","sub","adres","postcode","plaats","type","website"],"ROWS":[["343774520000","Zilverline B.V.","34377452","0","Molukkenstraat 200 E4","1098TW","Amsterdam","Hoofdvestiging",null]]}}]')
|
75
75
|
|
76
76
|
OpenKVK.find_by_kvk("343774520000", :count => :first).bedrijfsnaam.should == "Zilverline B.V."
|
77
77
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: openkvk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel van Hoesel
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-10 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: 1.0.0
|
102
|
-
type: :
|
102
|
+
type: :runtime
|
103
103
|
version_requirements: *id008
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: json
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 1.5.1
|
113
|
-
type: :
|
113
|
+
type: :runtime
|
114
114
|
version_requirements: *id009
|
115
115
|
description: This is a ruby wrapper for the Dutch OpenKVK api
|
116
116
|
email:
|