fred 0.1.0 → 0.2.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.
- data/README.md +8 -4
- data/VERSION +1 -1
- data/fred.gemspec +65 -0
- data/lib/fred.rb +3 -0
- data/lib/fred/client.rb +28 -12
- data/pkg/fred-0.1.0.gem +0 -0
- data/test/fixtures/category.xml +4 -0
- data/test/fixtures/release.xml +4 -0
- data/test/fixtures/releases.xml +52 -0
- data/test/fixtures/series.xml +4 -0
- data/test/fixtures/source.xml +4 -0
- data/test/fixtures/sources.xml +24 -0
- data/test/fred_test.rb +59 -5
- data/test/test_helper.rb +36 -2
- metadata +11 -3
data/README.md
CHANGED
|
@@ -4,7 +4,11 @@ This is a Ruby wrapper for the St. Louis Federal Reserve Economic Data [Fred API
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
As a gem:
|
|
8
|
+
|
|
9
|
+
sudo gem install fred
|
|
10
|
+
|
|
11
|
+
As a plugin (in your Rails directory):
|
|
8
12
|
|
|
9
13
|
script/plugin install git://github.com/phuphighter/fred.git
|
|
10
14
|
|
|
@@ -28,10 +32,10 @@ Sign up for a Fred API key: [http://api.stlouisfed.org/api_key.html](http://api.
|
|
|
28
32
|
#### Examples
|
|
29
33
|
|
|
30
34
|
>> fred.category(nil, :category_id => '125')
|
|
31
|
-
=>
|
|
35
|
+
=> <#Hashie::Mash categories=<#Hashie::Mash category=<#Hashie::Mash id="125" name="Trade Balance" parent_id="13">>>
|
|
32
36
|
|
|
33
|
-
>> fred.series(
|
|
34
|
-
=>
|
|
37
|
+
>> fred.series(nil, :series_id => 'GNPC')
|
|
38
|
+
=> <#Hashie::Mash seriess=<#Hashie::Mash realtime_end="2008-07-29" realtime_start="2008-07-29" series=<#Hashie::Mash frequency="Annual" frequency_short="A" id="GNPCA" last_updated="2008-03-27 11:16:06-05" observation_end="2007-01-01" observation_start="1929-01-01" realtime_end="2008-07-29" realtime_start="2008-07-29" seasonal_adjustment="Not Applicable" seasonal_adjustment_short="NA" title="Real Gross National Product" units="Billions of Chained 2000 Dollars" units_short="Bil. of Chained 2000 $">>>
|
|
35
39
|
|
|
36
40
|
## Copyright
|
|
37
41
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/fred.gemspec
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{fred}
|
|
8
|
+
s.version = "0.2.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Johnny Khai Nguyen"]
|
|
12
|
+
s.date = %q{2010-08-12}
|
|
13
|
+
s.description = %q{Ruby wrapper for the St. Louis Federal Reserve FRED API}
|
|
14
|
+
s.email = %q{johnnyn@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"README.md"
|
|
17
|
+
]
|
|
18
|
+
s.files = [
|
|
19
|
+
"MIT-LICENSE",
|
|
20
|
+
"README.md",
|
|
21
|
+
"Rakefile",
|
|
22
|
+
"VERSION",
|
|
23
|
+
"fred.gemspec",
|
|
24
|
+
"generators/fred/USAGE",
|
|
25
|
+
"generators/fred/fred_generator.rb",
|
|
26
|
+
"init.rb",
|
|
27
|
+
"install.rb",
|
|
28
|
+
"lib/fred.rb",
|
|
29
|
+
"lib/fred/client.rb",
|
|
30
|
+
"pkg/fred-0.1.0.gem",
|
|
31
|
+
"tasks/fred_tasks.rake",
|
|
32
|
+
"test/fixtures/category.xml",
|
|
33
|
+
"test/fixtures/release.xml",
|
|
34
|
+
"test/fixtures/releases.xml",
|
|
35
|
+
"test/fixtures/series.xml",
|
|
36
|
+
"test/fixtures/source.xml",
|
|
37
|
+
"test/fixtures/sources.xml",
|
|
38
|
+
"test/fred_test.rb",
|
|
39
|
+
"test/test_helper.rb",
|
|
40
|
+
"uninstall.rb"
|
|
41
|
+
]
|
|
42
|
+
s.homepage = %q{http://github.com/phuphighter/fred}
|
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
44
|
+
s.require_paths = ["lib"]
|
|
45
|
+
s.rubygems_version = %q{1.3.6}
|
|
46
|
+
s.summary = %q{Ruby wrapper for the St. Louis Federal Reserve FRED API}
|
|
47
|
+
s.test_files = [
|
|
48
|
+
"test/fred_test.rb",
|
|
49
|
+
"test/test_helper.rb"
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
if s.respond_to? :specification_version then
|
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
54
|
+
s.specification_version = 3
|
|
55
|
+
|
|
56
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
57
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
|
|
58
|
+
else
|
|
59
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
|
60
|
+
end
|
|
61
|
+
else
|
|
62
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
data/lib/fred.rb
CHANGED
data/lib/fred/client.rb
CHANGED
|
@@ -3,6 +3,7 @@ module Fred
|
|
|
3
3
|
class Client
|
|
4
4
|
include HTTParty
|
|
5
5
|
base_uri "http://api.stlouisfed.org/fred"
|
|
6
|
+
format :xml
|
|
6
7
|
|
|
7
8
|
attr_reader :api_key
|
|
8
9
|
|
|
@@ -12,49 +13,49 @@ module Fred
|
|
|
12
13
|
|
|
13
14
|
def category(secondary, options={})
|
|
14
15
|
if secondary.nil?
|
|
15
|
-
|
|
16
|
+
mashup(self.class.get("/category", :query => options.merge(self.default_options)))
|
|
16
17
|
else
|
|
17
|
-
|
|
18
|
+
mashup(self.class.get("/category/#{secondary}", :query => options.merge(self.default_options)))
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def releases(secondary, options={})
|
|
22
23
|
if secondary.nil?
|
|
23
|
-
|
|
24
|
+
mashup(self.class.get("/releases", :query => options.merge(self.default_options)))
|
|
24
25
|
else
|
|
25
|
-
|
|
26
|
+
mashup(self.class.get("/releases/#{secondary}", :query => options.merge(self.default_options)))
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def release(secondary, options={})
|
|
30
31
|
if secondary.nil?
|
|
31
|
-
|
|
32
|
+
mashup(self.class.get("/release", :query => options.merge(self.default_options)))
|
|
32
33
|
else
|
|
33
|
-
|
|
34
|
+
mashup(self.class.get("/release/#{secondary}", :query => options.merge(self.default_options)))
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def series(secondary, options={})
|
|
38
39
|
if secondary.nil?
|
|
39
|
-
|
|
40
|
+
mashup(self.class.get("/series", :query => options.merge(self.default_options)))
|
|
40
41
|
else
|
|
41
|
-
|
|
42
|
+
mashup(self.class.get("/series/#{secondary}", :query => options.merge(self.default_options)))
|
|
42
43
|
end
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def sources(secondary, options={})
|
|
46
47
|
if secondary.nil?
|
|
47
|
-
|
|
48
|
+
mashup(self.class.get("/sources?", :query => options.merge(self.default_options)))
|
|
48
49
|
else
|
|
49
|
-
|
|
50
|
+
mashup(self.class.get("/sources/#{secondary}", :query => options.merge(self.default_options)))
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def source(secondary, options={})
|
|
54
55
|
if secondary.nil?
|
|
55
|
-
|
|
56
|
+
mashup(self.class.get("/source", :query => options.merge(self.default_options)))
|
|
56
57
|
else
|
|
57
|
-
|
|
58
|
+
mashup(self.class.get("/source/#{secondary}", :query => options.merge(self.default_options)))
|
|
58
59
|
end
|
|
59
60
|
end
|
|
60
61
|
|
|
@@ -63,6 +64,21 @@ module Fred
|
|
|
63
64
|
def default_options
|
|
64
65
|
{:api_key => @api_key}
|
|
65
66
|
end
|
|
67
|
+
|
|
68
|
+
def mashup(response)
|
|
69
|
+
case response.code
|
|
70
|
+
when 200
|
|
71
|
+
if response.is_a?(Hash)
|
|
72
|
+
Hashie::Mash.new(response)
|
|
73
|
+
else
|
|
74
|
+
if response.first.is_a?(Hash)
|
|
75
|
+
response.map{|item| Hashie::Mash.new(item)}
|
|
76
|
+
else
|
|
77
|
+
response
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
66
82
|
|
|
67
83
|
end
|
|
68
84
|
end
|
data/pkg/fred-0.1.0.gem
ADDED
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<releases realtime_start="2008-07-28" realtime_end="2008-07-28">
|
|
3
|
+
<release id="53" realtime_start="2008-07-28" realtime_end="2008-07-28" name="Gross Domestic Product" press_release="true" link="http://www.bea.gov/national/index.htm"/>
|
|
4
|
+
</releases>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<releases realtime_start="2008-07-21" realtime_end="2008-07-21" order_by="release_id" sort_order="asc" count="82" offset="0" limit="1000">
|
|
3
|
+
<release id="9" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Advance Monthly Sales for Retail and Food Services" press_release="true" link="http://www.census.gov/svsd/www/advtable.html"/>
|
|
4
|
+
<release id="10" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Consumer Price Index" press_release="true" link="http://www.bls.gov/cpi/"/>
|
|
5
|
+
<release id="11" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Employment Cost Index" press_release="true" link="http://www.bls.gov/ncs/ect/"/>
|
|
6
|
+
<release id="13" realtime_start="2008-07-21" realtime_end="2008-07-21" name="G.17 Industrial Production and Capacity Utilization" press_release="true" link="http://www.federalreserve.gov/releases/g17/"/>
|
|
7
|
+
<release id="14" realtime_start="2008-07-21" realtime_end="2008-07-21" name="G.19 Consumer Credit" press_release="true" link="http://www.federalreserve.gov/releases/g19/"/>
|
|
8
|
+
<release id="15" realtime_start="2008-07-21" realtime_end="2008-07-21" name="G.5 Foreign Exchange Rates" press_release="true" link="http://www.federalreserve.gov/releases/g5/"/>
|
|
9
|
+
<release id="17" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.10 Foreign Exchange Rates" press_release="true" link="http://www.federalreserve.gov/releases/h10/"/>
|
|
10
|
+
<release id="18" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.15 Selected Interest Rates" press_release="true" link="http://www.federalreserve.gov/releases/h15/"/>
|
|
11
|
+
<release id="19" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.3 Aggregate Reserves of Depository Institutions and the Monetary Base" press_release="true" link="http://www.federalreserve.gov/releases/h3/"/>
|
|
12
|
+
<release id="20" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.4.1 Factors Affecting Reserve Balances" press_release="true" link="http://www.federalreserve.gov/releases/h41/"/>
|
|
13
|
+
<release id="21" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.6 Money Stock Measures" press_release="true" link="http://www.federalreserve.gov/releases/h6/"/>
|
|
14
|
+
<release id="22" realtime_start="2008-07-21" realtime_end="2008-07-21" name="H.8 Assets and Liabilities of Commercial Banks in the United States" press_release="true" link="http://www.federalreserve.gov/releases/h8/"/>
|
|
15
|
+
<release id="25" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Manufacturing and Trade Inventories and Sales" press_release="true" link="http://www.census.gov/mtis/www/mtis.html"/>
|
|
16
|
+
<release id="26" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Manufacturing ISM Report on Business" press_release="true" link="http://www.ism.ws/ISMReport/"/>
|
|
17
|
+
<release id="27" realtime_start="2008-07-21" realtime_end="2008-07-21" name="New Residential Construction" press_release="true" link="http://www.census.gov/const/www/newresconstindex.html"/>
|
|
18
|
+
<release id="46" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Producer Price Index" press_release="true" link="http://www.bls.gov/ppi/"/>
|
|
19
|
+
<release id="47" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Productivity and Costs" press_release="true" link="http://www.bls.gov/lpc/"/>
|
|
20
|
+
<release id="49" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. International Transactions" press_release="true" link="http://www.bea.gov/newsreleases/international/transactions/transnewsrelease.htm"/>
|
|
21
|
+
<release id="50" realtime_start="2008-07-21" realtime_end="2008-07-21" name="The Employment Situation" press_release="true" link="http://www.bls.gov/ces/"/>
|
|
22
|
+
<release id="51" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. International Trade in Goods and Services" press_release="true" link="http://www.bea.gov/newsreleases/international/trade/tradnewsrelease.htm"/>
|
|
23
|
+
<release id="52" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Z.1 Flow of Funds Accounts of the United States" press_release="true" link="http://www.federalreserve.gov/releases/z1/"/>
|
|
24
|
+
<release id="53" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Gross Domestic Product" press_release="true" link="http://www.bea.gov/national/index.htm"/>
|
|
25
|
+
<release id="54" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Personal Income and Outlays" press_release="true" link="http://www.bea.gov/national/index.htm#personal"/>
|
|
26
|
+
<release id="55" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Reports of Condition and Income for All Insured U.S. Commercial Banks" press_release="true"/>
|
|
27
|
+
<release id="59" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Monthly National Population Estimates" press_release="false" link="http://www.census.gov/popest/national/"/>
|
|
28
|
+
<release id="61" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Money Zero Maturity (MZM)" press_release="false" link="http://research.stlouisfed.org/publications/mt/"/>
|
|
29
|
+
<release id="62" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Monetary Services Index (MSI)" press_release="false" link="http://research.stlouisfed.org/msi/"/>
|
|
30
|
+
<release id="63" realtime_start="2008-07-21" realtime_end="2008-07-21" name="M2 Related Series" press_release="false" link="http://research.stlouisfed.org/publications/mt/"/>
|
|
31
|
+
<release id="64" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Long-Term U.S. Treasury Securities - Market Yield" press_release="false"/>
|
|
32
|
+
<release id="70" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Monthly Treasury Inflation-Indexed Securities" press_release="false"/>
|
|
33
|
+
<release id="71" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Weekly Treasury Inflation-Indexed Securities" press_release="false"/>
|
|
34
|
+
<release id="72" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Daily Treasury Inflation-Indexed Securities" press_release="false"/>
|
|
35
|
+
<release id="78" realtime_start="2008-07-21" realtime_end="2008-07-21" name="St. Louis Monthly Reserves and Monetary Base" press_release="false" link="http://research.stlouisfed.org/publications/mt/"/>
|
|
36
|
+
<release id="79" realtime_start="2008-07-21" realtime_end="2008-07-21" name="St. Louis Bi-Weekly Reserves and Monetary Base" press_release="false" link="http://research.stlouisfed.org/publications/usfd/"/>
|
|
37
|
+
<release id="80" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Treasury Bulletin" press_release="true" link="http://www.fms.treas.gov/bulletin/"/>
|
|
38
|
+
<release id="81" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Fiscal Year Budget Data" press_release="false" link="http://www.gpoaccess.gov/usbudget/"/>
|
|
39
|
+
<release id="82" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Economic Report of the President" press_release="true" link="http://www.gpoaccess.gov/eop/"/>
|
|
40
|
+
<release id="86" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Commercial Paper Outstanding" press_release="true" link="http://www.federalreserve.gov/releases/cp/"/>
|
|
41
|
+
<release id="87" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Transitional Euro Country Exchange Rates" press_release="false"/>
|
|
42
|
+
<release id="89" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Household Debt Service and Financial Obligations Ratios" press_release="true" link="http://federalreserve.gov/releases/housedebt/"/>
|
|
43
|
+
<release id="91" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Surveys of Consumers" press_release="true" link="http://www.sca.isr.umich.edu/"/>
|
|
44
|
+
<release id="92" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Selected Real Retail Sales Series" press_release="false"/>
|
|
45
|
+
<release id="93" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Supplemental Estimates, Motor Vehicles" press_release="true" link="http://www.bea.gov/bea/dn/home/suppestimates.htm"/>
|
|
46
|
+
<release id="94" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Survey of Secondary Market Prices and Yields, and Interest Rates for Home Loans" press_release="true"/>
|
|
47
|
+
<release id="95" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Manufacturer's Shipments, Inventories, and Orders (M3) Survey" press_release="true" link="http://www.census.gov/indicator/www/m3/"/>
|
|
48
|
+
<release id="97" realtime_start="2008-07-21" realtime_end="2008-07-21" name="New Residential Sales" press_release="true" link="http://www.census.gov/const/www/newressalesindex.html"/>
|
|
49
|
+
<release id="99" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Budget and Economic Outlook" press_release="true" link="http://www.cbo.gov/publications/bysubject.cfm?cat=0"/>
|
|
50
|
+
<release id="100" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Seasonal Credit Rate" press_release="false" link="http://www.frbdiscountwindow.org/historicalrates.cfm?hdrID=20&dtlID=52"/>
|
|
51
|
+
<release id="101" realtime_start="2008-07-21" realtime_end="2008-07-21" name="FOMC Press Release" press_release="true" link="http://www.federalreserve.gov/fomc/"/>
|
|
52
|
+
<release id="102" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Wall Street Journal" press_release="true" link="http://online.wsj.com/public/us"/>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<seriess realtime_start="2008-07-29" realtime_end="2008-07-29">
|
|
3
|
+
<series id="GNPCA" realtime_start="2008-07-29" realtime_end="2008-07-29" title="Real Gross National Product" observation_start="1929-01-01" observation_end="2007-01-01" frequency="Annual" frequency_short="A" units="Billions of Chained 2000 Dollars" units_short="Bil. of Chained 2000 $" seasonal_adjustment="Not Applicable" seasonal_adjustment_short="NA" last_updated="2008-03-27 11:16:06-05"/>
|
|
4
|
+
</seriess>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<sources realtime_start="2008-07-21" realtime_end="2008-07-21">
|
|
3
|
+
<source id="1" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Board of Governors of the Federal Reserve System" link="http://www.federalreserve.gov/"/>
|
|
4
|
+
</sources>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<sources realtime_start="2008-07-21" realtime_end="2008-07-21" order_by="source_id" sort_order="asc" count="21" offset="0" limit="1000">
|
|
3
|
+
<source id="1" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Board of Governors of the Federal Reserve System" link="http://www.federalreserve.gov/"/>
|
|
4
|
+
<source id="3" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Federal Reserve Bank of Philadelphia" link="http://www.philadelphiafed.org/"/>
|
|
5
|
+
<source id="4" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Federal Reserve Bank of St. Louis" link="http://www.stlouisfed.org/"/>
|
|
6
|
+
<source id="6" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Federal Financial Institutions Examination Council" link="http://www.ffiec.gov/"/>
|
|
7
|
+
<source id="11" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Dow Jones & Company" link="http://www.dowjones.com"/>
|
|
8
|
+
<source id="13" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Institute for Supply Management" link="http://www.ism.ws/"/>
|
|
9
|
+
<source id="14" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Survey Research Center: University of Michigan" link="http://www.isr.umich.edu/src/"/>
|
|
10
|
+
<source id="15" realtime_start="2008-07-21" realtime_end="2008-07-21" name="The White House: Council of Economic Advisors" link="http://www.whitehouse.gov/cea/"/>
|
|
11
|
+
<source id="16" realtime_start="2008-07-21" realtime_end="2008-07-21" name="The White House: Office of Management and Budget" link="http://www.whitehouse.gov/omb/"/>
|
|
12
|
+
<source id="17" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Congress: Congressional Budget Office" link="http://www.cbo.gov/"/>
|
|
13
|
+
<source id="18" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Department of Commerce: Bureau of Economic Analysis" link="http://www.bea.gov/"/>
|
|
14
|
+
<source id="19" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Department of Commerce: Census Bureau" link="http://www.census.gov/"/>
|
|
15
|
+
<source id="21" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Department of Housing and Urban Development" link="http://www.hud.gov/"/>
|
|
16
|
+
<source id="22" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Department of Labor: Bureau of Labor Statistics" link="http://www.bls.gov/"/>
|
|
17
|
+
<source id="23" realtime_start="2008-07-21" realtime_end="2008-07-21" name="U.S. Department of the Treasury, Financial Management Service" link="http://www.fms.treas.gov/"/>
|
|
18
|
+
<source id="26" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Haver Analytics" link="http://www.haver.com/"/>
|
|
19
|
+
<source id="31" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Reserve Bank of Australia" link="http://www.rba.gov.au/"/>
|
|
20
|
+
<source id="32" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Deutsche Bundesbank" link="http://www.bundesbank.de/index.en.php"/>
|
|
21
|
+
<source id="33" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Banca d'Italia" link="http://www.bancaditalia.it/;internal&action=_setlanguage.action?LANGUAGE=en"/>
|
|
22
|
+
<source id="34" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Swiss National Bank" link="http://www.snb.ch/"/>
|
|
23
|
+
<source id="35" realtime_start="2008-07-21" realtime_end="2008-07-21" name="Central Bank of the Republic of Turkey" link="http://www.tcmb.gov.tr/yeni/eng/"/>
|
|
24
|
+
</sources>
|
data/test/fred_test.rb
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
2
|
|
|
3
|
-
class FredTest <
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
class FredTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "Fred API" do
|
|
6
|
+
setup do
|
|
7
|
+
@client = Fred::Client.new(:api_key => 'wtf')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context "and get categories" do
|
|
11
|
+
should "find a specific category" do
|
|
12
|
+
stub_get("http://api.stlouisfed.org/fred/category?category_id=125&api_key=wtf", "category.xml")
|
|
13
|
+
category_result = @client.category(nil, :category_id => '125')
|
|
14
|
+
category_result.categories.category.name.should == "Trade Balance"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "and get releases" do
|
|
19
|
+
should "find all releases" do
|
|
20
|
+
stub_get("http://api.stlouisfed.org/fred/releases?api_key=wtf", "releases.xml")
|
|
21
|
+
releases_result = @client.releases(nil)
|
|
22
|
+
releases_result.first.last.release.first.name.should == "Advance Monthly Sales for Retail and Food Services"
|
|
23
|
+
releases_result.first.last.release.last.name.should == "Wall Street Journal"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "and get a release" do
|
|
28
|
+
should "find a specific release" do
|
|
29
|
+
stub_get("http://api.stlouisfed.org/fred/release?release_id=53&api_key=wtf", "release.xml")
|
|
30
|
+
release_result = @client.release(nil, :release_id => "53")
|
|
31
|
+
release_result.releases.release.name.should == "Gross Domestic Product"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "and get series" do
|
|
36
|
+
should "find a specific series" do
|
|
37
|
+
stub_get("http://api.stlouisfed.org/fred/series?api_key=wtf&series_id=GNPC", "series.xml")
|
|
38
|
+
series_result = @client.series(nil, :series_id => "GNPC")
|
|
39
|
+
series_result.seriess.series.title.should == "Real Gross National Product"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "and get source" do
|
|
44
|
+
should "find a specific source" do
|
|
45
|
+
stub_get("http://api.stlouisfed.org/fred/source?source_id=1&api_key=wtf", "source.xml")
|
|
46
|
+
source_result = @client.source(nil, :source_id => "1")
|
|
47
|
+
source_result.sources.source.name.should == "Board of Governors of the Federal Reserve System"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "and get sources" do
|
|
52
|
+
should "find all sources" do
|
|
53
|
+
stub_get("http://api.stlouisfed.org/fred/sources?&api_key=wtf&source_id=1", "sources.xml")
|
|
54
|
+
sources_result = @client.sources(nil, :source_id => "1")
|
|
55
|
+
sources_result.sources.source.first.name.should == "Board of Governors of the Federal Reserve System"
|
|
56
|
+
sources_result.sources.source.last.name.should == "Central Bank of the Republic of Turkey"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
7
60
|
end
|
|
8
|
-
|
|
61
|
+
|
|
62
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'pathname'
|
|
1
3
|
require 'rubygems'
|
|
2
|
-
|
|
3
|
-
require '
|
|
4
|
+
|
|
5
|
+
require 'shoulda'
|
|
6
|
+
require 'matchy'
|
|
7
|
+
require 'fakeweb'
|
|
8
|
+
|
|
9
|
+
begin require 'redgreen'; rescue LoadError; end
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
13
|
+
require 'fred'
|
|
14
|
+
|
|
15
|
+
# Set the default allow_net_connect option--usually you'll want this off.
|
|
16
|
+
# You don't usually want your test suite to make HTTP connections, do you?
|
|
17
|
+
|
|
18
|
+
FakeWeb.allow_net_connect = false
|
|
19
|
+
|
|
20
|
+
class Test::Unit::TestCase
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def fixture_file(filename)
|
|
24
|
+
return '' if filename == ''
|
|
25
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
|
26
|
+
File.read(file_path)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def fred_url(url, options={})
|
|
30
|
+
url =~ /^http/ ? url : "http://api2.citysearch.com#{url}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def stub_get(url, filename, options={})
|
|
34
|
+
opts = {:body => fixture_file(filename)}.merge(options)
|
|
35
|
+
|
|
36
|
+
FakeWeb.register_uri(:get, fred_url(url), opts)
|
|
37
|
+
end
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
-
|
|
7
|
+
- 2
|
|
8
8
|
- 0
|
|
9
|
-
version: 0.
|
|
9
|
+
version: 0.2.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Johnny Khai Nguyen
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-08-12 00:00:00 -05:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -44,13 +44,21 @@ files:
|
|
|
44
44
|
- README.md
|
|
45
45
|
- Rakefile
|
|
46
46
|
- VERSION
|
|
47
|
+
- fred.gemspec
|
|
47
48
|
- generators/fred/USAGE
|
|
48
49
|
- generators/fred/fred_generator.rb
|
|
49
50
|
- init.rb
|
|
50
51
|
- install.rb
|
|
51
52
|
- lib/fred.rb
|
|
52
53
|
- lib/fred/client.rb
|
|
54
|
+
- pkg/fred-0.1.0.gem
|
|
53
55
|
- tasks/fred_tasks.rake
|
|
56
|
+
- test/fixtures/category.xml
|
|
57
|
+
- test/fixtures/release.xml
|
|
58
|
+
- test/fixtures/releases.xml
|
|
59
|
+
- test/fixtures/series.xml
|
|
60
|
+
- test/fixtures/source.xml
|
|
61
|
+
- test/fixtures/sources.xml
|
|
54
62
|
- test/fred_test.rb
|
|
55
63
|
- test/test_helper.rb
|
|
56
64
|
- uninstall.rb
|