Hey it's like a CPI CSV proxy!

main
Dan Buch 9 years ago
commit 1c530fe20a

@ -0,0 +1,7 @@
source 'https://rubygems.org'
ruby '2.2.2' if ENV.key?('DYNO')
gem 'faraday'
gem 'puma'
gem 'sinatra'

@ -0,0 +1,26 @@
GEM
remote: https://rubygems.org/
specs:
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
multipart-post (2.0.0)
puma (2.13.4)
rack (1.6.4)
rack-protection (1.5.3)
rack
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
tilt (2.0.1)
PLATFORMS
ruby
DEPENDENCIES
faraday
puma
sinatra
BUNDLED WITH
1.10.6

@ -0,0 +1 @@
web: bundle exec rackup

@ -0,0 +1,3 @@
require './cpi_feed'
run CPIFeed

@ -0,0 +1,20 @@
require 'sinatra/base'
require 'faraday'
require 'json'
class CPIFeed < Sinatra::Base
DEFAULT_CPI_SERIES_URL = 'http://api.bls.gov/publicAPI/v2/timeseries/data/CUUSA210SA0'
get '/' do
resp = JSON.parse(Faraday.get(cpi_series_url).body)
content_type :csv
"cpi\n#{resp['Results']['series'].first['data'].first['value']}\n"
end
def cpi_series_url
ENV['CPI_SERIES_URL'] || DEFAULT_CPI_SERIES_URL
end
run! if app_file == $PROGRAM_FILE
end
Loading…
Cancel
Save