campaign_cash 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/lib/campaign_cash/base.rb +7 -0
- data/lib/campaign_cash/independent_expenditure.rb +1 -1
- data/lib/campaign_cash/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -12,6 +12,8 @@ Simple ruby wrapper for The New York Times Campaign Finance API[http://developer
|
|
12
12
|
|
13
13
|
== News
|
14
14
|
|
15
|
+
* Jan. 18, 2012: Version 2.0.4 released. Bugfix to handle offsets better.
|
16
|
+
* Jan. 14, 2012: Version 2.0.3 released. Bugfix so that President.detail returns 1 object, not an array.
|
15
17
|
* Jan. 13, 2012: Version 2.0.2 released. Bugfix to set offset=nil as default.
|
16
18
|
* Jan. 11, 2012: Version 2.0.1 released. Bugfix for some attributes on Filing class.
|
17
19
|
|
data/lib/campaign_cash/base.rb
CHANGED
@@ -59,6 +59,10 @@ module CampaignCash
|
|
59
59
|
def cycle_from_date(date=Date.today)
|
60
60
|
date.year.even? ? date.year : date.year+1
|
61
61
|
end
|
62
|
+
|
63
|
+
def check_offset(offset)
|
64
|
+
raise "Offset must be a multiple of 20" if offset % 20 != 0
|
65
|
+
end
|
62
66
|
|
63
67
|
##
|
64
68
|
# Builds a request URI to call the API server
|
@@ -75,6 +79,9 @@ module CampaignCash
|
|
75
79
|
end
|
76
80
|
|
77
81
|
full_params = params.merge 'api-key' => @@api_key
|
82
|
+
full_params.delete_if {|k,v| v.nil?}
|
83
|
+
|
84
|
+
check_offset(params[:offset]) if params[:offset]
|
78
85
|
|
79
86
|
uri = build_request_url(path, full_params)
|
80
87
|
|
@@ -34,7 +34,7 @@ module CampaignCash
|
|
34
34
|
def self.date(date,offset=nil)
|
35
35
|
d = Date.strptime(date, '%m/%d/%Y')
|
36
36
|
cycle = cycle_from_date(d)
|
37
|
-
reply = Base.invoke("#{cycle}/independent_expenditures/#{d.year}/#{d.month}/#{d.day}",{:offset => offset})
|
37
|
+
reply = Base.invoke("#{cycle}/independent_expenditures/#{d.year}/#{d.month}/#{d.day}", {:offset => offset})
|
38
38
|
results = reply['results']
|
39
39
|
results.map{|c| IndependentExpenditure.create(c)}
|
40
40
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campaign_cash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 4
|
10
|
+
version: 2.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Derek Willis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-18 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|