world_bank_fetcher 0.0.10 → 0.0.11

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.
@@ -4,9 +4,22 @@ module WorldBankFetcher
4
4
  class CountryParser
5
5
 
6
6
  def self.filter(data_collection)
7
+ if (data_collection.first.is_a? WorldBank::Country)
8
+ filter_countries data_collection
9
+ else
10
+ filter_data_from_non_countries data_collection
11
+ end
12
+ end
13
+
14
+ private
15
+ def self.filter_countries(data_collection)
7
16
  data_collection.reject {|country| non_country_codes.include? country.iso2_code }
8
17
  end
9
18
 
19
+ def self.filter_data_from_non_countries(data_collection)
20
+ data_collection.reject { |datum| non_country_codes.include? datum.raw.country.id }
21
+ end
22
+
10
23
  def self.non_country_codes
11
24
  NON_COUNTRIES.map {|country_info| country_info[:iso2_code] }
12
25
  end
@@ -12,9 +12,9 @@ module WorldBankFetcher
12
12
  end
13
13
 
14
14
  def fetch
15
- all_data = fetch_all_data query
15
+ all_data = fetch_everything query
16
16
  if all_data
17
- data = @job_type == :indicator ? all_data : CountryParser.filter(all_data)
17
+ data = CountryParser.filter(all_data)
18
18
  @checksum = checksum data
19
19
  {:results => data, :checksum => @checksum}
20
20
  else
@@ -44,7 +44,7 @@ module WorldBankFetcher
44
44
  @query
45
45
  end
46
46
 
47
- def fetch_all_data(query)
47
+ def fetch_everything(query)
48
48
  scheduler = QueryScheduler.new query
49
49
  query.per_page(MAXIMUM_BUFFER_SIZE)
50
50
  scheduler.execute!
@@ -1,3 +1,3 @@
1
1
  module WorldBankFetcher
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/spec/job_spec.rb CHANGED
@@ -2,6 +2,12 @@ require 'helper'
2
2
 
3
3
  module WorldBankFetcher
4
4
  describe Job do
5
+ before do
6
+ CountryParser.stub!(:filter) do |arg|
7
+ arg
8
+ end
9
+ end
10
+
5
11
  let(:indicator_string) { 'SP.POP.TOTL' }
6
12
 
7
13
  context 'initialize' do
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.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  segments:
85
85
  - 0
86
- hash: -1337123450392843755
86
+ hash: -36905167652878939
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: -1337123450392843755
95
+ hash: -36905167652878939
96
96
  requirements: []
97
97
  rubyforge_project:
98
98
  rubygems_version: 1.8.24