Browse files

Merge pull request #4 from Jeff-R/rdocs

Lots of new specs; updated RSpec; new rdocs; and eachability of most resources.
  • Loading branch information...
2 parents 7bf8b3a + 241b77f commit 801019cd3cb8133453ec7467aa49719fb45dcb29 OpenGovernment committed Jun 2, 2011
View
3 .rspec
@@ -0,0 +1,3 @@
+--colour
+--format nested
+--backtrace
View
2 lib/gov_kit/configuration.rb
@@ -2,7 +2,7 @@ module GovKit
class Configuration
attr_accessor :sunlight_apikey, :openstates_base_url, :transparency_data_base_url, :transparency_data_categories_url
attr_accessor :votesmart_apikey, :votesmart_base_url
- attr_accessor :ftm_apikey, :ftm_base_url
+ attr_accessor :openstates_apikey, :ftm_apikey, :ftm_base_url
attr_accessor :opencongress_apikey, :opencongress_base_url
attr_accessor :technorati_apikey, :technorati_base_url
attr_accessor :google_blog_base_url, :google_news_base_url
View
245 lib/gov_kit/open_states.rb
@@ -9,6 +9,24 @@ class OpenStatesResource < Resource
# http://rubydoc.info/gems/httparty/0.7.4/HTTParty/ClassMethods#default_params-instance_method
default_params :output => 'json', :apikey => GovKit::configuration.sunlight_apikey
base_uri GovKit::configuration.openstates_base_url
+
+ # Do a GET query, with optional parameters.
+ #
+ # OpenStates returns a 404 error when a query
+ # returns nothing.
+ #
+ # So, if a query result is a resource not found error,
+ # we return an empty set.
+ def self.get_uri(uri, options={})
+ begin
+ response = get(uri, options)
+ result = parse(response)
+ rescue ResourceNotFound
+ return []
+ end
+ result
+ end
+
end
# Ruby module for interacting with the Open States Project API
@@ -25,147 +43,33 @@ module OpenStates
CHAMBER_UPPER = "upper"
CHAMBER_LOWER = "lower"
- # The State class represents the data returned from Open States.
+ # The State class represents the state data returned from Open States.
#
- # From the Open States documentation, at http://openstates.sunlightlabs.com/api/metadata/,
- # the fields returned are:
+ # For details about fields returned, see the Open States documentation, at
+ # http://openstates.sunlightlabs.com/api/metadata/,
#
- # name
- # The name of the state
- # abbreviation
- # The two-letter abbreviation of the state
- # legislature_name
- # The name of the state legislature
- # upper_chamber_name
- # The name of the 'upper' chamber of the state legislature (if applicable)
- # lower_chamber_name
- # The name of the 'lower' chamber of the state legislature (if applicable)
- # upper_chamber_term
- # The length, in years, of a term for members of the 'upper' chamber (if applicable)
- # lower_chamber_term
- # The length, in years, of a term for members of the 'lower' chamber (if applicable)
- # upper_chamber_title
- # The title used to refer to members of the 'upper' chamber (if applicable)
- # lower_chamber_title
- # The title used to refer to members of the 'lower' chamber (if applicable)
- # latest_dump_url
- # URL pointing to a download of all data for the state
- # latest_dump_date
- # datestamp of the file at latest_dump_url
- # terms
- #
- # A list of terms that we have data available for. Each session will be an object with the following fields:
- #
- # * start_year: The year in which this session began.
- # * end_year: The year in which this session ended.
- # * name: The name of this session.
- # * sessions: List of sessions that took place inside the given term.
- #
- # session_details
- #
- # Optional extra details about sessions.
- #
- # If present will be a dictionary with keys corresponding to sessions and values are dictionaries of extra metadata about a session.
- #
- # Fields that may be present include start_date and end_date, as well as type indicating whether the session was a normally scheduled or special session.
- #
class State < OpenStatesResource
def self.find_by_abbreviation(abbreviation)
- response = get("/metadata/#{abbreviation}/")
- parse(response)
+ get_uri("/metadata/#{abbreviation}/")
end
end
- # The Bill class represents the data returned from Open States.
+ # The Bill class represents the bill data returned from Open States.
#
- # From the Open States documentation, at http://openstates.sunlightlabs.com/api/bills/,
- # the fields returned are:
+ # For details about fields returned, see the Open States documentation, at
+ # http://openstates.sunlightlabs.com/api/bills/,
#
- # title
- # The title given to the bill by the state legislature.
- # state
- # The 2-letter abbreviation of the state this bill is from (e.g. ny).
- # session
- # The session this bill was introduced in.
- # chamber
- # The chamber this bill was introduced in (e.g. 'upper', 'lower')
- # bill_id
- # The identifier given to this bill by the state legislature (e.g. 'AB6667')
- # type
- # Bill type (see bill categorization).
- # alternate_titles
- # A list of alternate titles that this bill is/was known by, if available.
- # updated_at
- # Timestamp representing when bill was last updated in our system.
- # actions
- #
- # A list of legislative actions performed on this bill. Each action will be an object with at least the following fields:
- #
- # * date: The date/time the action was performed
- # * actor: The chamber, person, committee, etc. responsible for this action
- # * action: A textual description of the action performed
- # * type: A normalized type for the action, see see action categorization.
- #
- # sponsors
- #
- # A list of sponsors of this bill. Each sponsor will be an object with at least the following fields:
- #
- # * leg_id: An Open State Project legislator ID.
- # * full_name: The name of the sponsor
- # * type: The type of sponsorship (state specific, examples include 'Primary Sponsor', 'Co-Sponsor')
- #
- # votes
- #
- # A list of votes relating to this bill. Each vote will be an object with at least the following fields:
- #
- # * date: The date/time the vote was taken
- # * chamber: The chamber that the vote was taken in
- # * motion: The motion being voted on
- # * yes_count, no_count, other_count: The number of 'yes', 'no', and other votes
- # * yes_votes, no_votes, other_votes: The legislators voting 'yes', 'no', and other
- # * passed: Whether or not the vote passed
- # * type: The normalized type for the vote. See vote categorization).
- #
- # versions
- #
- # A list of versions of the text of this bill. Each version will be an object with at least the following fields:
- #
- # * url: The URL for an official source of this version of the bill text
- # * name: A name for this version of the bill text
- #
- # documents
- #
- # A list of documents related to this bill. Each document will be an object with at least the following fields:
- #
- # * url: The URL for an official source of this document
- # * name: A name for this document (eg. 'Fiscal Statement', 'Education Committee Report')
- #
- # sources
- #
- # List of sources that this data was collected from.
- #
- # * url: URL of the source
- # * retrieved: time at which the source was last retrieved
- #
- # Note
- #
- # actions, sponsors, votes, versions, documents, alternate_title and sources are not returned via the search API.
- #
- # Note
- #
- # Keep in mind that these documented fields may be a subset of the fields provided for a given state.
class Bill < OpenStatesResource
# http://openstates.sunlightlabs.com/api/v1/bills/ca/20092010/AB 667/
def self.find(state_abbrev, session, bill_id, chamber = '')
escaped_bill_id = bill_id.gsub(/ /, '%20')
escaped_session = session.gsub(/ /, '%20')
- response = get("/bills/#{state_abbrev.downcase}/#{escaped_session}/#{chamber.blank? ? '' : chamber + '/'}#{escaped_bill_id}/")
- parse(response)
+
+ get_uri("/bills/#{state_abbrev.downcase}/#{escaped_session}/#{chamber.blank? ? '' : chamber + '/'}#{escaped_bill_id}/")
end
def self.search(query, options = {})
- response = get('/bills/', :query => {:q => query}.merge(options))
- parse(response)
+ get_uri('/bills/', :query => {:q => query}.merge(options))
end
def self.latest(updated_since, ops = {})
@@ -174,106 +78,33 @@ def self.latest(updated_since, ops = {})
end
end
- # The Legislator class represents the data returned from Open States.
+ # The Legislator class represents the legislator data returned from Open States.
#
- # From the Open States documentation, at http://openstates.sunlightlabs.com/api/legislators/,
- # the fields returned are:
+ # For details about fields returned, see the Open States documentation, at
+ # http://openstates.sunlightlabs.com/api/legislators/,
#
- # * leg_id: A permanent, unique identifier for this legislator within the Open State Project system.
- # * full_name
- # * first_name
- # * last_name
- # * middle_name
- # * suffixes
- # * photo_url
- # * active - Boolean indicating whether or not this legislator is currently serving.
- # * state, chamber, district, party (only present if the legislator is currently serving)
- # * roles: A list of objects representing roles this legislator currently holds. Each role will contain at least the type and term roles:
- # o type the type of role - e.g. "member", "committee member", "Lt. Governor"
- # o term the term the role was held during
- # o chamber
- # o district
- # o party
- # o committee
- # o term
- # * old_roles: A dictionary mapping term names for past terms to lists of roles held. (Sub-objects have same fields as roles.)
- # * sources List of sources that this data was collected from.
- # o url: URL of the source
- # o retrieved: time at which the source was last retrieved
- # Note
- #
- # sources, roles and old_roles are not included in the legislator search response.
- #
- # Note
- #
- # Keep in mind that these documented fields may be a subset of the fields provided for a given state.
class Legislator < OpenStatesResource
def self.find(legislator_id)
- response = get("/legislators/#{legislator_id}/")
- parse(response)
+ get_uri("/legislators/#{legislator_id}/")
end
def self.search(options = {})
- response = get('/legislators/', :query => options)
- parse(response)
+ get_uri('/legislators/', :query => options)
end
end
- # The Committeer class represents the data returned from Open States.
+ # The Committee class represents the committee data returned from Open States.
#
- # From the Open States documentation, at http://openstates.sunlightlabs.com/api/committees/,
- # the fields returned are:
+ # For details about fields returned, see the Open States documentation, at
+ # http://openstates.sunlightlabs.com/api/committees/,
#
- # Committee methods return objects with the following fields:
- #
- # id
- # Open State Project Committee ID.
- # chamber
- # Associated chamber (upper, lower, or joint).
- # state
- # State abbreviation (eg. ny).
- # committee
- # Name of committee.
- # subcommittee
- # Name of subcommittee (null if record describes a top level committee).
- # parent_id
- # For subcommittees, the committee ID of its parent. null otherwise.
- # members
- #
- # Listing of the current committee membership.
- #
- # legislator
- # Name of legislator (as captured from source).
- # role
- # Role of this member on the committee (usually 'member' but may indicate charimanship or other special status)
- # leg_id
- # Legislator's Open State Project ID
- #
- # sources
- #
- # List of sources that this data was collected from.
- #
- # url
- # URL of the source
- # retrieved
- # time at which the source was last retrieved
- #
- # Note
- #
- # members and sources are not included in the committee search API results
- #
- # Note
- #
- # Keep in mind that these documented fields may be a subset of the fields provided for a given state. (See extra fields.)
class Committee < OpenStatesResource
def self.find(committee_id)
- response = get("/committees/#{committee_id}/")
- parse(response)
+ get_uri("/committees/#{committee_id}/")
end
def self.search(options = {})
- response = get('/committees/', :query => options)
- parse(response)
+ get_uri('/committees/', :query => options)
end
end
View
39 lib/gov_kit/resource.rb
@@ -1,7 +1,24 @@
module GovKit
-
- # Parent class of resources returned by GovKit.
+
+ # This is the parent class to the classes that wrap
+ # the data returned to govkit.
+ #
+ # The subclasses are responsible for fetching the data as json from
+ # different web services; Resource will then parse the json,
+ # converting returned fields to instance methods.
+ #
+ # Initialize a Resource with a hash of attributes, or an array of hashes.
+ # For each attribute, add a getter and setter to this instance.
+ # So if
+ # res = Resource.new { "aaa" => "111", "bbb" => "222", "ccc" => "333" }
+ # then
+ # res.aaa == "111"
+ # res.bbb == "222"
+ # res.ccc == "333"
+ #
+ # Includes HTTParty, which provides convenience methods like get().
#
+ # See http://rdoc.info/github/jnunemaker/httparty/master/HTTParty/ClassMethods
class Resource
include HTTParty
format :json
@@ -32,12 +49,13 @@ def to_md5
# you'll need to handle that in the subclass.
#
def self.parse(response)
- raise ResourceNotFound, "Resource not found" unless !response.blank?
if response.class == HTTParty::Response
case response.response
when Net::HTTPNotFound
raise ResourceNotFound, "404 Not Found"
+ when Net::HTTPGone
+ raise ResourceNotFound, "404 Not Found"
when Net::HTTPUnauthorized
raise NotAuthorized, "401 Not Authorized; have you set up your API key?"
when Net::HTTPServerError
@@ -47,6 +65,8 @@ def self.parse(response)
end
end
+ return [] unless !response.blank?
+
instantiate(response)
end
@@ -55,24 +75,27 @@ def self.parse(response)
# +record+ is a hash of values returned by a service,
# or an array of hashes.
#
- # If +record+ is a hash, return a single GovKit::Resource.
+ # If +record+ is a hash, return an array containing a single GovKit::Resource.
# If it is an array, return an array of GovKit::Resources.
#
def self.instantiate(record)
if record.is_a?(Array)
instantiate_collection(record)
else
- new(record)
+ [new(record)]
end
end
def self.instantiate_collection(collection)
collection.collect! { |record| new(record) }
end
- # Fills the @attributes hash with new resources generated from the
- # members of the +attributes+ hash,
- #
+ # Given a hash of attributes, assign it to the @attributes member,
+ # then for each attribute, create or set a pair of member accessors with the name
+ # of the attribute's key.
+ # If the value of the attribute is itself an array or a hash,
+ # then create a new class with the (singularized) key as a name, and with a parent class of Resource,
+ # and initialize it with the hash.
def unload(attributes)
raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
View
98 lib/gov_kit/transparency_data.rb
@@ -1,24 +1,122 @@
module GovKit
class TransparencyDataResource < Resource
+
+ # default_params and base_uri are provided by HTTParty
default_params :apikey => GovKit::configuration.sunlight_apikey
base_uri GovKit::configuration.transparency_data_base_url
+
+ def self.search_for( path, ops={} )
+ response = get(path, :query => ops)
+ # puts "response.parsed_response: #{response.parsed_response.inspect}"
+ parse(response)
+ end
+
+ # For testing.
+ # Instantiate a GovKit::Resource object from sample data
+ # To get the sample data, use the text returned by "response.parsed_response" in self.search_for
+ def self.from_response response
+ parse response
+ end
+
end
module TransparencyData
+
+ # Represents contributions.
+ #
# See http://transparencydata.com/api/contributions/
# for complete query options.
+
class Contribution < TransparencyDataResource
+ # Deprecated. Use search instead.
def self.find(ops = {})
+ puts "GovKit::TransparencyData::Contribution.find is deprecated. Use Contribution.search instead."
response = get('/contributions.json', :query => ops)
parse(response)
end
+
+ # Search for contribution records.
+ #
+ # Example query:
+ # contributions = GovKit::TransparencyData::Contribution.search( { 'contributor_state' => 'md', 'recipient_ft' => 'mikulski', 'cycle' => '2008', 'per_page' => '3' } )
+ def self.search(ops = {})
+ search_for('/contributions.json', ops)
+ end
end
+ # Represents government contracts.
+ #
+ # See http://transparencydata.com/api/contracts/
+ # for complete query options.
+ #
+ class Contract < TransparencyDataResource
+ # Search for contract records.
+ #
+ # Example query:
+ # contracts = GovKit::TransparencyData::Contract.search( { :per_page => 2, :fiscal_year => 2008 } )
+ def self.search(ops = {})
+ search_for('/contracts.json', ops)
+ end
+ end
+
+ # Represents entities -- politicians, individuals, or organizations.
+ #
+ # See http://transparencydata.com/api/aggregates/contributions/
+ # for complete query options.
+
class Entity < TransparencyDataResource
+ # Deprecated for consistency of naming. Use find(id) instead.
def self.find_by_id(id)
+ puts "GovKit::TransparencyData::Entity.find_by_id is deprecated. Use Entity.find(id) instead."
response = get("/entities/#{id}.json")
parse(response)
end
+
+ # Find an entity by id.
+ def self.find(id)
+ response = get("/entities/#{id}.json")
+ parse(response)
+ end
+
+ # Search for contract records.
+ #
+ # Example query:
+ # entities = GovKit::TransparencyData::Entity.search('nancy+pelosi')
+ def self.search(search_string = '')
+ search_for("/entities.json", { :search => search_string } )
+ end
+ end
+
+ # Represents lobbying activity.
+ #
+ # See http://transparencydata.com/api/lobbying/
+ # for complete query options.
+
+ class LobbyingRecord < TransparencyDataResource
+ # Search for lobbying records.
+ #
+ # Example query:
+ # lobbying_records = GovKit::TransparencyData::LobbyingRecord.search( { :per_page => 2 } )
+ def self.search(ops = {})
+ search_for('/lobbying.json', ops)
+ end
+ end
+
+ # Represents government grants.
+ #
+ # See http://transparencydata.com/api/grants/
+ # for complete query options.
+
+ class Grant < TransparencyDataResource
+
+ # Search for lobbying records.
+ #
+ # Example query:
+ # grants = GovKit::TransparencyData::Grant.search( { :per_page => 2, :recipient_type => '00' } )
+
+ def self.search(ops = {})
+ search_for('/grants.json', ops)
+ end
end
class Categories
View
12 spec/fixtures/open_states/401.response
@@ -1,6 +1,10 @@
HTTP/1.1 401 UNAUTHORIZED
-Server: nginx/0.6.35
-Date: Tue, 15 Jun 2010 22:34:56 GMT
-Content-Type: text/plain
+Server: nginx/0.9.6
+Date: Thu, 21 Apr 2011 22:02:36 GMT
+Content-Type: text/html; charset=utf-8
+Transfer-Encoding: chunked
Connection: close
-Vary: Authorization
+Vary: Authorization
+
+Authorization Required:
+obtain a key at http://services.sunlightlabs.com/accounts/register/
View
9 spec/fixtures/open_states/404.response
@@ -0,0 +1,9 @@
+HTTP/1.1 404 NOT FOUND
+Server: nginx/0.9.6
+Date: Thu, 21 Apr 2011 21:34:05 GMT
+Content-Type: text/html; charset=utf-8
+Transfer-Encoding: chunked
+Connection: close
+
+404 not found
+
View
53 spec/fixtures/open_states/committee_find.response
@@ -0,0 +1,53 @@
+HTTP/1.1 200 OK
+Server: nginx/1.0.0
+Date: Fri, 29 Apr 2011 21:05:59 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+Authorization:
+
+{
+ "members": [
+ {
+ "leg_id": "MDL000194",
+ "role": "member",
+ "name": "Joan Carter Conway"
+ },
+ {
+ "leg_id": "MDL000226",
+ "role": "member",
+ "name": "Paul G. Pinsky"
+ },
+ {
+ "leg_id": "MDL000379",
+ "role": "member",
+ "name": "Bill Ferguson"
+ },
+ {
+ "leg_id": "MDL000381",
+ "role": "member",
+ "name": "J. B. Jennings"
+ },
+ {
+ "leg_id": "MDL000384",
+ "role": "member",
+ "name": "Karen S. Montgomery"
+ },
+ {
+ "leg_id": "MDL000387",
+ "role": "member",
+ "name": "Ronald N. Young"
+ }
+ ],
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "sources": [
+ {
+ "url": "http://www.msa.md.gov/msa/mdmanual/05sen/html/com/02eco.html"
+ }
+ ],
+ "subcommittee": "ENVIRONMENT SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000012"
+}
View
190 spec/fixtures/open_states/committee_query.response
@@ -0,0 +1,190 @@
+HTTP/1.1 200 OK
+Server: nginx/1.0.0
+Date: Fri, 29 Apr 2011 20:52:00 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[
+ {
+ "updated_at": "2011-04-26 01:20:17",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "ALCOHOLIC BEVERAGES SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000009"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000003",
+ "state": "md",
+ "subcommittee": "CAPITAL BUDGET SUBCOMMITTEE",
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000004"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "ENVIRONMENT SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000012"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "ETHICS & ELECTION LAW SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000013"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "FINANCE COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000015"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000015",
+ "state": "md",
+ "subcommittee": "HEALTH SUBCOMMITTEE",
+ "committee": "FINANCE COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000016"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:53",
+ "parent_id": "MDC000015",
+ "state": "md",
+ "subcommittee": "TRANSPORTATION SUBCOMMITTEE",
+ "committee": "FINANCE COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000017"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:53",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "EXECUTIVE NOMINATIONS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000018"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000003",
+ "state": "md",
+ "subcommittee": "PUBLIC SAFETY, TRANSPORTATION & ENVIRONMENT SUBCOMMITTEE",
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000007"
+ },
+ {
+ "created_at": "2011-01-29 00:13:19",
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "HEALTH OCCUPATIONS SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000068"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000003"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:53",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "SPECIAL COMMITTEE ON SUBSTANCE ABUSE",
+ "chamber": "upper",
+ "id": "MDC000019"
+ },
+ {
+ "created_at": "2011-01-29 00:13:19",
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "LABOR LICENSING, & REGULATION SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000069"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000003",
+ "state": "md",
+ "subcommittee": "HEALTH & HUMAN SERVICES SUBCOMMITTEE",
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000067"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000003",
+ "state": "md",
+ "subcommittee": "EDUCATION, BUSINESS & ADMINISTRATION SUBCOMMITTEE",
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000066"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000003",
+ "state": "md",
+ "subcommittee": "PENSIONS SUBCOMMITTEE",
+ "committee": "BUDGET & TAXATION COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000006"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000008"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": "MDC000009",
+ "state": "md",
+ "subcommittee": "EDUCATION SUBCOMMITTEE",
+ "committee": "EDUCATION, HEALTH & ENVIRONMENTAL AFFAIRS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000011"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "RULES COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000001"
+ },
+ {
+ "updated_at": "2011-04-29 01:19:52",
+ "parent_id": null,
+ "state": "md",
+ "subcommittee": null,
+ "committee": "JUDICIAL PROCEEDINGS COMMITTEE",
+ "chamber": "upper",
+ "id": "MDC000002"
+ }
+]
View
18 spec/fixtures/transparency_data/contributions.response
@@ -0,0 +1,18 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Mon, 11 Apr 2011 19:46:53 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+Authorization:
+
+[
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "D", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9020", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "4150", "parent_organization_name": "", "contributor_address": "3208 WOODLAND PARK DR", "transaction_id": "a980ecbe2fe713d4f7e57bea743fb5dd", "contributor_occupation": "", "filing_id": "", "contributor_city": "ANCHORAGE", "recipient_state_held": "", "district_held": "", "recipient_name": "FRENCH II, HOLLIS S", "organization_ext_id": "", "contributor_zipcode": "99517", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-10-04", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "FRENCH II, HOLLIS S", "contributor_type": "", "contributor_employer": "", "seat_result": "W", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "134213", "parent_organization_name": "", "contributor_address": "PO BOX 30009", "transaction_id": "cc17aa1b13fef861e777337443c15deb", "contributor_occupation": "", "filing_id": "", "contributor_city": "CENTRAL", "recipient_state_held": "", "district_held": "", "recipient_name": "CARTER, MAC", "organization_ext_id": "", "contributor_zipcode": "99730", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-03-15", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "CARTER, MAC", "contributor_type": "", "contributor_employer": "", "seat_result": "L", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z1100", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "CITIZENS FOR DAVE DONLEY", "recipient_ext_id": "13432", "parent_organization_name": "", "contributor_address": "4852 NEWCASTLE WAY", "transaction_id": "4c0b1c4a1749d5418322237bbc3e69f7", "contributor_occupation": "", "filing_id": "", "contributor_city": "ANCHORAGE", "recipient_state_held": "", "district_held": "", "recipient_name": "DONLEY, DAVE", "organization_ext_id": "", "contributor_zipcode": "99503", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-07-26", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "CITIZENS FOR DAVE DONLEY", "contributor_type": "C", "contributor_employer": "", "seat_result": "L", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "135818", "parent_organization_name": "", "contributor_address": "200 W 34TH AVE PMB 207", "transaction_id": "fee02c37c584c94ad17b37fcc265c21b", "contributor_occupation": "", "filing_id": "", "contributor_city": "ANCHORAGE", "recipient_state_held": "", "district_held": "", "recipient_name": "HEINZE, HAROLD", "organization_ext_id": "", "contributor_zipcode": "99503", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-10-02", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "HEINZE, HAROLD", "contributor_type": "", "contributor_employer": "", "seat_result": "L", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "4175", "parent_organization_name": "", "contributor_address": "1625 OLD STEESE HWY", "transaction_id": "8b354ef63c07e34ed5c4e30af05545c6", "contributor_occupation": "", "filing_id": "", "contributor_city": "FAIRBANKS", "recipient_state_held": "", "district_held": "", "recipient_name": "SEEKINS, RALPH C", "organization_ext_id": "", "contributor_zipcode": "99701", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-10-02", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "SEEKINS, RALPH C", "contributor_type": "", "contributor_employer": "", "seat_result": "W", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "4175", "parent_organization_name": "", "contributor_address": "1625 OLD STEESE HWY", "transaction_id": "213a7419bf0642cb871c45e0d6c7c062", "contributor_occupation": "", "filing_id": "", "contributor_city": "FAIRBANKS", "recipient_state_held": "", "district_held": "", "recipient_name": "SEEKINS, RALPH C", "organization_ext_id": "", "contributor_zipcode": "99701", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-06-24", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "SEEKINS, RALPH C", "contributor_type": "", "contributor_employer": "", "seat_result": "W", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "20439", "parent_organization_name": "", "contributor_address": "PO BOX 7351", "transaction_id": "0d438bc9c5bc86c90d36e79ef89be9db", "contributor_occupation": "", "filing_id": "", "contributor_city": "NIKISKI", "recipient_state_held": "", "district_held": "", "recipient_name": "WARD, JERRY", "organization_ext_id": "", "contributor_zipcode": "99635", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-07-25", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "WARD, JERRY", "contributor_type": "", "contributor_employer": "", "seat_result": "L", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""},
+{"seat": "state:upper", "committee_ext_id": "", "seat_held": "", "recipient_party": "R", "recipient_type": "P", "seat_status": "", "recipient_state": "AK", "contributor_category": "Z9010", "contributor_gender": "", "contributor_state": "AK", "recipient_category": "", "is_amendment": false, "district": "", "organization_name": "", "recipient_ext_id": "139048", "parent_organization_name": "", "contributor_address": "2207 SPENARD RD STE 100", "transaction_id": "613e3cc3b2758324c597d7f37bc976ff", "contributor_occupation": "", "filing_id": "", "contributor_city": "ANCHORAGE", "recipient_state_held": "", "district_held": "", "recipient_name": "WORTHEN, TIM", "organization_ext_id": "", "contributor_zipcode": "99503", "transaction_namespace": "urn:nimsp:transaction", "date": "2002-09-05", "committee_name": "", "candidacy_status": true, "parent_organization_ext_id": "", "cycle": 2002, "contributor_name": "WORTHEN, TIMOTHY J", "contributor_type": "", "contributor_employer": "", "seat_result": "L", "transaction_type": "", "amount": "10000.00", "contributor_ext_id": "", "committee_party": ""}
+
+]
View
7 spec/fixtures/transparency_data/entities_search.response
@@ -0,0 +1,7 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Thu, 14 Apr 2011 18:55:36 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[{"name": "Nancy Pelosi (D)", "count_given": 0, "firm_income": 0.0, "count_lobbied": 0, "seat": "federal:house", "total_received": 12163810.0, "state": "CA", "lobbying_firm": null, "count_received": 9190, "party": "D", "total_given": 0.0, "type": "politician", "id": "85ab2e74589a414495d18cc7a9233981", "non_firm_spending": 0.0},{"name": "Nancy Pelosi for Congress", "count_given": 1133, "firm_income": 0.0, "count_lobbied": 0, "seat": null, "total_received": 0.0, "state": null, "lobbying_firm": false, "count_received": 0, "party": null, "total_given": 1538428.0, "type": "organization", "id": "afb432ec90454c8a83a3113061e7be27", "non_firm_spending": 0.0}]
View
7 spec/fixtures/transparency_data/entities_search_limit_0.response
@@ -0,0 +1,7 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Thu, 14 Apr 2011 18:55:36 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[]
View
7 spec/fixtures/transparency_data/entities_search_limit_1.response
@@ -0,0 +1,7 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Thu, 14 Apr 2011 18:55:36 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[{"name": "Nancy Pelosi (D)", "count_given": 0, "firm_income": 0.0, "count_lobbied": 0, "seat": "federal:house", "total_received": 12163810.0, "state": "CA", "lobbying_firm": null, "count_received": 9190, "party": "D", "total_given": 0.0, "type": "politician", "id": "85ab2e74589a414495d18cc7a9233981", "non_firm_spending": 0.0}]
View
7 spec/fixtures/transparency_data/grants_find_all.response
@@ -0,0 +1,7 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Tue, 12 Apr 2011 02:49:40 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[{"progsrc_acnt_code": "", "principal_place_state": "FLORIDA", "non_fed_funding_amount": 0, "rec_flag": false, "recipient_zip": "", "fiscal_year": 2011, "progsrc_subacnt_code": "", "record_type": "1", "cfda_program_num": "97.022", "ending_date": null, "recipient_type": "21", "transaction_status": "active", "principal_place_cc": "BROWARD", "face_loan_guran": 0, "principal_place_cd": "", "total_funding_amount": 8076597900, "orig_sub_guran": 0, "principal_place_code": "12**011", "agency_code": "7022", "recipient_county_code": "011", "assistance_type": "09", "uri": "12011,,,,,,,~1027938375201111", "recipient_country_code": "USA", "maj_agency_cat": "70", "starting_date": null, "imported_on": "2011-03-14", "duns_conf_code": "", "account_title": "", "project_description": "NATIONAL FLOOD INSURANCE PROGRAM", "recipient_city_code": "", "duns_no": "", "recipient_county_name": "BROWARD", "cfda_program_title": "FLOOD INSURANCE", "recip_cat_type": "i", "sai_number": "", "obligation_action_date": "2010-11-30", "fyq": "201102011", "progsrc_agen_code": "70", "federal_award_mod": "", "principal_place_state_code": "FL", "recipient_name": "MULTIPLE RECIPIENTS", "receip_addr2": "", "receip_addr3": "", "receip_addr1": "", "recipient_cd": "ZZ", "recipient_city_name": "", "federal_award_id": "", "fed_funding_amount": 0, "recipient_state_code": "FL", "unique_transaction_id": "891efe71ebbb7d34b827bdce16cf9b71", "agency_name": "FEDERAL EMERGENCY MANAGEMENT AGENCY", "principal_place_zip": "", "fyq_correction": "", "action_type": "", "correction_late_ind": "", "asst_cat_type": "i"},{"progsrc_acnt_code": "0512", "principal_place_state": "NEW YORK", "non_fed_funding_amount": 0, "rec_flag": false, "recipient_zip": "12237", "fiscal_year": 2011, "progsrc_subacnt_code": "", "record_type": "2", "cfda_program_num": "93.778", "ending_date": "2010-12-31", "recipient_type": "00", "transaction_status": "active", "principal_place_cc": "ALBANY", "face_loan_guran": 0, "principal_place_cd": "22", "total_funding_amount": 7223838000, "orig_sub_guran": 0, "principal_place_code": "", "agency_code": "7530", "recipient_county_code": "001", "assistance_type": "03", "uri": "75-227-NY20111-1-1-2011-93778-75-0512-NON", "recipient_country_code": "USA", "maj_agency_cat": "75", "starting_date": "2010-10-01", "imported_on": "2011-03-14", "duns_conf_code": "", "account_title": "Grants to States for Medicaid", "project_description": "MEDICAID ENTITLEMENT FOR NEW YORK - FY 2011 QUARTER 1 - T19", "recipient_city_code": "01000", "duns_no": "806781340", "recipient_county_name": "Albany", "cfda_program_title": "Medical Assistance Program (Medicaid)", "recip_cat_type": "g", "sai_number": "SAI UNAVAILABLE", "obligation_action_date": "2010-10-01", "fyq": "201010291", "progsrc_agen_code": "75", "federal_award_mod": "1", "principal_place_state_code": "NY", "recipient_name": "NY ST DEPT OF HEALTH", "receip_addr2": "", "receip_addr3": "", "receip_addr1": "GNARESP CORNING TWR RM 1395", "recipient_cd": "NY21", "recipient_city_name": "ALBANY", "federal_award_id": "NY20111", "fed_funding_amount": 7223838000, "recipient_state_code": "NY", "unique_transaction_id": "679fd2b6b204328bc7e0811892809399", "agency_name": "DEPARTMENT OF HEALTH AND HUMAN SERVICES", "principal_place_zip": "0", "fyq_correction": "", "action_type": "A", "correction_late_ind": "", "asst_cat_type": "g"},{"progsrc_acnt_code": "0512", "principal_place_state": "NEW YORK", "non_fed_funding_amount": 0, "rec_flag": false, "recipient_zip": "12237", "fiscal_year": 2011, "progsrc_subacnt_code": "", "record_type": "2", "cfda_program_num": "93.778", "ending_date": "2011-03-31", "recipient_type": "00", "transaction_status": "active", "principal_place_cc": "ALBANY", "face_loan_guran": 0, "principal_place_cd": "22", "total_funding_amount": 6907531000, "orig_sub_guran": 0, "principal_place_code": "", "agency_code": "7530", "recipient_county_code": "001", "assistance_type": "03", "uri": "75-227-NY20112-0-1-2011-93778-75-0512-NON", "recipient_country_code": "USA", "maj_agency_cat": "75", "starting_date": "2011-01-01", "imported_on": "2011-03-14", "duns_conf_code": "", "account_title": "Grants to States for Medicaid", "project_description": "MEDICAID ENTITLEMENT FOR NEW YORK - FY 2011 QUARTER 2 - T19", "recipient_city_code": "01000", "duns_no": "806781340", "recipient_county_name": "Albany", "cfda_program_title": "Medical Assistance Program (Medicaid)", "recip_cat_type": "g", "sai_number": "SAI UNAVAILABLE", "obligation_action_date": "2011-01-01", "fyq": "201101211", "progsrc_agen_code": "75", "federal_award_mod": "0", "principal_place_state_code": "NY", "recipient_name": "NY ST DEPT OF HEALTH", "receip_addr2": "", "receip_addr3": "", "receip_addr1": "GNARESP CORNING TWR RM 1395", "recipient_cd": "NY21", "recipient_city_name": "ALBANY", "federal_award_id": "NY20112", "fed_funding_amount": 6907531000, "recipient_state_code": "NY", "unique_transaction_id": "9cf4728d045d93efdebf720476b8109d", "agency_name": "DEPARTMENT OF HEALTH AND HUMAN SERVICES", "principal_place_zip": "0", "fyq_correction": "", "action_type": "A", "correction_late_ind": "", "asst_cat_type": "g"}]
View
7 spec/fixtures/transparency_data/lobbyists_find_all.response
@@ -0,0 +1,7 @@
+HTTP/1.1 200 OK
+Server: nginx/0.7.67
+Date: Mon, 11 Apr 2011 23:02:23 GMT
+Content-Type: application/json; charset=utf-8
+Connection: keep-alive
+
+[{"registrant_name": "Brookfield Atlantic", "filing_type": "p", "client_category": "C5130", "client_name": "Brookfield Atlantic", "agencies": [{"agency_name": "Central Intelligence Agency", "agency_ext_id": "044 "}, {"agency_name": "Def Advanced Research Projects Agency", "agency_ext_id": "116 "}, {"agency_name": "Defense Business Transformation Agency", "agency_ext_id": "248 "}, {"agency_name": "Dept of Defense", "agency_ext_id": "025 "}, {"agency_name": "Dept of Navy", "agency_ext_id": "031 "}, {"agency_name": "Economic Development Administration", "agency_ext_id": "108 "}, {"agency_name": "Executive Office of the President", "agency_ext_id": "011 "}, {"agency_name": "National Geospatial-Intelligence Agency", "agency_ext_id": "126 "}, {"agency_name": "National Security Agency", "agency_ext_id": "127 "}, {"agency_name": "National Security Council", "agency_ext_id": "016 "}, {"agency_name": "Office of Director of Natl Intelligence", "agency_ext_id": "214 "}, {"agency_name": "US House of Representatives", "agency_ext_id": "002 "}, {"agency_name": "US Marine Corps", "agency_ext_id": "210 "}, {"agency_name": "US Senate", "agency_ext_id": "001 "}, {"agency_name": "White House", "agency_ext_id": "012 "}], "client_ext_id": null, "transaction_type": "q4", "client_parent_name": "Brookfield Atlantic", "amount": "550000.00", "transaction_id": "19E29BE9-B5AC-4058-92C6-07DA9F64537C", "lobbyists": [{"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "Dunn, Jennifer B", "lobbyist_ext_id": "Y00000403020"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "Montgomery, Wayne", "lobbyist_ext_id": "Y00000349490"}], "year": 2011, "transaction_type_desc": "FOURTH QUARTER REPORT", "registrant_is_firm": false, "issues": [{"specific_issue": "Lobbied the US Department of Defense to take over major US defense projects (R&D) that can not be completed with U.S. Public funds due to deficit reduction as well the firm lobbied the NSA & CIA to sell stakes and interest in major satellite programs.", "general_issue": "Defense", "general_issue_code": "DEF"}]},{"registrant_name": "Quantico North NFP Ltd", "filing_type": "p", "client_category": "g5270", "client_name": "Quantico North NFP Ltd", "agencies": [{"agency_name": "Dept of State", "agency_ext_id": "039 "}, {"agency_name": "National Security Agency", "agency_ext_id": "127 "}, {"agency_name": "National Security Council", "agency_ext_id": "016 "}, {"agency_name": "Overseas Private Investment Corporation", "agency_ext_id": "203 "}, {"agency_name": "US House of Representatives", "agency_ext_id": "002 "}, {"agency_name": "US Senate", "agency_ext_id": "001 "}], "client_ext_id": null, "transaction_type": "q4", "client_parent_name": "Quantico North NFP Ltd", "amount": "350000.00", "transaction_id": "FF564278-5E5C-430C-92C7-8E0175299951", "lobbyists": [{"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "Montgomery, Wayne", "lobbyist_ext_id": "Y00000349490"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "North, Lucas", "lobbyist_ext_id": "Y00000448080"}], "year": 2011, "transaction_type_desc": "FOURTH QUARTER REPORT", "registrant_is_firm": false, "issues": [{"specific_issue": "Intelligence & Surveillance , Nuclear Energy , Defense", "general_issue": "Foreign Relations", "general_issue_code": "FOR"}]},{"registrant_name": "Frontier Communications", "filing_type": "p", "client_category": "C4100", "client_name": "Frontier Communications", "agencies": [{"agency_name": "Federal Communications Commission", "agency_ext_id": "053 "}, {"agency_name": "US House of Representatives", "agency_ext_id": "002 "}, {"agency_name": "US Senate", "agency_ext_id": "001 "}], "client_ext_id": null, "transaction_type": "q4", "client_parent_name": "Frontier Communications", "amount": "175000.00", "transaction_id": "22D92EAB-1ABD-4D86-BEF1-32E4DB543F63", "lobbyists": [{"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "Schneider, Jennifer", "lobbyist_ext_id": "Y00000448510"}], "year": 2011, "transaction_type_desc": "FOURTH QUARTER REPORT", "registrant_is_firm": false, "issues": [{"specific_issue": "House and Senate: H.R. 1409 - Employee Free Choice Act of 2009; Tax Reform; monitored general telecommunications, USF, and rural broadband issues. \nFCC: Open Internet Proceeding; Role of the Universal Service Fund and Intercarrier Compensation in the National Broadband Plan; other FCC-related matters.", "general_issue": "Telecommunications", "general_issue_code": "TEC"}]},{"registrant_name": "Capitol Tax Partners", "filing_type": "n", "client_category": "E1500", "client_name": "Clean Coal Solutions", "agencies": [{"agency_name": "Dept of Treasury", "agency_ext_id": "041 "}, {"agency_name": "US House of Representatives", "agency_ext_id": "002 "}, {"agency_name": "US Senate", "agency_ext_id": "001 "}], "client_ext_id": null, "transaction_type": "q1t", "client_parent_name": "Clean Coal Solutions", "amount": "150000.00", "transaction_id": "D5B896AE-6AB5-475A-8992-5042E98BD554", "lobbyists": [{"member_of_congress": false, "candidate_ext_id": null, "government_position": "Deputy Chief of Staff, JCT", "lobbyist_name": "Grafmeyer, Richard", "lobbyist_ext_id": "Y00000316380"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": null, "lobbyist_name": "Hooper, Lindsay D", "lobbyist_ext_id": "Y00000053811"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Tax Counsel, Sen. Grassley, Sen. Finance Comm.", "lobbyist_name": "Javens, Chris L", "lobbyist_ext_id": "Y00000021000"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Staff Director, Ways & Means Over Sub", "lobbyist_name": "McKenney, William", "lobbyist_ext_id": "Y00000318210"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Tax Legislative Counsel - US Treasury", "lobbyist_name": "Mikrut, Joseph", "lobbyist_ext_id": "Y00000186820"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Assistant Treasury Secretary for Tax Policy", "lobbyist_name": "Talisman, Jonathan", "lobbyist_ext_id": "Y00000204320"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Staff Director, Senate Republican Policy Committee", "lobbyist_name": "Willcox, Lawrence G", "lobbyist_ext_id": "Y00000236600"}], "year": 2011, "transaction_type_desc": "FIRST QUARTER TERMINATION", "registrant_is_firm": true, "issues": [{"specific_issue": "Legislative and regulatory services related to the tax treatment of refined coal including: H.R. 4213, the Tax Extenders Act of 2009; S. 2826, the Clean Renewable Energy Advancement Tax Extension Jobs Act of 2009; S. 3793, the Job Creation and Tax Cuts Act; H.R. 5893, the Investing in American Jobs and Closing Tax Loopholes Act of 2010; H.R. 4853, the Tax Relief, Unemployment Insurance Reauthorization, and Job Creation Act of 2010; H.R. 6467, the Middle Class Tax Relief Act of 2010; and S. 3793, the Job Creation and Tax Cuts Act.", "general_issue": "Taxes", "general_issue_code": "TAX"}]},{"registrant_name": "YMCA of the USA", "filing_type": "p", "client_category": "x4000", "client_name": "YMCA of the USA", "agencies": [{"agency_name": "Centers for Disease Control & Prevention", "agency_ext_id": "134 "}, {"agency_name": "Consumer Product Safety Commission", "agency_ext_id": "046 "}, {"agency_name": "Dept of Education", "agency_ext_id": "032 "}, {"agency_name": "Dept of Health & Human Services", "agency_ext_id": "034 "}, {"agency_name": "Dept of Interior", "agency_ext_id": "036 "}, {"agency_name": "Dept of Justice", "agency_ext_id": "037 "}, {"agency_name": "Dept of Labor", "agency_ext_id": "038 "}, {"agency_name": "Executive Office of the President", "agency_ext_id": "011 "}, {"agency_name": "Faith-Based & Community Inititiatives", "agency_ext_id": "202 "}, {"agency_name": "Federal Bureau of Investigation", "agency_ext_id": "150 "}, {"agency_name": "Forest Service", "agency_ext_id": "212 "}, {"agency_name": "Internal Revenue Service", "agency_ext_id": "188 "}, {"agency_name": "National Park Service", "agency_ext_id": "143 "}, {"agency_name": "US House of Representatives", "agency_ext_id": "002 "}, {"agency_name": "US Senate", "agency_ext_id": "001 "}], "client_ext_id": null, "transaction_type": "q4", "client_parent_name": "YMCA of the USA", "amount": "100000.00", "transaction_id": "AB859B94-F1A8-4614-B510-AC735496B4F1", "lobbyists": [{"member_of_congress": false, "candidate_ext_id": null, "government_position": "Fmr. L.D. Rep. Sanders (D-VT)", "lobbyist_name": "Adamson, Katie", "lobbyist_ext_id": "Y00000040250"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Fmr. Dep. Chief of Staff. Sen. Moynihan (D-NY)", "lobbyist_name": "Bland, Richard", "lobbyist_ext_id": "Y00000112190"}, {"member_of_congress": false, "candidate_ext_id": null, "government_position": "Fmr. Chief of Staff, Wife of VP Gore, Tipper Gore", "lobbyist_name": "Haynes, Audrey", "lobbyist_ext_id": "Y0000040744@"}], "year": 2011, "transaction_type_desc": "FOURTH QUARTER REPORT", "registrant_is_firm": false, "issues": [{"specific_issue": "- Extension of the IRA Rollover Charitable Tax Incentive \n-- other provisions relating to nonprofit organizations and tax incentives for charitable giving", "general_issue": "Taxes", "general_issue_code": "TAX"}, {"specific_issue": "Prevention and wellness provisions/regulations in the Patient Protection and Affordable Care Act -- like prevention fund, task force and strategy; as well as Employer Mandate and small Employer Tax Credit", "general_issue": "Health Issues", "general_issue_code": "HCR"}, {"specific_issue": "Interpretation of federal regulations on public pools through the Virginia Graeme Baker Act of 2007, as interpreted and regulated through the Consumer Product Safety Commission.\nInterpretation and guidance on CPSC ban of \"drop-side\" cribs.", "general_issue": "Health Issues", "general_issue_code": "HCR"}, {"specific_issue": "-Efforts to promote YMCA solutions to childhood obesity\n-Efforts to promote YMCA solutions to child care needs and after school needs in US.", "general_issue": "Health Issues", "general_issue_code": "HCR"}, {"specific_issue": "-- Support for the Child Protection Improvements Act of 2009, (The Background Checks Bill) to improve and provide funding for federal background checks for youth serving organizations", "general_issue": "Health Issues", "general_issue_code": "HCR"}, {"specific_issue": "- New Partnerships with the US Forest Service (a subdivision of the USDA) and the US Park Service (a subdivision of the Dept. of Interior) to increase overall public health through physical activity and access to public lands\n- Premitting requirements for YMCA Camps: to have access to Forest Service and Park Service lands through favorable regulations towards nonprofit camps like the YMCA that promote stewardship of the land and give financial assistance", "general_issue": "Health Issues", "general_issue_code": "HCR"}, {"specific_issue": "-Support for legislation that promoted increased physical activity for children, before, during and after school\n-Support for legislation that promotes increased physical activity, better nutrition and healthy living for all adults.\n-Elementary and Seconday Education Act (ESEA) aka No Child Left Behind Legislation Reauthorization (NCLB)- with a focus on promoting health and wellbeing through nutrition and physical activity for children", "general_issue": "Education", "general_issue_code": "EDU"}, {"specific_issue": "FY'11 Labor/HHS/Education Appropriations - provisions related to afterschool, child care, disease prevention and health promotion\nFY'11 Commerce/Justice/Science Appropriations - provisions related to juvenile delinquincy prevention and gang prevention programs", "general_issue": "Fed Budget & Appropriations", "general_issue_code": "BUD"}]}]
View
10 spec/follow_the_money_spec.rb
@@ -1,5 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+# Provides "String.singularize"
+# which is used by resource_for_collection, in resource.rb
+require 'active_support/inflector'
+
module GovKit::FollowTheMoney
describe GovKit::FollowTheMoney do
@@ -25,10 +29,10 @@ module GovKit::FollowTheMoney
end
end
- it "should raise NotAuthorizedError if the api key is not valid" do
+ it "should raise NotAuthorized if the api key is not valid" do
lambda do
@contribution = Contribution.find(0)
- end.should raise_error(GovKit::NotAuthorizedError)
+ end.should raise_error(GovKit::NotAuthorized)
@contribution.should be_nil
end
@@ -54,4 +58,4 @@ module GovKit::FollowTheMoney
end
end
-end
+end
View
123 spec/open_states_spec.rb
@@ -1,37 +1,76 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+# Provides "String.singularize"
+# which is used by resource_for_collection, in resource.rb
+require 'active_support/inflector'
+
+# Provides string.last()
+# which is used by method_missing in resource.rb
+require 'active_support/core_ext/string'
+
module GovKit::OpenStates
describe GovKit::OpenStates do
before(:all) do
base_uri = GovKit::OpenStatesResource.base_uri.gsub(/\./, '\.')
+ # An array of uris and filenames
+ # Use FakeWeb to intercept net requests;
+ # if a requested uri matches one of the following,
+ # then return the contents of the corresponding file
+ # as the result.
urls = [
- ['/ca/\?', 'state.response'],
- ['/bills/ca/20092010/AB667/', 'bill.response'],
- ['/bills/search/\?', 'bill_query.response'],
+ ['/bills/ca/20092010/AB667/', 'bill.response'],
+ ['/bills/\?', 'bill_query.response'],
['/bills/latest/\?', 'bill_query.response'],
['/legislators/2462/\?', 'legislator.response'],
['/legislators/410/\?', '410.response'],
['/legislators/401/\?', '401.response'],
- ['/legislators/search/\?', 'legislator_query.response']
+ ['/legislators/404/\?', '404.response'],
+ ['/legislators/\?.*state=zz.*', '404.response'],
+ ['/legislators/\?.*state=ca.*', 'legislator.response'],
+ ['/committees/MDC000012/', 'committee_find.response'],
+ ['/committees/\?.*state=md', 'committee_query.response'],
+ ['/metadata/ca/\?', 'state.response']
]
+ # First convert each of the uri strings above into regexp's before
+ # passing them on to register_uri.
+ #
+ # Internally, before checking if a new uri string matches one of the registered uri's,
+ # FakeWeb normalizes it by parsing it with URI.parse(string), and then
+ # calling URI.normalize on the resulting URI. This appears to reorder any
+ # query parameters alphabetically by key.
+ #
+ # So the uri
+ # http://openstates.sunlightlabs.com/api/v1/legislators/?state=zz&output=json&apikey=
+ # would actually not match a registered uri of
+ # ['/legislators/\?state=zz', '404.response'],
+ # or
+ # ['/legislators/\?state=zz*', '404.response'],
+ # or even
+ # ['/legislators/\?state=zz&output=json&apikey=', '404.response'],
+ #
+ # But it would match a registered uri of
+ # ['/legislators/\?apikey=&output=json&state=zz', '404.response'],
+ # or
+ # ['/legislators/\?(.*)state=zz(.*)', '404.response'],
+
+
urls.each do |u|
FakeWeb.register_uri(:get, %r|#{base_uri}#{u[0]}|, :response => File.join(FIXTURES_DIR, 'open_states', u[1]))
end
end
it "should have the base uri set properly" do
[State, Bill, Legislator].each do |klass|
- klass.base_uri.should == "http://fiftystates-dev.sunlightlabs.com/api"
+ klass.base_uri.should == "http://openstates.sunlightlabs.com/api/v1"
end
end
- it "should raise NotAuthorizedError if the api key is not valid" do
- # The Open States API returns a 401 Not Authorized if the API key is invalid.
+ it "should raise NotAuthorized if the api key is not valid" do
lambda do
@legislator = Legislator.find(401)
- end.should raise_error(GovKit::NotAuthorizedError)
+ end.should raise_error(GovKit::NotAuthorized)
@legislator.should be_nil
end
@@ -43,9 +82,13 @@ module GovKit::OpenStates
it "should find a state by abbreviation" do
lambda do
- @state = State.find_by_abbreviation('ca')
+ @states = State.find_by_abbreviation('ca')
end.should_not raise_error
+ @states.should be_an_instance_of(Array)
+ @states.length.should eql(1)
+ @state = @states[0]
+
@state.should be_an_instance_of(State)
@state.name.should == "California"
@state.sessions.size.should == 8
@@ -55,11 +98,15 @@ module GovKit::OpenStates
describe Bill do
context "#find" do
- it "should find a bill by stat abbreviation, session, chamber, bill_id" do
+ it "should find a bill by state abbreviation, session, chamber, bill_id" do
lambda do
- @bill = Bill.find('ca', 20092010, 'lower', 'AB667')
+ @bills = Bill.find('ca', '20092010', 'lower', 'AB667')
end.should_not raise_error
+ @bills.should be_an_instance_of(Array)
+ @bills.length.should eql(1)
+ @bill = @bills[0]
+
@bill.should be_an_instance_of(Bill)
@bill.title.should include("An act to amend Section 1750.1 of the Business and Professions Code, and to amend Section 104830 of")
end
@@ -80,7 +127,7 @@ module GovKit::OpenStates
context "#latest" do
it "should get the latest bills by given criteria" do
lambda do
- @latest = Bill.latest('2010-01-01','tx')
+ @latest = Bill.latest('2010-01-01', :state => 'tx')
end.should_not raise_error
@latest.should be_an_instance_of(Array)
@@ -96,20 +143,22 @@ module GovKit::OpenStates
context "#find" do
it "should find a specific legislator" do
lambda do
- @legislator = Legislator.find(2462)
+ @legislators = Legislator.find(2462)
end.should_not raise_error
+ @legislators.should be_an_instance_of(Array)
+ @legislators.length.should eql(1)
+ @legislator = @legislators[0]
+
@legislator.should be_an_instance_of(Legislator)
@legislator.first_name.should == "Dave"
@legislator.last_name.should == "Cox"
end
- it "should raise a GovKitError if the legislator is not found" do
- lambda do
- @legislator = Legislator.find(410)
- end.should raise_error(GovKit::ResourceNotFoundError)
+ it "should return an empty array if the legislator is not found" do
+ @legislator = Legislator.find(404)
- @legislator.should be_nil
+ @legislator.should eql([])
end
end
@@ -124,8 +173,46 @@ module GovKit::OpenStates
l.should be_an_instance_of(Legislator)
end
end
+
+ it "should return an empty array if no legislators are found" do
+ lambda do
+ @legislators = Legislator.search(:state => 'zz')
+ end.should_not raise_error
+
+ @legislators.should be_an_instance_of(Array)
+ @legislators.length.should eql(0)
+ end
end
end
+
+ describe Committee do
+ context "#find" do
+ it "should find a specific committee" do
+ lambda do
+ @committees = Committee.find( 'MDC000012' )
+ end.should_not raise_error
+
+ @committees.should be_an_instance_of(Array)
+ @committees.length.should eql(1)
+ com = @committees[0]
+ com.should be_an_instance_of(Committee)
+ com['id'].should eql('MDC000012')
+ end
+ end
+ context "#search" do
+ it "should return an array of committees" do
+ lambda do
+ @committees = Committee.search( :state => 'md', :chamber => 'upper' )
+ end.should_not raise_error
+
+ @committees.should be_an_instance_of(Array)
+ @committees.length.should eql(20)
+ com = @committees[0]
+ com.should be_an_instance_of(Committee)
+ com['id'].should eql('MDC000009')
+ end
+ end
+ end
end
end
View
6 spec/spec.opts
@@ -1,6 +0,0 @@
---colour
---format nested
---loadby
-mtime
---reverse
---backtrace
View
5 spec/spec_helper.rb
@@ -1,11 +1,10 @@
require 'rubygems'
-require 'spec'
+require 'rspec'
require 'fakeweb'
-require 'fakeweb_matcher'
require File.dirname(__FILE__) + '/../lib/govkit'
# prevent the use of `` in tests
-Spec::Runner.configure do |configuration|
+RSpec.configure do |c|
end
# When running specs in TextMate, provide an rputs method to cleanly print objects into HTML display
View
106 spec/transparency_data_spec.rb
@@ -0,0 +1,106 @@
+require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+
+# Provides "String.singularize"
+# which is used by resource_for_collection, in resource.rb
+require 'active_support/inflector'
+
+# Provides string.last()
+# which is used by method_missing in resource.rb
+require 'active_support/core_ext/string'
+
+module GovKit::TransparencyData
+
+ describe GovKit::TransparencyData do
+ before(:all) do
+ base_uri = GovKit::TransparencyDataResource.base_uri.gsub(/\./, '\.')
+
+ urls = [
+ ['/contributions.json\?', 'contributions.response'],
+ ['/lobbying.json\?', 'lobbyists_find_all.response'],
+ ['/grants.json\?', 'grants_find_all.response'],
+ ['/entities.json\?apikey=&search=$', 'entities_search.response'],
+ ['/entities.json\?apikey=&search=harry%20pelosi', 'entities_search_limit_0.response'],
+ ['/entities.json\?apikey=&search=nancy%2Bpelosi', 'entities_search_limit_1.response']
+ ]
+
+ urls.each do |u|
+ FakeWeb.register_uri(:get, %r|#{base_uri}#{u[0]}|, :response => File.join(FIXTURES_DIR, 'transparency_data', u[1]))
+ end
+ end
+
+ it "should have the base uri set properly" do
+ [Contribution, Entity].each do |klass|
+ klass.base_uri.should == 'http://transparencydata.com/api/1.0'
+ end
+ end
+ end
+
+ describe Contribution do
+ context "#search" do
+ it "should find all contributions" do
+ lambda do
+ @contributions = Contribution.search
+ end.should_not raise_error
+
+ @contributions.length.should eql(8)
+ @contributions[0].contributor_city.should eql("ANCHORAGE")
+ end
+ end
+ end
+
+ describe Entity do
+ context "#search" do
+ it "should find all entities" do
+ lambda do
+ @entities = Entity.search
+ end.should_not raise_error
+
+ @entities.length.should eql(2)
+ @entities[0].name.should eql("Nancy Pelosi (D)")
+ @entities[1].name.should eql("Nancy Pelosi for Congress")
+ end
+
+ it 'should return an empty list when no elements found' do
+ lambda do
+ @entities = Entity.search( "harry pelosi" )
+ end.should_not raise_error
+
+ @entities.length.should eql(0)
+ end
+ it 'should return a list when one element found' do
+ lambda do
+ @entities = Entity.search( "nancy+pelosi" )
+ end.should_not raise_error
+
+ @entities.length.should eql(1)
+ end
+ end
+ end
+
+ describe LobbyingRecord do
+ context "#search" do
+ it "should find all contributions" do
+ lambda do
+ @records = LobbyingRecord.search
+ end.should_not raise_error
+
+ @records.length.should eql(5)
+ @records[0].lobbyists[0].lobbyist_name.should eql('Dunn, Jennifer B')
+ end
+ end
+ end
+
+ describe Grant do
+ context "#search" do
+ it "should find all contributions" do
+ lambda do
+ @records = Grant.search
+ end.should_not raise_error
+
+ @records.length.should eql(3)
+ @records[0].project_description.should eql('NATIONAL FLOOD INSURANCE PROGRAM')
+ end
+ end
+ end
+end
+

0 comments on commit 801019c

Please sign in to comment.