worldbank_as_dataframe 0.1.0
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.
- checksums.yaml +7 -0
- data/.autotest +1 -0
- data/.gemtest +0 -0
- data/.gitignore +42 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/.yardopts +3 -0
- data/Changelog +6 -0
- data/Gemfile +4 -0
- data/LICENSE.md +10 -0
- data/README.md +164 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/worldbank_as_dataframe/client.rb +69 -0
- data/lib/worldbank_as_dataframe/country.rb +326 -0
- data/lib/worldbank_as_dataframe/data.rb +47 -0
- data/lib/worldbank_as_dataframe/data_query.rb +82 -0
- data/lib/worldbank_as_dataframe/income_level.rb +23 -0
- data/lib/worldbank_as_dataframe/indicator.rb +42 -0
- data/lib/worldbank_as_dataframe/lending_type.rb +23 -0
- data/lib/worldbank_as_dataframe/param_query.rb +51 -0
- data/lib/worldbank_as_dataframe/queriable.rb +39 -0
- data/lib/worldbank_as_dataframe/query.rb +213 -0
- data/lib/worldbank_as_dataframe/region.rb +22 -0
- data/lib/worldbank_as_dataframe/source.rb +25 -0
- data/lib/worldbank_as_dataframe/topic.rb +25 -0
- data/lib/worldbank_as_dataframe/version.rb +3 -0
- data/lib/worldbank_as_dataframe.rb +21 -0
- data/spec/fixtures/brazil.json +43 -0
- data/spec/fixtures/countries.json +2 -0
- data/spec/fixtures/countries_india.json +2 -0
- data/spec/fixtures/income_level_lmc.json +1 -0
- data/spec/fixtures/income_levels.json +2 -0
- data/spec/fixtures/indicators.json +2 -0
- data/spec/fixtures/indicators_tractors.json +1 -0
- data/spec/fixtures/lending_type_idb.json +1 -0
- data/spec/fixtures/lending_types.json +1 -0
- data/spec/fixtures/regions.json +2 -0
- data/spec/fixtures/regions_world.json +1 -0
- data/spec/fixtures/source_21.json +2 -0
- data/spec/fixtures/sources.json +1 -0
- data/spec/fixtures/topic_6.json +2 -0
- data/spec/fixtures/topics.json +2 -0
- data/spec/helper.rb +48 -0
- data/spec/worldbank_as_dataframe/client_spec.rb +23 -0
- data/spec/worldbank_as_dataframe/country_spec.rb +35 -0
- data/spec/worldbank_as_dataframe/data_query_spec.rb +38 -0
- data/spec/worldbank_as_dataframe/data_spec.rb +26 -0
- data/spec/worldbank_as_dataframe/income_level_spec.rb +26 -0
- data/spec/worldbank_as_dataframe/indicator_spec.rb +38 -0
- data/spec/worldbank_as_dataframe/lending_type_spec.rb +26 -0
- data/spec/worldbank_as_dataframe/param_query_spec.rb +45 -0
- data/spec/worldbank_as_dataframe/query_spec.rb +83 -0
- data/spec/worldbank_as_dataframe/region_spec.rb +29 -0
- data/spec/worldbank_as_dataframe/source_spec.rb +32 -0
- data/spec/worldbank_as_dataframe/topic_spec.rb +35 -0
- data/spec/worldbank_as_dataframe_spec.rb +9 -0
- data/worldbank_as_dataframe.gemspec +30 -0
- metadata +274 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Client do
|
4
|
+
|
5
|
+
context 'get' do
|
6
|
+
let(:query_string) { 'sources/all?format=json' }
|
7
|
+
let(:client) { WorldbankAsDataframe::Client.new( { :dirs => ['sources', 'all'], :params => {:format => 'json'}}, false) }
|
8
|
+
|
9
|
+
it 'returns the response from the specified path' do
|
10
|
+
stub_get(query_string).to_return(:status => 200, :body => fixture('sources.json'))
|
11
|
+
|
12
|
+
client.get(query_string)
|
13
|
+
|
14
|
+
a_get(query_string).should have_been_made
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns null if status is not in 200s" do
|
18
|
+
stub_get(query_string).to_return(:status => 500)
|
19
|
+
client.get(query_string).should be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Country do
|
4
|
+
context 'returned Country has' do
|
5
|
+
before do
|
6
|
+
stub_get('countries/in?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('countries_india.json'))
|
8
|
+
@india = WorldbankAsDataframe::Country.find('in').fetch
|
9
|
+
end
|
10
|
+
it 'a three letter code' do
|
11
|
+
@india.iso3_code.should eql 'IND'
|
12
|
+
end
|
13
|
+
it 'a two letter code' do
|
14
|
+
@india.iso2_code.should eql 'IN'
|
15
|
+
end
|
16
|
+
it 'a name' do
|
17
|
+
@india.name.should eql 'India'
|
18
|
+
end
|
19
|
+
it 'an IncomeLevel' do
|
20
|
+
@india.income_level.should be_a WorldbankAsDataframe::IncomeLevel
|
21
|
+
end
|
22
|
+
it 'a LendingType' do
|
23
|
+
@india.lending_type.should be_a WorldbankAsDataframe::LendingType
|
24
|
+
end
|
25
|
+
it 'a capital' do
|
26
|
+
@india.capital.should eql 'New Delhi'
|
27
|
+
end
|
28
|
+
it 'a region' do
|
29
|
+
@india.region.should be_a WorldbankAsDataframe::Region
|
30
|
+
end
|
31
|
+
it 'should initialize without all required attributes' do
|
32
|
+
WorldbankAsDataframe::Country.new({'name' => 'France'}).should be_an_instance_of(WorldbankAsDataframe::Country)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::DataQuery do
|
4
|
+
context 'lending types' do
|
5
|
+
it 'accepts a single LendingType as param' do
|
6
|
+
stub_get('lendingTypes/IDB/indicators/all?format=json')
|
7
|
+
lending_type = WorldbankAsDataframe::LendingType.new({"id" => "IDB","value" => "Blend"})
|
8
|
+
WorldbankAsDataframe::Data.raw.lending_type(lending_type).fetch
|
9
|
+
a_get('lendingTypes/IDB/indicators/all?format=json').should have_been_made
|
10
|
+
end
|
11
|
+
end
|
12
|
+
context 'income levels' do
|
13
|
+
it 'accepts a single IncomeLevels as param' do
|
14
|
+
stub_get('incomeLevels/LMC/indicators/all?format=json')
|
15
|
+
WorldbankAsDataframe::Data.raw.income_level('LMC').fetch
|
16
|
+
a_get('incomeLevels/LMC/indicators/all?format=json').should have_been_made
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'sources' do
|
20
|
+
it 'accepts a single Source as param' do
|
21
|
+
stub_get('sources/1/indicators/all?format=json')
|
22
|
+
WorldbankAsDataframe::Data.raw.source(1).fetch
|
23
|
+
a_get('sources/1/indicators/all?format=json').should have_been_made
|
24
|
+
end
|
25
|
+
end
|
26
|
+
context 'country' do
|
27
|
+
it 'adds countries to the params if given ISO-2 code' do
|
28
|
+
stub_get('countries/br/indicators/AB.LND.ARBL.ZS?format=json')
|
29
|
+
WorldbankAsDataframe::Data.find('AB.LND.ARBL.ZS').country('br').raw.fetch
|
30
|
+
a_get('countries/br/indicators/AB.LND.ARBL.ZS?format=json').should have_been_made
|
31
|
+
end
|
32
|
+
it 'adds countries to the params if given human name' do
|
33
|
+
stub_get('countries/BR/indicators/AB.LND.ARBL.ZS?format=json')
|
34
|
+
WorldbankAsDataframe::Data.find('AB.LND.ARBL.ZS').country('brazil').raw.fetch
|
35
|
+
a_get('countries/BR/indicators/AB.LND.ARBL.ZS?format=json').should have_been_made
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Data do
|
4
|
+
context "cycle" do
|
5
|
+
it "cycles through 2 pages of results for data query on all countries, specific indicator" do
|
6
|
+
2.times do |i|
|
7
|
+
request_string = "countries/all/indicators/SP.POP.TOTL?page=#{i+1}&format=json"
|
8
|
+
stub_get(request_string).
|
9
|
+
to_return(:status => 200, :body => ["#{i+1}"])
|
10
|
+
end
|
11
|
+
query = WorldbankAsDataframe::Data.country('all').indicator('SP.POP.TOTL').raw.page(1)
|
12
|
+
query.instance_variable_set(:@pages, 2)
|
13
|
+
query.cycle.should == ["2"]
|
14
|
+
end
|
15
|
+
it "cycles through all 5 pages of results for data query on all countries, specific indicator" do
|
16
|
+
5.times do |i|
|
17
|
+
request_string = "countries/all/indicators/SP.POP.TOTL?page=#{i+1}&format=json"
|
18
|
+
stub_get(request_string).
|
19
|
+
to_return(:status => 200, :body => ["#{i+1}"])
|
20
|
+
end
|
21
|
+
query = WorldbankAsDataframe::Data.country('all').indicator('SP.POP.TOTL').raw.page(1)
|
22
|
+
query.instance_variable_set(:@pages, 5)
|
23
|
+
query.cycle.should == ["2", "3", "4", "5"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::IncomeLevel do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns a WorldbankAsDataframe::IncomeLevel' do
|
6
|
+
stub_get('incomeLevels/lmc?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('income_level_lmc.json'))
|
8
|
+
@working_class = WorldbankAsDataframe::IncomeLevel.find('lmc').fetch
|
9
|
+
a_get('incomeLevels/lmc?format=json').should have_been_made
|
10
|
+
@working_class.should be_a WorldbankAsDataframe::IncomeLevel
|
11
|
+
end
|
12
|
+
context 'returned IncomeLevel has' do
|
13
|
+
before do
|
14
|
+
stub_get('incomeLevels/lmc?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('income_level_lmc.json'))
|
16
|
+
@working_class = WorldbankAsDataframe::IncomeLevel.find('lmc').fetch
|
17
|
+
end
|
18
|
+
it 'an id' do
|
19
|
+
@working_class.id.should eql 'LMC'
|
20
|
+
end
|
21
|
+
it 'a name' do
|
22
|
+
@working_class.name.should eql 'Lower middle income'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Indicator do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns a WorldbankAsDataframe::Indicator' do
|
6
|
+
stub_get('indicators/AG.AGR.TRAC.NO?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('indicators_tractors.json'))
|
8
|
+
tractors = WorldbankAsDataframe::Indicator.find('AG.AGR.TRAC.NO').fetch
|
9
|
+
a_get('indicators/AG.AGR.TRAC.NO?format=json').should have_been_made
|
10
|
+
tractors.should be_a WorldbankAsDataframe::Indicator
|
11
|
+
end
|
12
|
+
context 'returned Indicator has' do
|
13
|
+
before do
|
14
|
+
stub_get('indicators/AG.AGR.TRAC.NO?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('indicators_tractors.json'))
|
16
|
+
@tractors = WorldbankAsDataframe::Indicator.find('AG.AGR.TRAC.NO').fetch
|
17
|
+
end
|
18
|
+
it 'an id' do
|
19
|
+
@tractors.id.should eql 'AG.AGR.TRAC.NO'
|
20
|
+
end
|
21
|
+
it 'a name' do
|
22
|
+
@tractors.name.should eql 'Agricultural machinery, tractors'
|
23
|
+
end
|
24
|
+
it 'a source' do
|
25
|
+
@tractors.source.should be_a WorldbankAsDataframe::Source
|
26
|
+
end
|
27
|
+
it 'a note' do
|
28
|
+
@tractors.note[0..19].should eql 'Agricultural machine'
|
29
|
+
end
|
30
|
+
it 'an organization' do
|
31
|
+
@tractors.organization.should eql 'Food and Agriculture Organization, electronic files and web site.'
|
32
|
+
end
|
33
|
+
it 'many topics' do
|
34
|
+
@tractors.topics[0].should be_a WorldbankAsDataframe::Topic
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::LendingType do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns a LendingType' do
|
6
|
+
stub_get('lendingTypes/idb?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('lending_type_idb.json'))
|
8
|
+
@blend = WorldbankAsDataframe::LendingType.find('idb').fetch
|
9
|
+
a_get('lendingTypes/idb?format=json').should have_been_made
|
10
|
+
@blend.should be_a WorldbankAsDataframe::LendingType
|
11
|
+
end
|
12
|
+
context 'returned LendingType has' do
|
13
|
+
before do
|
14
|
+
stub_get('lendingTypes/idb?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('lending_type_idb.json'))
|
16
|
+
@blend = WorldbankAsDataframe::LendingType.find('idb').fetch
|
17
|
+
end
|
18
|
+
it 'an id' do
|
19
|
+
@blend.id.should eql 'IDB'
|
20
|
+
end
|
21
|
+
it 'a name' do
|
22
|
+
@blend.name.should eql 'Blend'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::ParamQuery do
|
4
|
+
context 'lending types' do
|
5
|
+
it 'accepts a single LendingType as param' do
|
6
|
+
stub_get('countries/all?format=json&lendingTypes=IDB')
|
7
|
+
lending_type = WorldbankAsDataframe::LendingType.new({"id" => "IDB","value" => "Blend"})
|
8
|
+
WorldbankAsDataframe::Country.all.raw.lending_type(lending_type).fetch
|
9
|
+
a_get('countries/all?format=json&lendingTypes=IDB').should have_been_made
|
10
|
+
end
|
11
|
+
end
|
12
|
+
context 'income levels' do
|
13
|
+
it 'accepts a single IncomeLevels as param' do
|
14
|
+
stub_get('countries/all?format=json&incomeLevels=LMC')
|
15
|
+
WorldbankAsDataframe::Country.all.raw.income_level('LMC').fetch
|
16
|
+
a_get('countries/all?format=json&incomeLevels=LMC').should have_been_made
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'sources' do
|
20
|
+
it 'accepts a single Source as param' do
|
21
|
+
stub_get('countries/all?format=json&sources=1')
|
22
|
+
WorldbankAsDataframe::Country.all.raw.source(1).fetch
|
23
|
+
a_get('countries/all?format=json&sources=1').should have_been_made
|
24
|
+
end
|
25
|
+
end
|
26
|
+
context 'featured_indicators' do
|
27
|
+
it 'adds featured param with value of 1' do
|
28
|
+
stub_get('indicators/all?format=json&featured=1')
|
29
|
+
WorldbankAsDataframe::Indicator.featured.raw.fetch
|
30
|
+
a_get('indicators/all?format=json&featured=1').should have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context 'country' do
|
34
|
+
it 'adds countries to the params if given ISO-2 code' do
|
35
|
+
stub_get('indicators/AB.LND.ARBL.ZS?format=json&countries=br')
|
36
|
+
WorldbankAsDataframe::Indicator.find('AB.LND.ARBL.ZS').country('br').raw.fetch
|
37
|
+
a_get('indicators/AB.LND.ARBL.ZS?format=json&countries=br').should have_been_made
|
38
|
+
end
|
39
|
+
it 'adds countries to the params if given human name' do
|
40
|
+
stub_get('indicators/AB.LND.ARBL.ZS?format=json&countries=BR')
|
41
|
+
WorldbankAsDataframe::Indicator.find('AB.LND.ARBL.ZS').country('brazil').raw.fetch
|
42
|
+
a_get('indicators/AB.LND.ARBL.ZS?format=json&countries=BR').should have_been_made
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Query do
|
4
|
+
let(:query_string) { 'sources/all?date=2000:2010&format=json' }
|
5
|
+
let(:query) { WorldbankAsDataframe::Source.all.raw.dates('2000:2010') }
|
6
|
+
|
7
|
+
context 'dates' do
|
8
|
+
it 'should return self' do
|
9
|
+
WorldbankAsDataframe::Source.all.dates('something').should be_a_kind_of WorldbankAsDataframe::Query
|
10
|
+
end
|
11
|
+
it 'adds a date string to the params hash' do
|
12
|
+
stub_get(query_string)
|
13
|
+
query.fetch
|
14
|
+
a_get(query_string).should have_been_made
|
15
|
+
end
|
16
|
+
it 'adds a range of date objects to the params hash' do
|
17
|
+
stub_get('sources/all?date=1982M03:2010M09&format=json')
|
18
|
+
birthday = Date.new(1982, 3, 7)
|
19
|
+
q3 = Date.new(2010, 9, 30)
|
20
|
+
WorldbankAsDataframe::Source.all.raw.dates(birthday...q3).fetch
|
21
|
+
a_get('sources/all?date=1982M03:2010M09&format=json').should have_been_made
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context 'format' do
|
25
|
+
it 'adds a format string to the params' do
|
26
|
+
stub_get('sources/all?format=xml')
|
27
|
+
WorldbankAsDataframe::Source.all.raw.format(:xml).fetch
|
28
|
+
a_get('sources/all?format=xml').should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'most_recent_values' do
|
32
|
+
it 'adds a MRV to the params' do
|
33
|
+
stub_get('sources/all?MRV=5&format=json')
|
34
|
+
WorldbankAsDataframe::Source.all.raw.most_recent_values(5).fetch
|
35
|
+
a_get('sources/all?MRV=5&format=json').should have_been_made end
|
36
|
+
end
|
37
|
+
context 'per page' do
|
38
|
+
it 'adds a perPage string to the params' do
|
39
|
+
stub_get('sources/all?per_page=50&format=json')
|
40
|
+
WorldbankAsDataframe::Source.all.raw.per_page(50).fetch
|
41
|
+
a_get('sources/all?per_page=50&format=json').should have_been_made
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context 'page' do
|
45
|
+
it 'adds a page param when passed a value' do
|
46
|
+
stub_get('sources/all?page=3&format=json')
|
47
|
+
WorldbankAsDataframe::Source.all.raw.page(3).fetch
|
48
|
+
a_get('sources/all?page=3&format=json').should have_been_made
|
49
|
+
end
|
50
|
+
end
|
51
|
+
context 'next' do
|
52
|
+
it 'increments the page count' do
|
53
|
+
stub_get('sources/all?page=3&format=json')
|
54
|
+
query = WorldbankAsDataframe::Source.all.raw.page(2)
|
55
|
+
query.next.fetch
|
56
|
+
a_get('sources/all?page=3&format=json').should have_been_made
|
57
|
+
end
|
58
|
+
end
|
59
|
+
context 'cycle' do
|
60
|
+
it 'cycles through all of the pages of results' do
|
61
|
+
3.times do |i|
|
62
|
+
stub_get("sources/all?page=#{i+1}&format=json").
|
63
|
+
to_return(:status => 200, :body => ["#{i+1}"])
|
64
|
+
end
|
65
|
+
query = WorldbankAsDataframe::Source.all.raw.page(1)
|
66
|
+
query.instance_variable_set(:@pages, 3)
|
67
|
+
query.cycle.should == ["2", "3"]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
context 'language' do
|
71
|
+
it 'adds language param to the front of the query path' do
|
72
|
+
stub_get('es/sources/all?format=json')
|
73
|
+
WorldbankAsDataframe::Source.all.raw.language(:spanish).fetch
|
74
|
+
a_get('es/sources/all?format=json').should have_been_made
|
75
|
+
end
|
76
|
+
end
|
77
|
+
context 'fetch' do
|
78
|
+
it "should signal communication error by returning nil when client returns nil" do
|
79
|
+
WorldbankAsDataframe::Client.any_instance.stub(:get).and_return(nil)
|
80
|
+
query.fetch.should be_nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Region do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns WorldbankAsDataframe::Region' do
|
6
|
+
stub_get('regions/wld?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('regions_world.json'))
|
8
|
+
@so_helpful = WorldbankAsDataframe::Region.find('wld').fetch
|
9
|
+
a_get('regions/wld?format=json').should have_been_made
|
10
|
+
@so_helpful.should be_a WorldbankAsDataframe::Region
|
11
|
+
end
|
12
|
+
context 'returned Region has' do
|
13
|
+
before do
|
14
|
+
stub_get('regions/wld?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('regions_world.json'))
|
16
|
+
@so_helpful = WorldbankAsDataframe::Region.find('wld').fetch
|
17
|
+
end
|
18
|
+
it 'an id' do
|
19
|
+
@so_helpful.id.should eql ''
|
20
|
+
end
|
21
|
+
it 'a code' do
|
22
|
+
@so_helpful.code.should eql 'WLD'
|
23
|
+
end
|
24
|
+
it 'a name' do
|
25
|
+
@so_helpful.name.should eql 'World'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Source do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns a new Source object' do
|
6
|
+
stub_get('sources/21?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('source_21.json'))
|
8
|
+
@gem = WorldbankAsDataframe::Source.find(21).fetch
|
9
|
+
a_get('sources/21?format=json').should have_been_made
|
10
|
+
@gem.should be_a WorldbankAsDataframe::Source
|
11
|
+
end
|
12
|
+
context 'returned Source has' do
|
13
|
+
before do
|
14
|
+
stub_get('sources/21?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('source_21.json'))
|
16
|
+
@gem = WorldbankAsDataframe::Source.find(21).fetch
|
17
|
+
end
|
18
|
+
it 'an id' do
|
19
|
+
@gem.id.should eql '21'
|
20
|
+
end
|
21
|
+
it 'a name' do
|
22
|
+
@gem.name.should eql 'Global Economic Monitor (GEM) Commodities'
|
23
|
+
end
|
24
|
+
it 'a description' do
|
25
|
+
@gem.description.should eql ''
|
26
|
+
end
|
27
|
+
it 'a url' do
|
28
|
+
@gem.url.should eql ''
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldbankAsDataframe::Topic do
|
4
|
+
|
5
|
+
context 'find' do
|
6
|
+
|
7
|
+
it 'returns an instance of Topic' do
|
8
|
+
stub_get('topics/6?format=json').
|
9
|
+
to_return(:status => 200, :body => fixture('topic_6.json'))
|
10
|
+
@environment = WorldbankAsDataframe::Topic.find(6).fetch
|
11
|
+
a_get('topics/6?format=json').should have_been_made
|
12
|
+
@environment.should be_a WorldbankAsDataframe::Topic
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'returned topic has' do
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub_get('topics/6?format=json').
|
19
|
+
to_return(:status => 200, :body => fixture('topic_6.json'))
|
20
|
+
@environment = WorldbankAsDataframe::Topic.find(6).fetch
|
21
|
+
end
|
22
|
+
it 'name' do
|
23
|
+
@environment.name.should eql 'Environment '
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'id' do
|
27
|
+
@environment.id.should eql '6'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'note' do
|
31
|
+
@environment.note[0..20].should eql "Natural and man-made "
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/worldbank_as_dataframe/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'worldbank_as_dataframe'
|
6
|
+
gem.version = WorldbankAsDataframe::VERSION
|
7
|
+
gem.authors = ['Bill McKinnon']
|
8
|
+
gem.email = ['bill.mckinnon@bmck.org']
|
9
|
+
gem.homepage = 'https://github.com/bmck/worldbank_as_dataframe'
|
10
|
+
gem.summary = %q{A Ruby wrapper around the World Bank's Development Indicators API}
|
11
|
+
gem.description = %q{A Ruby wrapper around the World Bank's Development Indicators API, with credit to Code for America and Justin Stoller}
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
19
|
+
gem.add_development_dependency 'maruku', '~> 0.6'
|
20
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 2.6'
|
22
|
+
gem.add_development_dependency 'simplecov', '~> 0.4'
|
23
|
+
gem.add_development_dependency 'yard', '~> 0.7'
|
24
|
+
gem.add_development_dependency 'webmock', '~> 1.8.9'
|
25
|
+
|
26
|
+
gem.add_runtime_dependency 'httparty'
|
27
|
+
gem.add_runtime_dependency 'polars-df'
|
28
|
+
gem.add_runtime_dependency 'multi_json'
|
29
|
+
# gem.add_runtime_dependency 'rash', '~> 0.3.0'
|
30
|
+
end
|