Permalink
Browse files

Person abstraction now initializes from OpenCongress and pulls contri…

…butions from TransparencyData
  • Loading branch information...
1 parent 041ad2a commit 0a0cced19a28f5d49ce4bfa2b6b2cfa108971088 @NateBarnes committed May 6, 2012
Showing with 29 additions and 20 deletions.
  1. +1 −0 lib/gov_kit.rb
  2. +9 −7 lib/gov_kit/bill.rb
  3. +19 −13 lib/gov_kit/person.rb
View
@@ -22,6 +22,7 @@ module GovKit
autoload :FollowTheMoney, 'gov_kit/follow_the_money'
autoload :OpenCongress, 'gov_kit/open_congress'
autoload :SearchEngines, 'gov_kit/search_engines'
+ autoload :Person, "gov_kit/person"
# Convenience class to represent a news story or blog post.
# Used by GovKit::SearchEngines classes.
View
@@ -1,11 +1,13 @@
-class Bill
- attr_accessor :bill_type, :id, :introduced, :last_speech, :last_vote_date, :last_vote_roll, :last_vote_where, :last_action, :number, :plain_language_summary, :session, :sponsor, :co_sponsors, :title_full_common, :status, :most_recent_actions, :bill_titles, :recent_blogs, :recent_news, :ident
+module GovKit
+ class Bill
+ attr_accessor :bill_type, :id, :introduced, :last_speech, :last_vote_date, :last_vote_roll, :last_vote_where, :last_action, :number, :plain_language_summary, :session, :sponsor, :co_sponsors, :title_full_common, :status, :most_recent_actions, :bill_titles, :recent_blogs, :recent_news, :ident
- def initialize
+ def initialize
- end
+ end
- def self.find
-
+ def self.find opts
+ GovKit::OpenCongress::Bill.find opts
+ end
end
-end
+end
View
@@ -1,18 +1,24 @@
-class Person
- attr_accessor :firstname, :lastname, :bioguideid, :birthday, :district, :email, :gender, :id, :metavid_id, :middlename,
- :name, :nickname, :osid, :party, :religion, :state, :title, :unaccented_name, :url, :user_approval,
- :youtube_id, :oc_user_comments, :oc_users_tracking, :abstains_percentage, :with_party_percentage, :recent_news,
- :recent_blogs, :person_stats, :contributions
+module GovKit
+ class Person
+ attr_accessor :firstname, :lastname, :bioguideid, :birthday, :district, :email, :gender, :id, :metavid_id, :middlename,
+ :name, :nickname, :osid, :party, :religion, :state, :title, :unaccented_name, :url, :user_approval,
+ :youtube_id, :oc_user_comments, :oc_users_tracking, :abstains_percentage, :with_party_percentage, :recent_news,
+ :recent_blogs, :person_stats, :contributions
- def initialize
+ def initialize
- end
+ end
- def self.find
-
- end
+ def self.find opts
+ s = self.new
+ oc_person = GovKit::OpenCongress::Person.find(opts).first
+ oc_person.instance_variables.each { |var| s.instance_variable_set(var, oc_person.send(var.to_s.delete "@")) }
+ s
+ end
- def contributions
-
+ def contributions
+ @contributions = GovKit::TransparencyData::Contribution.search( :recipient_ft => "#{firstname} #{lastname}" ) if @contributions.nil?
+ @contributions
+ end
end
-end
+end

0 comments on commit 0a0cced

Please sign in to comment.