Is this the first comment?

11 views
Skip to first unread message

Tim Booher

unread,
May 30, 2011, 6:31:17 AM5/30/11
to govkit
In the absence of documentation that I can find, I am struggling with
getting the actual data.

bonhoffer:cba Tim$ rails c
Loading development environment (Rails 3.0.7)
ruby-1.9.2-p180 :001 > bills =
GovKit::OpenCongress::Bill.most_blogged_bills_this_week
=> [#<GovKit::OpenCongress::Bill:0x00000104163460>,
#<GovKit::OpenCongress::Bill:0x000001041614a8>,
#<GovKit::OpenCongress::Bill:0x0000010415fe50>,
#<GovKit::OpenCongress::Bill:0x0000010415da88>,
#<GovKit::OpenCongress::Bill:0x0000010415c278>,
#<GovKit::OpenCongress::Bill:0x0000010415aa40>,
#<GovKit::OpenCongress::Bill:0x00000104157e80>,
#<GovKit::OpenCongress::Bill:0x0000010414fb90>,
#<GovKit::OpenCongress::Bill:0x0000010414dd90>,
#<GovKit::OpenCongress::Bill:0x0000010414c738>]
ruby-1.9.2-p180 :002 > the_first_bill = bills.first
=> #<GovKit::OpenCongress::Bill:0x00000104163460>
ruby-1.9.2-p180 :003 > the_first_bill.inspect
=> "#<GovKit::OpenCongress::Bill:0x00000104163460>"
ruby-1.9.2-p180 :004 > the_first_bill.to_json
=> "{}"

Anything in there?

Any thoughts very appreciated.

Best,

Tim

Carl Tashian

unread,
Jun 1, 2011, 1:56:38 PM6/1/11
to govkit
Tim, do you have your API keys configured properly?
Here's what I see on my end:

$ rails c
Loading development environment (Rails 3.0.7)
ree-1.8.7-2011.03 :001 >
GovKit::OpenCongress::Bill.most_blogged_bills_this_week
=> [#<GovKit::OpenCongress::Bill:0x1051fb728
@last_vote_date=1306454160, @recent_news=[], @id=70461,
@last_speech=nil, @recent_blogs=[], @co_sponsors=[],
@last_vote_where=nil, @introduced=1305176400, @last_vote_roll=nil,
@number=990, @session=112, @bill_type="s",
@plain_language_summary="Four-year reauthorization of three
controversial government surveillance powers from the PATRIOT Act. The
powers include the authority for “roving” wiretaps that allows the
government to monitor computers that may occasionally be used by
suspected terrorists, the “tangible records provision” that requires
banks, telecoms and libraries to hand over any customer information
the government requests without being allows to inform the customer,
and the “lone wolf” provision allowing the government to track
terrorists acting independently of any foreign power or
organization.">, #<GovKit::OpenCongress::Bill:0x1051d0258
@last_vote_date=nil, @recent_news=[], @id=70848, @last_speech=nil,
@recent_blogs=[], @co_sponsors=[], @last_vote_where=nil,
@introduced=1306386000, @last_vote_roll=nil, @number=2017,
@session=112, @bill_type="h", @plain_language_summary=nil>,
#<GovKit::OpenCongress::Bill:0x1051a4d88 @last_vote_date=1306883460,
@recent_news=[], @id=70580, @last_speech=nil, @recent_blogs=[],
@co_sponsors=[], ......

Carl

Tim Booher

unread,
Jun 11, 2011, 8:43:57 AM6/11/11
to govkit
carl,

my api key tests well directly with the api.

do you have any troubleshooting ideas?

tim

Tim Booher

unread,
Jun 11, 2011, 10:52:45 PM6/11/11
to govkit
carl,

o.k. JSON.parse('{"hello":"world"}') -> {"hello"=>"world"}

using ruby 1.9.2 and json (1.5.1) json_pure (1.5.1).

the way your code is written, it assumes keys are symbols and the
line:

instance_variable_set("@#{key}", value) if
Bill.instance_methods.include? key

Will always fail.

I changed this in my fork to get:

instance_variable_set("@#{key}", value) if
Bill.instance_methods.include? key.to_sym

Now everything works.

Best,

Tim

(my code is at: https://github.com/tbbooher/govkit)

Nathaniel Barnes

unread,
Jun 21, 2011, 9:58:27 PM6/21/11
to govkit
I noticed this too when I started working with govkit a day or two
ago. I assume the reason that it's parsing on strings instead of
symbols is because the instance_methods method returned an array of
strings in 1.8, whereas in 1.9 it returns an array of symbols.

I added the following line to the block before the
instance_variable_set call:
key = key.to_sym if RUBY_VERSION[0,3] == "1.9"

I put that and a refactor with tests in my fork on github and opened a
pull request, it's issue #5. That should resolve the problem.
Reply all
Reply to author
Forward
0 new messages