world_bank_fetcher 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,14 +13,8 @@ module WorldBankFetcher
13
13
 
14
14
  def fetch
15
15
  data = fetch_all_data query
16
- if data
17
- if @job_type == :indicator
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
@@ -1,3 +1,3 @@
1
1
  module WorldBankFetcher
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  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
- it "should receive same checksum if scheduler returns identical results" do
47
- WorldBank::DataQuery.any_instance.stub(:total).and_return(39)
48
- QueryScheduler.any_instance.stub(:execute!).and_return(:something)
49
-
50
- job = Job.new(:indicator => indicator_string)
51
- first = job.fetch[:checksum]
52
- second = job.fetch[:checksum]
53
- first.should eq(second)
54
- end
55
-
56
- it "should return unique checksums given unique results" do
57
-
58
- DataParser.should_receive(:parse).twice.and_return(:something, :something_else)
59
- WorldBank::DataQuery.any_instance.stub(:total).and_return(39)
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.6
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: -874768310666581088
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: -874768310666581088
97
+ hash: -3624973243962127060
98
98
  requirements: []
99
99
  rubyforge_project:
100
100
  rubygems_version: 1.8.24