catobills 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in catobills.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Derek Willis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Catobills
2
+
3
+ Catobills is a Ruby library for working with congressional legislation served by the [Cato Institute's Deepbills Project](http://www.cato.org/resources/data), which adds [semantic information](http://namespaces.cato.org/catoxml/) to legislative XML. Catobills is an interface to the Deepbills API ([example response](http://deepbills.cato.org/api/1/bill?congress=113&billnumber=499&billtype=s&billversion=is)), which returns JSON that contains embedded XML.
4
+
5
+ The initial release of Catobills returns the contents of an API response but also two additional arrays. The first, `federal_bodies`, is a hash of federal agencies and organization (other than Congress itself and its leadership offices) that a bill mentions, and the number of times each is referenced. The second, `acts`, is a hash of references to enacted legislation contained in the bill - Catobills returns only full titles, not internal references - and the number of times each is referenced. These can be used to help determine the scope and impact of the legislation.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'catobills'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install catobills
20
+
21
+ ## Usage
22
+
23
+ You'll need to supply several parameters to a `Catobills::Bill` object to retrieve results. There are two ways to do this:
24
+
25
+ #### Using Deepbills parameters
26
+
27
+ Cato's API requires a congress (currently only the 113th Congress is available), the bill number, the bill type and bill version, which defaults to the introduced (first) version of the legislation. This would retrieve details for S1328:
28
+
29
+ ```ruby
30
+ bill = Catobills::Bill.find(113, 362, 's', 'is')
31
+ bill.federal_bodies
32
+ => {"Department of Energy"=>2, "Secretary of the Interior"=>1, "Secretary of Energy"=>2, "Office of Energy Efficiency and Renewable Energy"=>2, "Assistant Secretary for Energy Efficiency and Renewable Energy"=>1}
33
+ bill.acts
34
+ => {"Title VI of the Energy Independence and Security Act of 2007"=>1, "Mineral Leasing Act"=>1, "Mineral Leasing Act for Acquired Lands"=>1}
35
+ ```
36
+
37
+ #### Using Congress and Bill Slug
38
+
39
+ For example, from a NYT Inside Congress [bill url](http://politics.nytimes.com/congress/bills/113/hr391):
40
+
41
+ ```ruby
42
+ bill = Catobills::Bill.find_by_slug(113,'hr541')
43
+ bill.federal_bodies
44
+ => {"Secretary of Health and Human Services"=>3, "Director of the Centers for Disease Control and Prevention"=>2, "Advisory Committee on Infant Mortality"=>1, "Department of Health and Human Services"=>4}
45
+ bill.acts
46
+ => {"PREEMIE Reauthorization Act"=>1}
47
+ ```
48
+
49
+ ## Tests
50
+
51
+ To run the tests, it's `rake test`. Catobills uses MiniTest.
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/test_*.rb"
6
+ end
data/catobills.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'catobills/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "catobills"
8
+ spec.version = Catobills::VERSION
9
+ spec.authors = ["Derek Willis"]
10
+ spec.email = ["dwillis@gmail.com"]
11
+ spec.description = %q{Wrapper for Cato's Deep Bills API}
12
+ spec.summary = %q{Extracts XML markup from Cato's Deep Bills Project}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "webmock"
25
+ spec.add_dependency "oj"
26
+ spec.add_dependency "ox"
27
+ spec.add_dependency "httparty"
28
+ end
@@ -0,0 +1,51 @@
1
+ module Catobills
2
+ class Bill
3
+
4
+ attr_reader :bill_number, :bill_body, :version, :congress, :bill_type, :federal_bodies, :acts
5
+
6
+ def initialize(params={})
7
+ params.each_pair do |k,v|
8
+ instance_variable_set("@#{k}", v)
9
+ end
10
+ end
11
+
12
+ def self.find_by_slug(congress, bill_slug)
13
+ m = /([a-z]*)([0-9]*)/.match(bill_slug)
14
+ version = m[1][0] == 'h' ? 'ih' : 'is'
15
+ find(congress, m[2], m[1], version)
16
+ end
17
+
18
+ def self.find(congress, bill_number, bill_type, version)
19
+ url = "http://deepbills.cato.org/api/1/bill?congress=#{congress}&billnumber=#{bill_number}&billtype=#{bill_type}&billversion=#{version}"
20
+ response = HTTParty.get(url)
21
+ bill = Oj.load(response.body)
22
+ bill_body = Ox.load(bill['billbody'])
23
+ self.new(:bill_number => bill['billnumber'],
24
+ :bill_body => bill_body,
25
+ :version => bill['billversion'],
26
+ :congress => bill['congress'],
27
+ :bill_type => bill['billtype'],
28
+ :federal_bodies => self.populate_federal_bodies(bill_body),
29
+ :acts => self.populate_acts(bill_body))
30
+ end
31
+
32
+ def self.populate_acts(bill_body)
33
+ results = bill_body.locate('legis-body/*/cato:entity-ref').select{|ref| ref['entity-type'] == 'act'}
34
+ array_count(results.map{|ref| ref.text.gsub(/\s+/, " ").strip}.compact.reject{|ref| ref[0] != ref[0].upcase}).reject{|ref| ref[0] == '('}.reject{|ref| ['Section', 'section', 'chapter', 'subsection'].any? {|s| ref.include?(s)}}
35
+ end
36
+
37
+ # collects mentions of federal bodies, removing 'Congress', leadership offices, 'Commission', 'Board' and offices within agencies.
38
+ def self.populate_federal_bodies(bill_body)
39
+ results = bill_body.locate('legis-body/*/cato:entity-ref').select{|ref| ref['entity-type'] == 'federal-body'}
40
+ array_count(results.flatten.reject{|ref| ref['entity-id'] == "0001"}.reject{|ref| ref['entity-parent-id'] == '0050'}.reject{|ref| ref['entity-parent-id'] == '0010'}.map{|ref| ref.text.gsub(/\s+/, " ").strip}.compact.reject{|x| ['Commission', 'Board', 'Secretary', 'Department', 'Administrator', 'Administration', 'House', 'Senate', 'Director', 'Advisory Committee'].include?(x)})
41
+ end
42
+
43
+ def self.array_count(array)
44
+ h = Hash.new(0)
45
+ array.each do |v|
46
+ h[v] += 1
47
+ end
48
+ h
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Catobills
2
+ VERSION = "0.1"
3
+ end
data/lib/catobills.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "catobills/version"
2
+ require "catobills/bill"
3
+ require 'httparty'
4
+ require 'oj'
5
+ require 'ox'
6
+
7
+ module Catobills
8
+ end
@@ -0,0 +1 @@
1
+ {"billnumber": "1328", "billbody": "<bill bill-stage=\"Introduced-in-Senate\" public-private=\"public\">\n\t<metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<dublinCore>\n<dc:title>113 S1328 IS: New Philadelphia, Illinois, Study Act</dc:title>\n<dc:publisher>U.S. Senate</dc:publisher>\n<dc:date>2013-07-18</dc:date>\n<dc:format>text/xml</dc:format>\n<dc:language>EN</dc:language>\n<dc:rights>Pursuant to Title 17 Section 105 of the United States Code, this file is not subject to copyright protection and is in the public domain.</dc:rights>\n</dublinCore>\n</metadata>\n<form>\n\t\t<distribution-code display=\"yes\">II</distribution-code>\n\t\t<congress>113th CONGRESS</congress>\n\t\t<session>1st Session</session>\n\t\t<legis-num>S. 1328</legis-num>\n\t\t<current-chamber>IN THE SENATE OF THE UNITED STATES</current-chamber>\n\t\t<action>\n\t\t\t<action-date date=\"20130718\">July 18, 2013</action-date>\n\t\t\t<action-desc>\n <sponsor name-id=\"S339\">Mr. Kirk</sponsor> (for himself\n\t\t\t and <cosponsor name-id=\"S253\">Mr. Durbin</cosponsor>) introduced the following\n\t\t\t bill; which was read twice and referred to the\n\t\t\t <committee-name committee-id=\"SSEG00\">Committee on Energy and Natural\n\t\t\t Resources</committee-name>\n </action-desc>\n\t\t</action>\n\t\t<legis-type>A BILL</legis-type>\n\t\t<official-title>To authorize the Secretary of the Interior to conduct a\n\t\t special resource study of the archeological site and surrounding land of the\n\t\t New Philadelphia town site in the State of Illinois, and for other\n\t\t purposes.</official-title>\n\t</form>\n\t<legis-body id=\"H9D3B4B70193943A9B8F54B62F3816AB3\" style=\"OLC\">\n\t\t<section id=\"H8ED0C4CA58C84BD3BF7D9E6A4C03F570\" section-type=\"section-one\">\n <enum>1.</enum>\n <header>Short title</header>\n <text display-inline=\"no-display-inline\">This Act may be cited as the\n\t\t\t <quote>\n <short-title>New Philadelphia, Illinois, Study\n\t\t\t Act</short-title>\n </quote>.</text>\n\t\t</section>\n <section id=\"HD626AE713A4A417CABD79DB353AE0A8E\">\n <enum>2.</enum>\n <header>Findings</header>\n <text display-inline=\"no-display-inline\">\n <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"0001\">Congress</cato:entity-ref> finds that\u2014</text>\n\t\t\t<paragraph id=\"HF466BB30674B48DC8E2CD1A144401DD7\">\n <enum>(1)</enum>\n <text>Frank McWorter, an\n\t\t\t enslaved man, bought his freedom and the freedom of 15 family members by mining\n\t\t\t for crude niter in Kentucky caves and processing the mined material into\n\t\t\t saltpeter;</text>\n\t\t\t</paragraph>\n <paragraph id=\"HE24B4FCABBCA4608B7E7CEA7F7669B76\">\n <enum>(2)</enum>\n <text>New Philadelphia,\n\t\t\t founded in 1836 by Frank McWorter, was the first town planned and legally\n\t\t\t registered by a free African-American before the Civil War;</text>\n\t\t\t</paragraph>\n <paragraph id=\"H79E9E24750254A68A174DD103887C16E\">\n <enum>(3)</enum>\n <text>the first railroad\n\t\t\t constructed in the area of New Philadelphia bypassed New Philadelphia, which\n\t\t\t led to the decline of New Philadelphia; and</text>\n\t\t\t</paragraph>\n <paragraph id=\"HC7A29B29C42B440F920D82AF3BBCE485\">\n <enum>(4)</enum>\n <text>the New\n\t\t\t Philadelphia site\u2014</text>\n\t\t\t\t<subparagraph id=\"H00A2FE056A0E499784BC63F61A225618\">\n <enum>(A)</enum>\n <text>is a registered\n\t\t\t National Historic Landmark;</text>\n\t\t\t\t</subparagraph>\n <subparagraph id=\"H654ED09F49DA4105933A782DDCF5861C\">\n <enum>(B)</enum>\n <text>is covered by\n\t\t\t farmland; and</text>\n\t\t\t\t</subparagraph>\n <subparagraph id=\"H1FE803EC55CA4898AFFDA2FFC76A988F\">\n <enum>(C)</enum>\n <text>does not contain\n\t\t\t any original buildings of the town or the McWorter farm and home that are\n\t\t\t visible above ground.</text>\n\t\t\t\t</subparagraph>\n </paragraph>\n </section>\n <section id=\"HACB7EC2B3367446C997A8E03C62787A8\">\n <enum>3.</enum>\n <header>Definitions</header>\n <text display-inline=\"no-display-inline\">In this Act:</text>\n\t\t\t<paragraph id=\"HA0B04B72933F415DB13AC02EC566060A\">\n <enum>(1)</enum>\n <header>Secretary</header>\n <text>The\n\t\t\t term <term>Secretary</term> means the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1400\">Secretary of the Interior</cato:entity-ref>.</text>\n\t\t\t</paragraph>\n <paragraph id=\"H984A2A4CD11C43B4B8AD24350C36D120\">\n <enum>(2)</enum>\n <header>Study\n\t\t\t Area</header>\n <text>The term <term>Study Area</term> means the New Philadelphia\n\t\t\t archeological site and the surrounding land in the State of Illinois.</text>\n\t\t\t</paragraph>\n </section>\n <section id=\"H60E946510C9740E385A18149B6F397E6\">\n <enum>4.</enum>\n <header>Special resource\n\t\t\t study</header>\n\t\t\t<subsection id=\"HBCE89EE053E94B0D97DFC666EC25368E\">\n <enum>(a)</enum>\n <header>Study</header>\n <text>The\n\t\t\t <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1400\">Secretary</cato:entity-ref> shall conduct a special resource study of the Study Area.</text>\n\t\t\t</subsection>\n <subsection id=\"H0BA427F9036A4FB29CE6AFFAC6D17418\">\n <enum>(b)</enum>\n <header>Contents</header>\n <text>In\n\t\t\t conducting the study under <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"act\" value=\"New Philadelphia, Illinois, Study Act/s:4/ss:a\" proposed=\"true\">subsection (a)</cato:entity-ref>, the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1400\">Secretary</cato:entity-ref> shall\u2014</text>\n\t\t\t\t<paragraph id=\"H07D6E02431854EDDA4472D2DB5286FC7\">\n <enum>(1)</enum>\n <text>evaluate the\n\t\t\t national significance of the Study Area;</text>\n\t\t\t\t</paragraph>\n <paragraph id=\"H561BFBA1A76445FE917E993203238FF5\">\n <enum>(2)</enum>\n <text>determine the\n\t\t\t suitability and feasibility of designating the Study Area as a unit of the\n\t\t\t <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" value=\"National Park System\" entity-parent-id=\"1443\">National Park System</cato:entity-ref>;</text>\n\t\t\t\t</paragraph>\n <paragraph id=\"HC2F698E5BF294AB4B9CCCC7AA2B6F0B9\">\n <enum>(3)</enum>\n <text>consider other\n\t\t\t alternatives for preservation, protection, and interpretation of the Study Area\n\t\t\t by\u2014</text>\n\t\t\t\t\t<subparagraph id=\"HF5D0F3C0C0F54B92A44706CDAECE6E63\">\n <enum>(A)</enum>\n <text>Federal, State, or\n\t\t\t local governmental entities; or</text>\n\t\t\t\t\t</subparagraph>\n <subparagraph id=\"H66E02A0B4F464367B1E1A05117C976A0\">\n <enum>(B)</enum>\n <text>private and\n\t\t\t nonprofit organizations;</text>\n\t\t\t\t\t</subparagraph>\n </paragraph>\n <paragraph id=\"HDF0116C8761744F1A647287D8113D87F\">\n <enum>(4)</enum>\n <text>consult\n\t\t\t with\u2014</text>\n\t\t\t\t\t<subparagraph id=\"HA93F5DD18F5C4BB689C98EDD6DF7F525\">\n <enum>(A)</enum>\n <text>interested\n\t\t\t Federal, State, or local governmental entities;</text>\n\t\t\t\t\t</subparagraph>\n <subparagraph id=\"H0988B5472C6042D5B9D63B136AE50B66\">\n <enum>(B)</enum>\n <text>private and\n\t\t\t nonprofit organizations; or</text>\n\t\t\t\t\t</subparagraph>\n <subparagraph id=\"HB84FCD21D29D409A839176D9E93AFCBB\">\n <enum>(C)</enum>\n <text>any other\n\t\t\t interested individuals; and</text>\n\t\t\t\t\t</subparagraph>\n </paragraph>\n <paragraph id=\"H4E6ED4A013664005856655A6C10FE5EE\">\n <enum>(5)</enum>\n <text>identify cost\n\t\t\t estimates for any Federal acquisition, development, interpretation, operation,\n\t\t\t and maintenance associated with the alternatives considered under <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"act\" value=\"New Philadelphia, Illinois, Study Act/s:4/ss:b/p:3\" proposed=\"true\">paragraph\n\t\t\t (3)</cato:entity-ref>.</text>\n\t\t\t\t</paragraph>\n </subsection>\n <subsection id=\"HD8F91DC17B3643F1A4620FCAE89BE8EF\">\n <enum>(c)</enum>\n <header>Applicable\n\t\t\t law</header>\n <text>The study required under <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"act\" value=\"New Philadelphia, Illinois, Study Act/s:4/ss:a\" proposed=\"true\">subsection (a)</cato:entity-ref> shall be conducted in\n\t\t\t accordance with <cato:entity xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"law-citation\">\n <cato:entity-ref entity-type=\"public-law\" value=\"public-law/91/383/s:8\">section 8 of Public Law 91\u2013383</cato:entity-ref> (<cato:entity-ref entity-type=\"uscode\" value=\"usc/16/1a\u20135\">16 U.S.C. 1a\u20135</cato:entity-ref>)</cato:entity>.</text>\n\t\t\t</subsection>\n <subsection id=\"H0CA44C10B6F843AF8E3DA3A90F528193\">\n <enum>(d)</enum>\n <header>Report</header>\n <text>Not\n\t\t\t later than 3 years after the date on which funds are first made available for\n\t\t\t the study under <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"act\" value=\"New Philadelphia, Illinois, Study Act/s:4/ss:a\" proposed=\"true\">subsection (a)</cato:entity-ref>, the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1400\">Secretary</cato:entity-ref> shall submit to the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"committee\" entity-id=\"HII00\">Committee on\n\t\t\t Natural Resources of the House of Representatives</cato:entity-ref> and the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"committee\" entity-id=\"SSEG00\">Committee on Energy\n\t\t\t and Natural Resources of the Senate</cato:entity-ref> a report containing\u2014</text>\n\t\t\t\t<paragraph id=\"H135EAF8EADB0454988BF556CD5112087\">\n <enum>(1)</enum>\n <text>the results of the\n\t\t\t study; and</text>\n\t\t\t\t</paragraph>\n <paragraph id=\"HFEF9826AFA1E4CC6933022FF3CE7CA29\">\n <enum>(2)</enum>\n <text>any conclusions\n\t\t\t and recommendations of the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1400\">Secretary</cato:entity-ref>.</text>\n\t\t\t\t</paragraph>\n </subsection>\n <subsection id=\"idD35277E2BF6443A8925A21749C273B71\">\n <enum>(e)</enum>\n <header>Funding</header>\n <text>The\n\t\t\t study authorized under this section shall be carried out using existing funds\n\t\t\t of the <cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"federal-body\" entity-id=\"1443\">National Park Service</cato:entity-ref>.</text>\n\t\t\t</subsection>\n </section>\n </legis-body>\n</bill>", "billversion": "is", "congress": "113", "billtype": "s"}
data/test/test_bill.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'catobills'
3
+ require 'oj'
4
+ require 'ox'
5
+ require 'net/http'
6
+ require 'minitest/autorun'
7
+ require 'webmock/minitest'
8
+
9
+ class TestBill < MiniTest::Test
10
+
11
+ def setup
12
+ stub_request(:get, "http://deepbills.cato.org/api/1/bill?billnumber=1328&billtype=s&billversion=is&congress=113").
13
+ with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
14
+ to_return(:status => 200, :body => File.open('test/s1328_113_is.json'), :headers => {})
15
+ @response = Net::HTTP.get('deepbills.cato.org', '/api/1/bill?congress=113&billnumber=1328&billtype=s&billversion=is')
16
+ bill = Oj.load(@response)
17
+ bill_body = Ox.load(bill['billbody'])
18
+ @bill = Catobills::Bill.new(:bill_number => bill['billnumber'],
19
+ :bill_body => bill_body,
20
+ :version => bill['billversion'],
21
+ :congress => bill['congress'],
22
+ :bill_type => bill['billtype'],
23
+ :federal_bodies => Catobills::Bill.populate_federal_bodies(bill_body),
24
+ :acts => Catobills::Bill.populate_acts(bill_body))
25
+ end
26
+
27
+ def test_that_the_correct_bill_was_loaded
28
+ assert_equal "1328", @bill.bill_number
29
+ end
30
+
31
+ def test_that_federal_bodies_were_created
32
+ h = {"Secretary of the Interior"=>1, "National Park System"=>1, "National Park Service"=>1}
33
+ assert_equal h, @bill.federal_bodies
34
+ end
35
+
36
+ def test_that_no_acts_were_created
37
+ assert_equal Hash.new, @bill.acts
38
+ end
39
+
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: catobills
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Derek Willis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: minitest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: oj
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: ox
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: httparty
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Wrapper for Cato's Deep Bills API
127
+ email:
128
+ - dwillis@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - catobills.gemspec
139
+ - lib/catobills.rb
140
+ - lib/catobills/bill.rb
141
+ - lib/catobills/version.rb
142
+ - test/s1328_113_is.json
143
+ - test/test_bill.rb
144
+ homepage: ''
145
+ licenses:
146
+ - MIT
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ segments:
158
+ - 0
159
+ hash: -3589454586152104644
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ segments:
167
+ - 0
168
+ hash: -3589454586152104644
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 1.8.25
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: Extracts XML markup from Cato's Deep Bills Project
175
+ test_files:
176
+ - test/s1328_113_is.json
177
+ - test/test_bill.rb