federal_register 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/federal_register.gemspec +3 -3
- data/lib/federal_register/article.rb +13 -0
- data/lib/federal_register/base.rb +0 -2
- data/spec/article_spec.rb +8 -0
- metadata +96 -148
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/federal_register.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{federal_register}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew Carpenter"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2012-03-30}
|
13
13
|
s.description = %q{Ruby API Client for FederalRegister.gov that handles searching articles and getting information about agencies}
|
14
14
|
s.email = %q{andrew@criticaljuncture.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.homepage = %q{http://github.com/criticaljuncture/federal_register}
|
44
44
|
s.licenses = ["MIT"]
|
45
45
|
s.require_paths = ["lib"]
|
46
|
-
s.rubygems_version = %q{1.
|
46
|
+
s.rubygems_version = %q{1.7.2}
|
47
47
|
s.summary = %q{Ruby API Client for FederalRegister.gov}
|
48
48
|
|
49
49
|
if s.respond_to? :specification_version then
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class FederalRegister::Article < FederalRegister::Base
|
2
|
+
class InvalidDocumentNumber < ArgumentError; end
|
2
3
|
add_attribute :abstract,
|
3
4
|
:abstract_html_url,
|
4
5
|
:action,
|
@@ -17,6 +18,7 @@ class FederalRegister::Article < FederalRegister::Base
|
|
17
18
|
:pdf_url,
|
18
19
|
:regulation_id_numbers,
|
19
20
|
:start_page,
|
21
|
+
:subtype,
|
20
22
|
:title,
|
21
23
|
:type,
|
22
24
|
:volume
|
@@ -31,11 +33,14 @@ class FederalRegister::Article < FederalRegister::Base
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.find(document_number)
|
36
|
+
validate_document_number!(document_number)
|
34
37
|
attributes = get("/articles/#{document_number}.json")
|
35
38
|
new(attributes, :full => true)
|
36
39
|
end
|
37
40
|
|
38
41
|
def self.find_all(*document_numbers)
|
42
|
+
document_numbers = document_numbers.flatten
|
43
|
+
document_numbers.each {|doc_num| validate_document_number!(doc_num)}
|
39
44
|
result_set = FederalRegister::ResultSet.fetch("/articles/#{document_numbers.join(',')}.json", :result_class => self)
|
40
45
|
end
|
41
46
|
|
@@ -50,4 +55,12 @@ class FederalRegister::Article < FederalRegister::Base
|
|
50
55
|
self.class.get(send("#{file_type}_url")).body
|
51
56
|
end
|
52
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def self.validate_document_number!(document_number)
|
62
|
+
if document_number.blank? || document_number !~ /^[a-zA-Z0-9-]+$/
|
63
|
+
raise InvalidDocumentNumber.new("'#{document_number}' is not a valid FR Document Number")
|
64
|
+
end
|
65
|
+
end
|
53
66
|
end
|
data/spec/article_spec.rb
CHANGED
@@ -24,6 +24,10 @@ describe FederalRegister::Article do
|
|
24
24
|
)
|
25
25
|
lambda{ FederalRegister::Article.find(document_number) }.should raise_error FederalRegister::Client::RecordNotFound
|
26
26
|
end
|
27
|
+
|
28
|
+
it "throws an error when given an invalid document number" do
|
29
|
+
lambda{ FederalRegister::Article.find('an! invalid! document! number!') }.should raise_error FederalRegister::Article::InvalidDocumentNumber
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
describe ".find_all" do
|
@@ -37,6 +41,10 @@ describe FederalRegister::Article do
|
|
37
41
|
result_set = FederalRegister::Article.find_all('abc','def')
|
38
42
|
result_set.results.map(&:document_number).sort.should === ['abc','def']
|
39
43
|
end
|
44
|
+
|
45
|
+
it "throws an error when given an invalid document number" do
|
46
|
+
lambda{ FederalRegister::Article.find_all('123-456','an! invalid! document! number!') }.should raise_error FederalRegister::Article::InvalidDocumentNumber
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
describe ".search" do
|
metadata
CHANGED
@@ -1,169 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: federal_register
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
version: 0.4.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Andrew Carpenter
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-03-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &70208318603020 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 7
|
32
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 0.7.0
|
34
|
-
|
35
|
-
version_requirements: *id001
|
22
|
+
type: :runtime
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
24
|
+
version_requirements: *70208318603020
|
25
|
+
- !ruby/object:Gem::Dependency
|
48
26
|
name: shoulda
|
49
|
-
|
50
|
-
|
51
|
-
|
27
|
+
requirement: &70208318601540 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
52
33
|
type: :development
|
53
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70208318601540
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &70208318600540 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
40
|
+
requirements:
|
56
41
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 23
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 0
|
62
|
-
- 0
|
42
|
+
- !ruby/object:Gem::Version
|
63
43
|
version: 1.0.0
|
64
|
-
name: bundler
|
65
|
-
version_requirements: *id003
|
66
|
-
prerelease: false
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
44
|
type: :development
|
69
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70208318600540
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jeweler
|
49
|
+
requirement: &70208318599520 !ruby/object:Gem::Requirement
|
70
50
|
none: false
|
71
|
-
requirements:
|
51
|
+
requirements:
|
72
52
|
- - ~>
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
hash: 15
|
75
|
-
segments:
|
76
|
-
- 1
|
77
|
-
- 6
|
78
|
-
- 0
|
53
|
+
- !ruby/object:Gem::Version
|
79
54
|
version: 1.6.0
|
80
|
-
name: jeweler
|
81
|
-
version_requirements: *id004
|
82
|
-
prerelease: false
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
55
|
type: :development
|
85
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
hash: 3
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
version: "0"
|
94
|
-
name: rcov
|
95
|
-
version_requirements: *id005
|
96
56
|
prerelease: false
|
97
|
-
|
57
|
+
version_requirements: *70208318599520
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rcov
|
60
|
+
requirement: &70208318598420 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
98
66
|
type: :development
|
99
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70208318598420
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &70208318588640 !ruby/object:Gem::Requirement
|
100
72
|
none: false
|
101
|
-
requirements:
|
73
|
+
requirements:
|
102
74
|
- - ~>
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
segments:
|
106
|
-
- 2
|
107
|
-
- 6
|
108
|
-
version: "2.6"
|
109
|
-
name: rspec
|
110
|
-
version_requirements: *id006
|
111
|
-
prerelease: false
|
112
|
-
- !ruby/object:Gem::Dependency
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.6'
|
113
77
|
type: :development
|
114
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70208318588640
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rspec
|
82
|
+
requirement: &70208318587660 !ruby/object:Gem::Requirement
|
115
83
|
none: false
|
116
|
-
requirements:
|
84
|
+
requirements:
|
117
85
|
- - ~>
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
segments:
|
121
|
-
- 2
|
122
|
-
- 6
|
123
|
-
version: "2.6"
|
124
|
-
name: rspec
|
125
|
-
version_requirements: *id007
|
126
|
-
prerelease: false
|
127
|
-
- !ruby/object:Gem::Dependency
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.6'
|
128
88
|
type: :development
|
129
|
-
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70208318587660
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: activesupport
|
93
|
+
requirement: &70208318586740 !ruby/object:Gem::Requirement
|
130
94
|
none: false
|
131
|
-
requirements:
|
95
|
+
requirements:
|
132
96
|
- - ~>
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
segments:
|
136
|
-
- 3
|
137
|
-
version: "3"
|
138
|
-
name: activesupport
|
139
|
-
version_requirements: *id008
|
140
|
-
prerelease: false
|
141
|
-
- !ruby/object:Gem::Dependency
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3'
|
142
99
|
type: :development
|
143
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70208318586740
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: fakeweb
|
104
|
+
requirement: &70208318586020 !ruby/object:Gem::Requirement
|
144
105
|
none: false
|
145
|
-
requirements:
|
106
|
+
requirements:
|
146
107
|
- - ~>
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
hash: 27
|
149
|
-
segments:
|
150
|
-
- 1
|
151
|
-
- 3
|
152
|
-
- 0
|
108
|
+
- !ruby/object:Gem::Version
|
153
109
|
version: 1.3.0
|
154
|
-
|
155
|
-
version_requirements: *id009
|
110
|
+
type: :development
|
156
111
|
prerelease: false
|
157
|
-
|
112
|
+
version_requirements: *70208318586020
|
113
|
+
description: Ruby API Client for FederalRegister.gov that handles searching articles
|
114
|
+
and getting information about agencies
|
158
115
|
email: andrew@criticaljuncture.org
|
159
116
|
executables: []
|
160
|
-
|
161
117
|
extensions: []
|
162
|
-
|
163
|
-
extra_rdoc_files:
|
118
|
+
extra_rdoc_files:
|
164
119
|
- LICENSE.txt
|
165
120
|
- README.rdoc
|
166
|
-
files:
|
121
|
+
files:
|
167
122
|
- .document
|
168
123
|
- .watchr
|
169
124
|
- Gemfile
|
@@ -186,39 +141,32 @@ files:
|
|
186
141
|
- spec/public_inspection_document_spec.rb
|
187
142
|
- spec/result_set_spec.rb
|
188
143
|
- spec/spec_helper.rb
|
189
|
-
has_rdoc: true
|
190
144
|
homepage: http://github.com/criticaljuncture/federal_register
|
191
|
-
licenses:
|
145
|
+
licenses:
|
192
146
|
- MIT
|
193
147
|
post_install_message:
|
194
148
|
rdoc_options: []
|
195
|
-
|
196
|
-
require_paths:
|
149
|
+
require_paths:
|
197
150
|
- lib
|
198
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
152
|
none: false
|
200
|
-
requirements:
|
201
|
-
- -
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
|
204
|
-
segments:
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
segments:
|
205
158
|
- 0
|
206
|
-
|
207
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
hash: -1815142448098795316
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
161
|
none: false
|
209
|
-
requirements:
|
210
|
-
- -
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
|
213
|
-
segments:
|
214
|
-
- 0
|
215
|
-
version: "0"
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
216
166
|
requirements: []
|
217
|
-
|
218
167
|
rubyforge_project:
|
219
|
-
rubygems_version: 1.
|
168
|
+
rubygems_version: 1.7.2
|
220
169
|
signing_key:
|
221
170
|
specification_version: 3
|
222
171
|
summary: Ruby API Client for FederalRegister.gov
|
223
172
|
test_files: []
|
224
|
-
|