Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec out more of the disclosure filings and lobbyists
- Loading branch information
Justin Palmer
committed
Jan 21, 2009
1 parent
f1df31f
commit 582d423
Showing
10 changed files
with
183 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'pp' | ||
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require File.join(dir, 'sunshine') | ||
|
||
Sunshine.api_key = File.read(File.join(dir, '..', '.sunlight_api_key')) | ||
|
||
pelosi = Sunshine::Legislator.find(:all, {:title => 'Rep'}) | ||
pelosi.each do |l| | ||
puts "#{l.full_name}: #{l.district}" | ||
end | ||
|
||
many_dudes = Sunshine::Legislator.search('smith') | ||
many_dudes.each do |score, leg| | ||
puts leg.full_name | ||
end | ||
|
||
zipdudes = Sunshine::Legislator.find_by_zipcode(97209) | ||
zipdudes.each do |dude| | ||
puts dude.full_name | ||
end | ||
|
||
democrats = Sunshine::Legislator.find(:all, :party => 'D') | ||
pp Sunshine::Legislator.find(:one, :firstname => 'nancy') | ||
|
||
legislators = Sunshine::Legislator.find_by_lat_long("36.234822", "-115.180664") | ||
legislators.each do |l| | ||
puts l.full_name | ||
end |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'pp' | ||
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require File.join(dir, 'sunshine') | ||
|
||
Sunshine.api_key = File.read(File.join(dir, '..', '.sunlight_api_key')) | ||
|
||
filing = Sunshine::DisclosureFiling.find('29D4D19E-CB7D-46D2-99F0-27FF15901A4C') | ||
filing.lobbyists.each do |lob| | ||
puts lob.full_name | ||
end | ||
|
||
filing = Sunshine::DisclosureFiling.find(:first, {:client_name => 'Sunlight Foundation'}) | ||
filing.client_contact_name | ||
#pp filing | ||
#pp filing.raw_data['client_contact_lastname'] | ||
puts "CONTACT NAME:#{filing.client_contact_name}" | ||
filing.lobbyists.each do |lob| | ||
puts "-- #{lob.full_name}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
module Sunshine | ||
class Lobbyist < Base | ||
|
||
exclude :firstname, :lastname | ||
|
||
# def self.search(names, year, threshold) | ||
# results = [] | ||
# year = year || Time.now.year | ||
# names = names.join(',') if names.is_a? Array | ||
# response = fetch('lobbyists.search', :name => names, :year => year, :threshold => threshold) | ||
# response['response']['results'].each do |item| | ||
# results << [item['result']['score'], initialize_one(item['result']['lobbyist'])] | ||
# end | ||
# results | ||
# end | ||
|
||
|
||
def full_name | ||
"#{firstname} #{lastname}" | ||
end | ||
|
||
def firstname | ||
@raw_data['firstname'].capitalize | ||
end | ||
|
||
def lastname | ||
@raw_data['lastname'].capitalize | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec/spec_helper' | ||
|
||
include Sunshine | ||
|
||
describe DisclosureFiling do | ||
before do | ||
@disclosure = DisclosureFiling.find("29D4D19E-CB7D-46D2-99F0-27FF15901A4C") | ||
end | ||
|
||
it "should find a disclosure when given an id" do | ||
@disclosure.should be_instance_of(DisclosureFiling) | ||
end | ||
|
||
it "should find a disclosure when given a client name" do | ||
disclosure = DisclosureFiling.find(:first, {:client_name => 'Sunlight Foundation'}) | ||
disclosure.should be_instance_of(DisclosureFiling) | ||
end | ||
|
||
it "should return nil if a client name and recipient name are both given" do | ||
disclosure = DisclosureFiling.find(:first, {:client_name => 'Sunlight Foundation', :recipient_name => 'Sunlight Foundation'}) | ||
disclosure.should_not be(nil) | ||
end | ||
|
||
it "should initialize lobbyists for a filing" do | ||
lobbyists = @disclosure.lobbyists | ||
lobbyists.first.should be_instance_of(Lobbyist) | ||
end | ||
|
||
it "should compose client contact name from firstname and lastname" do | ||
firstname = @disclosure.raw_data['client_contact_firstname'].capitalize | ||
lastname = @disclosure.raw_data['client_contact_lastname'].capitalize | ||
|
||
@disclosure.client_contact_name.should == "#{firstname} #{lastname}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec/spec_helper' | ||
|
||
describe Lobbyist do | ||
before do | ||
#@lobbyists.search('Sunlight Foundation') | ||
end | ||
|
||
it "should exclude firstname and lastname from instance" do | ||
@speaker.class.keys_to_exclude.should be(['firstname', 'lastname']) | ||
end | ||
end |