world_bank_fetcher 0.1.0 → 0.1.1

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.
@@ -11,13 +11,17 @@ module WorldBankFetcher
11
11
  end
12
12
  end
13
13
 
14
+ def self.data_from_official_country?(datum)
15
+ non_country_codes.include? datum.raw.country.id
16
+ end
17
+
14
18
  private
15
19
  def self.filter_countries(data_collection)
16
20
  data_collection.reject {|country| non_country_codes.include? country.iso2_code }
17
21
  end
18
22
 
19
23
  def self.filter_data_from_non_countries(data_collection)
20
- data_collection.reject { |datum| non_country_codes.include? datum.raw.country.id }
24
+ data_collection.reject { |datum| data_from_official_country? datum }
21
25
  end
22
26
 
23
27
  def self.non_country_codes
@@ -4,7 +4,7 @@ module WorldBankFetcher
4
4
  class IndicatorDataParser
5
5
 
6
6
  def self.filter(data_collection)
7
- data = data_collection.keep_if {|datum| datum.value != nil }
7
+ data = data_collection.keep_if {|datum| (datum.value != nil) and CountryParser.data_from_official_country?(datum) }
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module WorldBankFetcher
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -10,11 +10,24 @@ module WorldBankFetcher
10
10
 
11
11
 
12
12
  it "should filter data with nil values" do
13
- # CountryParser.filter([france, arab_world, canada]).should eq([france, canada])
13
+ CountryParser.stub(:data_from_official_country?).and_return(true)
14
14
  good_data = [good_data_1, good_data_2]
15
15
  IndicatorDataParser.filter([good_data_1, bad_data_2, bad_data_1, good_data_2]).should eq(good_data)
16
16
  end
17
17
 
18
+ it "should confirm that data is from an actual country by passing scores with values to CountryParser" do
19
+ CountryParser.should_receive(:data_from_official_country?).exactly(2).times.and_return(true)
20
+
21
+ IndicatorDataParser.filter([good_data_1, bad_data_2, bad_data_1, good_data_2])
22
+ end
23
+
24
+ it "should filter data rejected by CountryParser" do
25
+ CountryParser.stub(:data_from_official_country?).with(good_data_1).and_return(false)
26
+ CountryParser.stub(:data_from_official_country?).with(good_data_2).and_return(true)
27
+
28
+ IndicatorDataParser.filter([good_data_1, good_data_2]).should eq([good_data_2])
29
+ end
30
+
18
31
  private
19
32
 
20
33
  def attrs_with(attr)
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.1.0
4
+ version: 0.1.1
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: 438441967872334920
88
+ hash: 4160122140544830138
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: 438441967872334920
97
+ hash: 4160122140544830138
98
98
  requirements: []
99
99
  rubyforge_project:
100
100
  rubygems_version: 1.8.24