world_bank_fetcher 0.0.6 → 0.0.7
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/world_bank_fetcher/job.rb +6 -8
- data/lib/world_bank_fetcher/version.rb +1 -1
- data/spec/job_spec.rb +15 -22
- metadata +3 -3
@@ -13,14 +13,8 @@ module WorldBankFetcher
|
|
13
13
|
|
14
14
|
def fetch
|
15
15
|
data = fetch_all_data query
|
16
|
-
if data
|
17
|
-
|
18
|
-
@results = DataParser.parse data
|
19
|
-
else
|
20
|
-
@results = CountryParser.parse data
|
21
|
-
end
|
22
|
-
|
23
|
-
@checksum = Digest::MD5.hexdigest Marshal.dump(@results)
|
16
|
+
if data
|
17
|
+
@checksum = checksum data
|
24
18
|
{:results => @results, :checksum => @checksum}
|
25
19
|
else
|
26
20
|
nil
|
@@ -29,6 +23,10 @@ module WorldBankFetcher
|
|
29
23
|
|
30
24
|
private
|
31
25
|
|
26
|
+
def checksum(data)
|
27
|
+
Digest::MD5.hexdigest Marshal.dump(data)
|
28
|
+
end
|
29
|
+
|
32
30
|
def build_query(options)
|
33
31
|
options[:indicator] ? indicator_query(options[:indicator]) : countries_query
|
34
32
|
end
|
data/spec/job_spec.rb
CHANGED
@@ -42,28 +42,21 @@ module WorldBankFetcher
|
|
42
42
|
job = Job.new(:indicator => indicator_string)
|
43
43
|
job.fetch.should be_an_instance_of(Hash)
|
44
44
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
QueryScheduler.any_instance.stub(:execute!).and_return(:some_stuff)
|
61
|
-
|
62
|
-
job = Job.new(:indicator => indicator_string)
|
63
|
-
second_job = Job.new :indicator => 'different string'
|
64
|
-
first = job.fetch[:checksum]
|
65
|
-
second = second_job.fetch[:checksum]
|
66
|
-
first.should_not eq(second)
|
45
|
+
|
46
|
+
context 'checksum' do
|
47
|
+
it "should return unique checksums given unique results" do
|
48
|
+
job = Job.new(:indicator => indicator_string)
|
49
|
+
d1 = [:blah, :blog, :dj]
|
50
|
+
d2 = [:bjad, :awe, :asdf]
|
51
|
+
job.send(:checksum, d1).should_not eq(job.send(:checksum, d2))
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should receive same checksum if scheduler returns identical results" do
|
55
|
+
job = Job.new(:indicator => indicator_string)
|
56
|
+
d1 = [:blah, :blog, :dj]
|
57
|
+
job.send(:checksum, d1).should eq(job.send(:checksum, d1))
|
58
|
+
end
|
59
|
+
|
67
60
|
end
|
68
61
|
end
|
69
62
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: world_bank_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash: -
|
88
|
+
hash: -3624973243962127060
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
none: false
|
91
91
|
requirements:
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash: -
|
97
|
+
hash: -3624973243962127060
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
100
|
rubygems_version: 1.8.24
|