world_bank 0.0.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.
- data/.autotest +1 -0
- data/.gemtest +0 -0
- data/.gitignore +41 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/.yardopts +3 -0
- data/Gemfile +4 -0
- data/LICENSE.md +10 -0
- data/README.md +131 -0
- data/Rakefile +18 -0
- data/country_aliases +257 -0
- data/lib/world_bank/client.rb +88 -0
- data/lib/world_bank/country.rb +35 -0
- data/lib/world_bank/income_level.rb +30 -0
- data/lib/world_bank/indicator.rb +36 -0
- data/lib/world_bank/lending_type.rb +30 -0
- data/lib/world_bank/query.rb +107 -0
- data/lib/world_bank/region.rb +29 -0
- data/lib/world_bank/source.rb +31 -0
- data/lib/world_bank/topic.rb +32 -0
- data/lib/world_bank/version.rb +3 -0
- data/lib/world_bank.rb +19 -0
- data/notes +33 -0
- data/notes_part_2 +108 -0
- data/projects_notes +11 -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/world_bank/client_spec.rb +85 -0
- data/spec/world_bank/country_spec.rb +47 -0
- data/spec/world_bank/income_level_spec.rb +33 -0
- data/spec/world_bank/indicator_spec.rb +38 -0
- data/spec/world_bank/lending_type_spec.rb +32 -0
- data/spec/world_bank/query_spec.rb +114 -0
- data/spec/world_bank/region_spec.rb +29 -0
- data/spec/world_bank/source_spec.rb +38 -0
- data/spec/world_bank/topic_spec.rb +41 -0
- data/spec/world_bank_spec.rb +9 -0
- data/world_bank.gemspec +31 -0
- metadata +261 -0
@@ -0,0 +1 @@
|
|
1
|
+
[{"page":"1","pages":"1","per_page":"50","total":"14"},[{"id":"11","name":"Africa Development Indicators","description":"","url":""},{"id":"1","name":"Doing Business","description":"","url":""},{"id":"12","name":"Education Statistics","description":"","url":""},{"id":"13","name":"Enterprise Surveys","description":"","url":""},{"id":"6","name":"Global Development Finance","description":"","url":""},{"id":"14","name":"Gender Statistics","description":"","url":""},{"id":"15","name":"Global Economic Monitor","description":"","url":""},{"id":"21","name":"Global Economic Monitor (GEM) Commodities","description":"","url":""},{"id":"16","name":"Health Nutrition and Population Statistics","description":"","url":""},{"id":"18","name":"International Development Association - Results Measurement System","description":"","url":""},{"id":"19","name":"Millennium Development Goals","description":"","url":""},{"id":"20","name":"Public Sector Debt","description":"","url":""},{"id":"2","name":"World Development Indicators","description":"","url":""},{"id":"3","name":"Worldwide Governance Indicators","description":"","url":""}]]
|
@@ -0,0 +1,2 @@
|
|
1
|
+
[{"page":1,"pages":1,"per_page":"50","total":1},[{"id":"6","value":"Environment ","sourceNote":"Natural and man-made environmental resources – fresh water, clean air, forests, grasslands, marine resources, and agro-ecosystems – provide sustenance and a foundation for social and economic development. The need to safeguard these resources crosses all borders. Today, the World Bank is one of the key promoters and financiers of environmental upgrading in the developing world. Data here cover forests, biodiversity, emissions, and pollution. Other indicators relevant to the environment are found under data pages for Agriculture & Rural Development, Energy & Mining, Infrastructure, and Urban Development."}]]
|
2
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
[{"page":1,"pages":1,"per_page":"50","total":18},[{"id":"1","value":"Agriculture & Rural Development ","sourceNote":"For the 70 percent of the world's poor who live in rural areas, agriculture is the main source of income and employment. But depletion and degradation of land and water pose serious challenges to producing enough food and other agricultural products to sustain livelihoods here and meet the needs of urban populations. Data presented here include measures of agricultural inputs, outputs, and productivity compiled by the UN's Food and Agriculture Organization."},{"id":"2","value":"Aid Effectiveness ","sourceNote":"Aid effectiveness is the impact that aid has in reducing poverty and inequality, increasing growth, building capacity, and accelerating achievement of the Millennium Development Goals set by the international community. Indicators here cover aid received as well as progress in reducing poverty and improving education, health, and other measures of human welfare."},{"id":"3","value":"Economic Policy and External Debt ","sourceNote":"Economic indicators measure outcomes in the structure and rates of change of output, trade, and aggregate demand, and in macroeconomic performance. The data here consist of national accounts, government finances, money supply, prices, balance of payments, and external debt. Data are gathered from national statistical organizations and central banks by World Bank missions and from the International Monetary Fund's data files."},{"id":"4","value":"Education ","sourceNote":"Education is one of the most powerful instruments for reducing poverty and inequality and lays a foundation for sustained economic growth. The World Bank compiles data on education inputs, participation, efficiency, and outcomes. Data on education are compiled by the United Nations Educational, Scientific, and Cultural Organization (UNESCO) Institute for Statistics from official responses to surveys and from reports provided by education authorities in each country."},{"id":"5","value":"Energy & Mining ","sourceNote":"The world economy needs ever-increasing amounts of energy to sustain economic growth, raise living standards, and reduce poverty. But today's trends in energy use are not sustainable. As the world's population grows and economies become more industrialized, nonrenewable energy sources will become scarcer and more costly. Data here on energy production, use, dependency, and efficiency are compiled by the World Bank from the International Energy Agency and the Carbon Dioxide Information Analysis Center."},{"id":"6","value":"Environment ","sourceNote":"Natural and man-made environmental resources – fresh water, clean air, forests, grasslands, marine resources, and agro-ecosystems – provide sustenance and a foundation for social and economic development. The need to safeguard these resources crosses all borders. Today, the World Bank is one of the key promoters and financiers of environmental upgrading in the developing world. Data here cover forests, biodiversity, emissions, and pollution. Other indicators relevant to the environment are found under data pages for Agriculture & Rural Development, Energy & Mining, Infrastructure, and Urban Development."},{"id":"7","value":"Financial Sector ","sourceNote":"An economy's financial markets are critical to its overall development. Banking systems and stock markets enhance growth, the main factor in poverty reduction. Strong financial systems provide reliable and accessible information that lowers transaction costs, which in turn bolsters resource allocation and economic growth. Indicators here include the size and liquidity of stock markets; the accessibility, stability, and efficiency of financial systems; and international migration and workers\\ remittances, which affect growth and social welfare in both sending and receiving countries."},{"id":"8","value":"Health ","sourceNote":"Improving health is central to the Millennium Development Goals, and the public sector is the main provider of health care in developing countries. To reduce inequities, many countries have emphasized primary health care, including immunization, sanitation, access to safe drinking water, and safe motherhood initiatives. Data here cover health systems, disease prevention, reproductive health, nutrition, and population dynamics. Data are from the United Nations Population Division, World Health Organization, United Nations Children's Fund, the Joint United Nations Programme on HIV\/AIDS, and various other sources."},{"id":"9","value":"Infrastructure ","sourceNote":"Infrastructure helps determine the success of manufacturing and agricultural activities. Investments in water, sanitation, energy, housing, and transport also improve lives and help reduce poverty. And new information and communication technologies promote growth, improve delivery of health and other services, expand the reach of education, and support social and cultural advances. Data here are compiled from such sources as the International Road Federation, Containerisation International, the International Civil Aviation Organization, the International Energy Association, and the International Telecommunications Union."},{"id":"10","value":"Labor & Social Protection ","sourceNote":"The supply of labor available in an economy includes people who are employed, those who are unemployed but seeking work, and first-time job-seekers. Not everyone who works is included: unpaid workers, family workers, and students are often omitted, while some countries do not count members of the armed forces. Data on labor and employment are compiled by the International Labour Organization (ILO) from labor force surveys, censuses, establishment censuses and surveys, and administrative records such as employment exchange registers and unemployment insurance schemes."},{"id":"11","value":"Poverty ","sourceNote":"The World Bank periodically prepares poverty assessments of countries in which it has an active program, in close collaboration with national institutions, other development agencies, and civil society, including poor people's organizations. Assessments report the extent and causes of poverty and propose strategies to reduce it. Countries have varying definitions of poverty, and comparisons can be difficult. National poverty lines tend to have higher purchasing power in rich countries, where standards used are more generous than in poor countries. Poverty measures based on an international poverty line attempt to hold the real value of the poverty line constant across countries, including when making comparisons over time. Data here includes measures of population living below the national poverty line as well as the international poverty line. Also included are income distributions and urban and rural poverty rates."},{"id":"12","value":"Private Sector","sourceNote":"Private markets drive economic growth, tapping initiative and investment to create productive jobs and raise incomes. Trade is also a driver of economic growth as it integrates developing countries into the world economy and generates benefits for their people. Data on the private sector and trade are from the World Bank Group's Private Participation in Infrastructure Project Database, Enterprise Surveys, and Doing Business Indicators, as well as from the International Monetary Fund's Balance of Payments database and International Financial Statistics, the UN Commission on Trade and Development, the World Trade Organization, and various other sources."},{"id":"13","value":"Public Sector ","sourceNote":"Effective governments improve people's standard of living by ensuring access to essential services – health, education, water and sanitation, electricity, transport – and the opportunity to live and work in peace and security. Data here includes World Bank staff assessments of country performance in economic management, structural policies, policies for social inclusion and equity, and public sector management and institutions for the poorest countries. Also included are indicators on revenues and expenses from the International Monetary Fund's Government Finance Statistics, and on tax policies from various sources."},{"id":"14","value":"Science & Technology ","sourceNote":"Technological innovation, often fueled by governments, drives industrial growth and helps raise living standards. Data here aims to shed light on countries technology base: research and development, scientific and technical journal articles, high-technology exports, royalty and license fees, and patents and trademarks. Sources include the UNESCO Institute for Statistics, the U.S. National Science Board, the UN Statistics Division, the International Monetary Fund, and the World Intellectual Property Organization."},{"id":"15","value":"Social Development ","sourceNote":"Data here cover child labor, gender issues, refugees, and asylum seekers. Children in many countries work long hours, often combining studying with work for pay. The data on their paid work are from household surveys conducted by the International Labour Organization (ILO), the United Nations Children's Fund (UNICEF), the World Bank, and national statistical offices. Gender disparities are measured using a compilation of data on key topics such as education, health, labor force participation, and political participation. Data on refugees are from the United Nations High Commissioner for Refugees complemented by statistics on Palestinian refugees under the mandate of the United Nations Relief and Works Agency."},{"id":"16","value":"Urban Development ","sourceNote":"Cities can be tremendously efficient. It is easier to provide water and sanitation to people living closer together, while access to health, education, and other social and cultural services is also much more readily available. However, as cities grow, the cost of meeting basic needs increases, as does the strain on the environment and natural resources. Data on urbanization, traffic and congestion, and air pollution are from the United Nations Population Division, World Health Organization, International Road Federation, World Resources Institute, and other sources."},{"id":"17","value":"Gender Statistics","sourceNote":""},{"id":"18","value":"Millenium development goals","sourceNote":""}]]
|
2
|
+
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'world_bank'
|
6
|
+
require 'rspec'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
|
9
|
+
|
10
|
+
def a_delete(path)
|
11
|
+
a_request(:delete, 'http://api.worldbank.org/' + path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def a_get(path)
|
15
|
+
a_request(:get, 'http://api.worldbank.org/' + path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def a_post(path)
|
19
|
+
a_request(:post, 'http://api.worldbank.org/' + path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def a_put(path)
|
23
|
+
a_request(:put, 'http://api.worldbank.org/' + path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_delete(path)
|
27
|
+
stub_request(:delete, 'http://api.worldbank.org/' + path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_get(path)
|
31
|
+
stub_request(:get, 'http://api.worldbank.org/' + path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def stub_post(path)
|
35
|
+
stub_request(:post, 'http://api.worldbank.org/' + path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_put(path)
|
39
|
+
stub_request(:put, 'http://api.worldbank.org/' + path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def fixture_path
|
43
|
+
File.expand_path('../fixtures', __FILE__)
|
44
|
+
end
|
45
|
+
|
46
|
+
def fixture(file)
|
47
|
+
File.new(fixture_path + '/' + file)
|
48
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = WorldBank::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'topics' do
|
10
|
+
it 'returns all of the topics for the world bank' do
|
11
|
+
stub_get('topics?format=json').
|
12
|
+
to_return(:status => 200, :body => fixture('topics.json'))
|
13
|
+
test = @client.topics
|
14
|
+
a_get('topics?format=json').should have_been_made
|
15
|
+
test[0][:total].should eql 18
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'indicators' do
|
20
|
+
it 'returns all of the indicators for the world bank' do
|
21
|
+
stub_get('indicators?format=json').
|
22
|
+
to_return(:status => 200, :body => fixture('indicators.json'))
|
23
|
+
test = @client.indicators
|
24
|
+
a_get('indicators?format=json').should have_been_made
|
25
|
+
test[0][:pages].should eql 82
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'countries' do
|
30
|
+
it 'returns all of the countries for the world bank' do
|
31
|
+
stub_get('countries?format=json').
|
32
|
+
to_return(:status => 200, :body => fixture('countries.json'))
|
33
|
+
test = @client.countries
|
34
|
+
a_get('countries?format=json').should have_been_made
|
35
|
+
test[0][:pages].should eql 5
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'lending_types' do
|
40
|
+
it 'returns all of the lending types for the world bank' do
|
41
|
+
stub_get('lendingTypes?format=json').
|
42
|
+
to_return(:status => 200, :body => fixture('lending_types.json'))
|
43
|
+
test = @client.lending_types
|
44
|
+
a_get('lendingTypes?format=json').should have_been_made
|
45
|
+
test[0][:total].should eql '4'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'income_levels' do
|
50
|
+
it 'returns all of the income levels for the world bank' do
|
51
|
+
stub_get('incomeLevels?format=json').
|
52
|
+
to_return(:status => 200, :body => fixture('income_levels.json'))
|
53
|
+
test = @client.income_levels
|
54
|
+
a_get('incomeLevels?format=json').should have_been_made
|
55
|
+
test[0][:total].should eql '9'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'sources' do
|
60
|
+
it 'returns all of the sources for the world bank' do
|
61
|
+
stub_get('sources?format=json').
|
62
|
+
to_return(:status => 200, :body => fixture('sources.json'))
|
63
|
+
test = @client.sources
|
64
|
+
a_get('sources?format=json').should have_been_made
|
65
|
+
test[0][:total].should eql '14'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'get' do
|
70
|
+
it 'returns the response from the specified path' do
|
71
|
+
stub_get('sources?format=json').
|
72
|
+
to_return(:status => 200, :body => fixture('sources.json'))
|
73
|
+
test = @client.sources
|
74
|
+
a_get('sources?format=json').should have_been_made
|
75
|
+
test[0][:total].should eql '14'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'connection' do
|
80
|
+
it 'returns an instance of Faraday' do
|
81
|
+
@client.send(:connection).should be_a Faraday::Connection
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Country do
|
4
|
+
context 'client' do
|
5
|
+
it 'returns WorldBank::Client' do
|
6
|
+
client = WorldBank::Country.client
|
7
|
+
client.should be_a WorldBank::Client
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'find' do
|
11
|
+
it 'returns the correct Country' do
|
12
|
+
stub_get('countries/in?format=json').
|
13
|
+
to_return(:status => 200, :body => fixture('countries_india.json'))
|
14
|
+
india = WorldBank::Country.find('in')
|
15
|
+
a_get('countries/in?format=json').should have_been_made
|
16
|
+
india.should be_a WorldBank::Country
|
17
|
+
end
|
18
|
+
context 'returned Country has' do
|
19
|
+
before do
|
20
|
+
stub_get('countries/in?format=json').
|
21
|
+
to_return(:status => 200, :body => fixture('countries_india.json'))
|
22
|
+
@india = WorldBank::Country.find('in')
|
23
|
+
end
|
24
|
+
it 'a three letter code' do
|
25
|
+
@india.iso3_code.should eql 'IND'
|
26
|
+
end
|
27
|
+
it 'a two letter code' do
|
28
|
+
@india.iso2_code.should eql 'IN'
|
29
|
+
end
|
30
|
+
it 'a name' do
|
31
|
+
@india.name.should eql 'India'
|
32
|
+
end
|
33
|
+
it 'an IncomeLevel' do
|
34
|
+
@india.income_level.should be_a WorldBank::IncomeLevel
|
35
|
+
end
|
36
|
+
it 'a LendingType' do
|
37
|
+
@india.lending_type.should be_a WorldBank::LendingType
|
38
|
+
end
|
39
|
+
it 'a capital' do
|
40
|
+
@india.capital.should eql 'New Delhi'
|
41
|
+
end
|
42
|
+
it 'a region' do
|
43
|
+
@india.region.should be_a WorldBank::Region
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::IncomeLevel do
|
4
|
+
context 'client' do
|
5
|
+
# my god these need to be refactored... but can they be? what about including client within????
|
6
|
+
it 'returns a WorldBank::Client' do
|
7
|
+
client = WorldBank::IncomeLevel.client
|
8
|
+
client.should be_a WorldBank::Client
|
9
|
+
end
|
10
|
+
end
|
11
|
+
context 'find' do
|
12
|
+
it 'returns a WorldBank::IncomeLevel' do
|
13
|
+
stub_get('incomeLevels/lmc?format=json').
|
14
|
+
to_return(:status => 200, :body => fixture('income_level_lmc.json'))
|
15
|
+
@working_class = WorldBank::IncomeLevel.find('lmc')
|
16
|
+
a_get('incomeLevels/lmc?format=json').should have_been_made
|
17
|
+
@working_class.should be_a WorldBank::IncomeLevel
|
18
|
+
end
|
19
|
+
context 'returned IncomeLevel has' do
|
20
|
+
before do
|
21
|
+
stub_get('incomeLevels/lmc?format=json').
|
22
|
+
to_return(:status => 200, :body => fixture('income_level_lmc.json'))
|
23
|
+
@working_class = WorldBank::IncomeLevel.find('lmc')
|
24
|
+
end
|
25
|
+
it 'an id' do
|
26
|
+
@working_class.id.should eql 'LMC'
|
27
|
+
end
|
28
|
+
it 'a name' do
|
29
|
+
@working_class.name.should eql 'Lower middle income'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Indicator do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns a WorldBank::Indicator' do
|
6
|
+
stub_get('indicators/AG.AGR.TRAC.NO?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('indicators_tractors.json'))
|
8
|
+
tractors = WorldBank::Indicator.find('AG.AGR.TRAC.NO')
|
9
|
+
a_get('indicators/AG.AGR.TRAC.NO?format=json').should have_been_made
|
10
|
+
tractors.should be_a WorldBank::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 = WorldBank::Indicator.find 'AG.AGR.TRAC.NO'
|
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 WorldBank::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 WorldBank::Topic
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::LendingType do
|
4
|
+
context 'client' do
|
5
|
+
it 'should return a Client' do
|
6
|
+
client = WorldBank::LendingType.client
|
7
|
+
client.should be_a WorldBank::Client
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'find' do
|
11
|
+
it 'returns a LendingType' do
|
12
|
+
stub_get('lendingTypes/idb?format=json').
|
13
|
+
to_return(:status => 200, :body => fixture('lending_type_idb.json'))
|
14
|
+
@blend = WorldBank::LendingType.find('idb')
|
15
|
+
a_get('lendingTypes/idb?format=json').should have_been_made
|
16
|
+
@blend.should be_a WorldBank::LendingType
|
17
|
+
end
|
18
|
+
context 'returned LendingType has' do
|
19
|
+
before do
|
20
|
+
stub_get('lendingTypes/idb?format=json').
|
21
|
+
to_return(:status => 200, :body => fixture('lending_type_idb.json'))
|
22
|
+
@blend = WorldBank::LendingType.find('idb')
|
23
|
+
end
|
24
|
+
it 'an id' do
|
25
|
+
@blend.id.should eql 'IDB'
|
26
|
+
end
|
27
|
+
it 'a name' do
|
28
|
+
@blend.name.should eql 'Blend'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Query do
|
4
|
+
before do
|
5
|
+
@india = {"id" => "IND",
|
6
|
+
"iso2Code" => "IN",
|
7
|
+
"name" => "India",
|
8
|
+
"region" => {
|
9
|
+
"id" => "SAS",
|
10
|
+
"value" => "South Asia"},
|
11
|
+
"adminregion" => {
|
12
|
+
"id" => "SAS",
|
13
|
+
"value" => "South Asia"},
|
14
|
+
"incomeLevel" => {
|
15
|
+
"id" => "LMC",
|
16
|
+
"value" => "Lower middle income"},
|
17
|
+
"lendingType" => {
|
18
|
+
"id" => "IDB",
|
19
|
+
"value" => "Blend"},
|
20
|
+
"capitalCity" => "New Delhi",
|
21
|
+
"longitude" => "77.225",
|
22
|
+
"latitude" => "28.6353"}
|
23
|
+
@country = WorldBank::Country.new(@india)
|
24
|
+
@query = WorldBank::Query::Base.new(@country)
|
25
|
+
@client = @query.instance_variable_get :@client
|
26
|
+
end
|
27
|
+
context 'client' do
|
28
|
+
it 'returns WorldBank::Client' do
|
29
|
+
@client.should be_a WorldBank::Client
|
30
|
+
end
|
31
|
+
end
|
32
|
+
context 'dates' do
|
33
|
+
it 'adds a date string to the params hash' do
|
34
|
+
@query.dates('2000:2010')
|
35
|
+
@client.query[:params].should eql({:format => 'json', :date => '2000:2010'})
|
36
|
+
end
|
37
|
+
it 'adds a range of date objects to the params hash' do
|
38
|
+
@birthday = Date.new(1982, 3, 7)
|
39
|
+
@q3 = Date.new(2010, 9, 30)
|
40
|
+
@query.dates(@birthday...@q3)
|
41
|
+
@client.query[:params].should eql({:format => 'json', :date => '1982M03:2010M09'})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context 'format' do
|
45
|
+
it 'adds a format string to the params' do
|
46
|
+
@query.format('xml')
|
47
|
+
@client.query[:params].should eql({:format => 'xml'})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
context 'id' do
|
51
|
+
it 'adds an id string to the params' do
|
52
|
+
@query.id(9)
|
53
|
+
@client.query[:params].should eql({:format => 'json', :id => 9})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
context 'most_recent_values' do
|
57
|
+
it 'adds a MRV to the params' do
|
58
|
+
@query.most_recent_values(10)
|
59
|
+
@client.query[:params].should eql({:format => 'json', :MRV => 10})
|
60
|
+
end
|
61
|
+
end
|
62
|
+
context 'per page' do
|
63
|
+
it 'adds a perPage string to the params' do
|
64
|
+
@query.per_page(50)
|
65
|
+
@client.query[:params].should eql({:format => 'json', :perPage => 50})
|
66
|
+
end
|
67
|
+
end
|
68
|
+
context 'page' do
|
69
|
+
it 'adds a page param' do
|
70
|
+
@query.page(3)
|
71
|
+
@client.query[:params].should eql({:format => 'json', :page => 3})
|
72
|
+
end
|
73
|
+
end
|
74
|
+
context 'language' do
|
75
|
+
it 'adds one of (en, es, fr, ar) to the dir array' do
|
76
|
+
@query.language('es')
|
77
|
+
@client.query[:dirs].should eql(['countries', 'es'])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context 'lending types' do
|
81
|
+
it 'accepts a single LendingType as param' do
|
82
|
+
@query = WorldBank::Query::Base::Countries.new(@country)
|
83
|
+
@client = @query.instance_variable_get :@client
|
84
|
+
@lending_type = WorldBank::LendingType.new({"id" => "IDB","value" => "Blend"})
|
85
|
+
@query.lending_types(@lending_type)
|
86
|
+
@client.query[:params].should eql({:format => 'json', :lendingTypes => 'IDB'})
|
87
|
+
end
|
88
|
+
it 'converts an array of LendingTypes to a param' do
|
89
|
+
@query = WorldBank::Query::Base::Countries.new(@country)
|
90
|
+
@client = @query.instance_variable_get :@client
|
91
|
+
@lending_type = WorldBank::LendingType.new({"id" => "IDB","value" => "Blend"})
|
92
|
+
@other_type = @lending_type.dup
|
93
|
+
@query.lending_types([@other_type, @lending_type])
|
94
|
+
@client.query[:params].should eql({:format => 'json', :lendingTypes => 'IDB;IDB'})
|
95
|
+
end
|
96
|
+
end
|
97
|
+
context 'income levels' do
|
98
|
+
it 'accepts a single IncomeLevels as param' do
|
99
|
+
@query = WorldBank::Query::Base::Countries.new(@country)
|
100
|
+
@client = @query.instance_variable_get :@client
|
101
|
+
@income_level = WorldBank::IncomeLevel.new({"id" => "LMC","value" => "Lower middle income"})
|
102
|
+
@query.income_levels(@income_level)
|
103
|
+
@client.query[:params].should eql({:format => 'json', :incomeLevels => 'LMC'})
|
104
|
+
end
|
105
|
+
it 'converts an array of IncomeLevels to a param' do
|
106
|
+
@query = WorldBank::Query::Base::Countries.new(@country)
|
107
|
+
@client = @query.instance_variable_get :@client
|
108
|
+
@income_level = WorldBank::IncomeLevel.new({"id" => "LMC","value" => "Lower middle income"})
|
109
|
+
@other_type = @income_level.dup
|
110
|
+
@query.income_levels([@other_type, @income_level])
|
111
|
+
@client.query[:params].should eql({:format => 'json', :incomeLevels => 'LMC;LMC'})
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Region do
|
4
|
+
context 'find' do
|
5
|
+
it 'returns WorldBank::Region' do
|
6
|
+
stub_get('regions/wld?format=json').
|
7
|
+
to_return(:status => 200, :body => fixture('regions_world.json'))
|
8
|
+
@so_helpful = WorldBank::Region.find('wld')
|
9
|
+
a_get('regions/wld?format=json').should have_been_made
|
10
|
+
@so_helpful.should be_a WorldBank::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 = WorldBank::Region.find('wld')
|
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,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Source do
|
4
|
+
context 'client' do
|
5
|
+
it 'return an new WorldBank::Client' do
|
6
|
+
client = WorldBank::Source.client
|
7
|
+
client.should be_a WorldBank::Client
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'find' do
|
11
|
+
it 'returns a new Source object' do
|
12
|
+
stub_get('sources/21?format=json').
|
13
|
+
to_return(:status => 200, :body => fixture('source_21.json'))
|
14
|
+
@gem = WorldBank::Source.find 21
|
15
|
+
a_get('sources/21?format=json').should have_been_made
|
16
|
+
@gem.should be_a WorldBank::Source
|
17
|
+
end
|
18
|
+
context 'returned Source has' do
|
19
|
+
before do
|
20
|
+
stub_get('sources/21?format=json').
|
21
|
+
to_return(:status => 200, :body => fixture('source_21.json'))
|
22
|
+
@gem = WorldBank::Source.find 21
|
23
|
+
end
|
24
|
+
it 'an id' do
|
25
|
+
@gem.id.should eql '21'
|
26
|
+
end
|
27
|
+
it 'a name' do
|
28
|
+
@gem.name.should eql 'Global Economic Monitor (GEM) Commodities'
|
29
|
+
end
|
30
|
+
it 'a description' do
|
31
|
+
@gem.description.should eql ''
|
32
|
+
end
|
33
|
+
it 'a url' do
|
34
|
+
@gem.url.should eql ''
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe WorldBank::Topic do
|
4
|
+
|
5
|
+
context 'client' do
|
6
|
+
it 'returns a new WorldBank::Client' do
|
7
|
+
client = WorldBank::Topic.client
|
8
|
+
client.should be_a WorldBank::Client
|
9
|
+
end
|
10
|
+
end
|
11
|
+
context 'find' do
|
12
|
+
|
13
|
+
it 'returns an instance of Topic' do
|
14
|
+
stub_get('topics/6?format=json').
|
15
|
+
to_return(:status => 200, :body => fixture('topic_6.json'))
|
16
|
+
@environment = WorldBank::Topic.find(6)
|
17
|
+
a_get('topics/6?format=json').should have_been_made
|
18
|
+
@environment.should be_a WorldBank::Topic
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'returned topic has' do
|
22
|
+
|
23
|
+
before do
|
24
|
+
stub_get('topics/6?format=json').
|
25
|
+
to_return(:status => 200, :body => fixture('topic_6.json'))
|
26
|
+
@environment = WorldBank::Topic.find(6)
|
27
|
+
end
|
28
|
+
it 'name' do
|
29
|
+
@environment.name.should eql 'Environment '
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'id' do
|
33
|
+
@environment.id.should eql '6'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'note' do
|
37
|
+
@environment.note[0..20].should eql "Natural and man-made "
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/world_bank.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/world_bank/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'world_bank'
|
6
|
+
gem.version = WorldBank::VERSION
|
7
|
+
gem.author = 'Code for America - DevTools'
|
8
|
+
gem.email = 'info@codeforamerica.org'
|
9
|
+
gem.homepage = 'https://github.com/codeforamerica/world_bank_ruby'
|
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}
|
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.6'
|
25
|
+
|
26
|
+
gem.add_runtime_dependency 'faraday', '~> 0.6.1'
|
27
|
+
gem.add_runtime_dependency 'faraday_middleware', '~> 0.6.3'
|
28
|
+
gem.add_runtime_dependency 'hashie', '~> 1.0.0'
|
29
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.0.2'
|
30
|
+
gem.add_runtime_dependency 'rash', '~> 0.3.0'
|
31
|
+
end
|