myl-fech 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/fech/filing.rb +11 -1
- data/lib/fech/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -9,7 +9,7 @@ Fech makes it easy to parse electronic campaign finance filings[http://www.fec.g
|
|
9
9
|
|
10
10
|
NOTE: You're looking at the Make Your Laws fork of New York Times' Fech gem. It has bugfixes and features that NYT's doesn't. Take a look at the commit history / network graph.
|
11
11
|
|
12
|
-
Latest (myl-fech) version: 1.0.
|
12
|
+
Latest (myl-fech) version: 1.0.4
|
13
13
|
|
14
14
|
|
15
15
|
Fech is tested under Ruby versions 1.8.7, 1.9.2 and 1.9.3.
|
data/lib/fech/filing.rb
CHANGED
@@ -59,11 +59,21 @@ module Fech
|
|
59
59
|
# filing.download is of course unnecessary.
|
60
60
|
#
|
61
61
|
# note that if there are a lot of files (e.g. after download_all), just listing them to prepare for this will take several seconds
|
62
|
+
#
|
63
|
+
# Special option: :from => integer or :from => range will only process filing #s starting from / within the argument
|
62
64
|
def self.for_all options = {}
|
63
65
|
options[:download_dir] ||= Dir.tmpdir
|
66
|
+
from = options.delete :from
|
67
|
+
raise ArgumentError, ":from must be Integer or Range" if from and !(from.is_a?(Integer) or from.is_a?(Range))
|
64
68
|
# .sort{|x| x.scan/\d+/.to_i } # should be no need to spend time on sort, since the file system should already do that
|
65
69
|
Dir[File.join(options[:download_dir], '*.fec')].each do |file|
|
66
|
-
|
70
|
+
n = file.scan(/(\d+)\.fec/)[0][0].to_i
|
71
|
+
if from.is_a? Integer
|
72
|
+
next unless n >= from
|
73
|
+
elsif from.is_a? Range
|
74
|
+
next unless n.in? from
|
75
|
+
end
|
76
|
+
yield Fech::Filing.new(n, options)
|
67
77
|
end
|
68
78
|
end
|
69
79
|
|
data/lib/fech/version.rb
CHANGED