federal_register 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,6 +8,7 @@ For more information about the FederalRegister.gov API, see http://www.federalre
8
8
 
9
9
  FederalRegister::Article.find('2011-17721').title
10
10
  result_set = FederalRegister::Article.search(:conditions => {:term => "Accessibility"})
11
+ # or result_set = FederalRegister.find_all('2011-17721','2011-17722')
11
12
  result_set.count
12
13
  result_set.results.each do |article|
13
14
  puts "#{article.title} by #{article.agencies.map(&:name)}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{federal_register}
8
- s.version = "0.0.1"
8
+ s.version = "0.1.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{2011-08-01}
12
+ s.date = %q{2011-08-15}
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 = [
@@ -41,13 +41,14 @@ Gem::Specification.new do |s|
41
41
  s.homepage = %q{http://github.com/criticaljuncture/federal_register}
42
42
  s.licenses = ["MIT"]
43
43
  s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.6.2}
44
+ s.rubygems_version = %q{1.3.6}
45
45
  s.summary = %q{Ruby API Client for FederalRegister.gov}
46
46
 
47
47
  if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
49
  s.specification_version = 3
49
50
 
50
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
52
  s.add_runtime_dependency(%q<httparty>, [">= 0.7.0"])
52
53
  s.add_development_dependency(%q<shoulda>, [">= 0"])
53
54
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -33,6 +33,10 @@ class FederalRegister::Article < FederalRegister::Base
33
33
  attributes = get("/articles/#{document_number}.json")
34
34
  new(attributes, :full => true)
35
35
  end
36
+
37
+ def self.find_all(*document_numbers)
38
+ result_set = FederalRegister::ResultSet.fetch("/articles/#{document_numbers.join(',')}.json", :result_class => self)
39
+ end
36
40
 
37
41
  def agencies
38
42
  attributes["agencies"].map do |attr|
@@ -45,12 +49,4 @@ class FederalRegister::Article < FederalRegister::Base
45
49
  self.class.get(attributes["#{file_type}_url"]).body
46
50
  end
47
51
  end
48
-
49
- def full_text_xml
50
- self.class.get(full_text_xml_url).body
51
- end
52
-
53
- def full_text_xml
54
- self.class.get(full_text_xml_url).body
55
- end
56
- end
52
+ end
@@ -1,5 +1,5 @@
1
1
  class FederalRegister::ResultSet < FederalRegister::Client
2
- attr_reader :count, :total_pages, :results
2
+ attr_reader :count, :total_pages, :results, :errors
3
3
 
4
4
  def initialize(attributes, result_class)
5
5
  @result_class = result_class
@@ -9,6 +9,7 @@ class FederalRegister::ResultSet < FederalRegister::Client
9
9
 
10
10
  @prev_url = attributes['previous_page_url']
11
11
  @next_url = attributes['next_page_url']
12
+ @errors = attributes['errors']
12
13
  end
13
14
 
14
15
  def next
@@ -24,4 +25,4 @@ class FederalRegister::ResultSet < FederalRegister::Client
24
25
  response = get(url, options)
25
26
  new(response, result_class)
26
27
  end
27
- end
28
+ end
data/spec/agency_spec.rb CHANGED
@@ -5,37 +5,37 @@ describe FederalRegister::Agency do
5
5
  before(:each) do
6
6
  FakeWeb.register_uri(:get, "http://www.federalregister.gov/api/v1/agencies.json", :body => [{},{}].to_json, :content_type =>"text/json")
7
7
  end
8
-
8
+
9
9
  it "returns Agency objects" do
10
10
  agencies = FederalRegister::Agency.all
11
11
  agencies.each do |agency|
12
12
  agency.should be_an_instance_of(FederalRegister::Agency)
13
13
  end
14
14
  end
15
-
15
+
16
16
  it "returns multiple agencies" do
17
17
  agencies = FederalRegister::Agency.all
18
18
  agencies.count.should == 2
19
19
  end
20
20
  end
21
-
21
+
22
22
  describe "attribute loading" do
23
23
  before(:each) do
24
24
  @agency = FederalRegister::Agency.new({'name' => "Commerce Department", 'json_url' => "http://www.federalregister.gov/api/v1/agencies/1.json"})
25
25
  end
26
-
26
+
27
27
  describe "existing attribute" do
28
28
  it "reads the from the json hash if already there" do
29
29
  @agency.name.should == 'Commerce Department'
30
30
  end
31
31
  end
32
-
32
+
33
33
  describe "non-existent attributes" do
34
34
  it "should trigger an error" do
35
35
  lambda {@agency.non_existent_attribute}.should raise_error NoMethodError
36
36
  end
37
37
  end
38
-
38
+
39
39
  describe "missing attribute" do
40
40
  FakeWeb.register_uri(:get, "http://www.federalregister.gov/api/v1/agencies/1.json", :body => {:description => "Lorem ipsum"}.to_json, :content_type =>"text/json")
41
41
  it "should lazy-load from the json_url" do
@@ -44,7 +44,7 @@ describe FederalRegister::Agency do
44
44
  @agency.send(:attributes)['description'].should == "Lorem ipsum"
45
45
  end
46
46
  end
47
-
47
+
48
48
  describe "missing attribute when no full json" do
49
49
  it "should lazy-load from the json_url" do
50
50
  @agency = FederalRegister::Agency.new({'name' => "Commerce Department"})
@@ -52,4 +52,4 @@ describe FederalRegister::Agency do
52
52
  end
53
53
  end
54
54
  end
55
- end
55
+ end
data/spec/article_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe FederalRegister::Article do
4
4
  describe ".find" do
5
- it "should fetch the document by its document number" do
5
+ it "fetches the document by its document number" do
6
6
  document_number = "2010-213"
7
7
  FakeWeb.register_uri(
8
8
  :get,
@@ -10,11 +10,11 @@ describe FederalRegister::Article do
10
10
  :content_type =>"text/json",
11
11
  :body => {:title => "Important Notice"}.to_json
12
12
  )
13
-
13
+
14
14
  FederalRegister::Article.find(document_number).title.should == 'Important Notice'
15
15
  end
16
-
17
- it "should throw an error when a document doesn't exist" do
16
+
17
+ it "throws an error when a document doesn't exist" do
18
18
  document_number = "some-random-document"
19
19
  FakeWeb.register_uri(
20
20
  :get,
@@ -25,7 +25,20 @@ describe FederalRegister::Article do
25
25
  lambda{ FederalRegister::Article.find(document_number) }.should raise_error FederalRegister::Client::RecordNotFound
26
26
  end
27
27
  end
28
-
28
+
29
+ describe ".find_all" do
30
+ it "fetches multiple matching documents" do
31
+ FakeWeb.register_uri(
32
+ :get,
33
+ "http://www.federalregister.gov/api/v1/articles/abc,def.json",
34
+ :content_type =>"text/json",
35
+ :body => {:results => [{:document_number => "abc"}, {:document_number => "def"}]}.to_json
36
+ )
37
+ result_set = FederalRegister::Article.find_all('abc','def')
38
+ result_set.results.map(&:document_number).sort.should === ['abc','def']
39
+ end
40
+ end
41
+
29
42
  describe ".search" do
30
43
  before(:each) do
31
44
  FakeWeb.register_uri(
@@ -35,8 +48,8 @@ describe FederalRegister::Article do
35
48
  :body => {:count => 3}.to_json
36
49
  )
37
50
  end
38
-
39
- it "should return a resultset object" do
51
+
52
+ it "returns a resultset object" do
40
53
  FederalRegister::Article.search(:conditions => {:term => "Fish"}).should be_an_instance_of(FederalRegister::ResultSet)
41
54
  end
42
55
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe FederalRegister::ResultSet do
4
4
  describe "#next" do
5
- it "should load the next_page_url" do
5
+ it "loads the next_page_url" do
6
6
  FakeWeb.register_uri(:get, "http://www.federalregister.gov/api/v1/fishes?page=2", :body => {:count => 24}.to_json, :content_type =>"text/json")
7
7
  FederalRegister::ResultSet.new({'next_page_url' => 'http://www.federalregister.gov/api/v1/fishes?page=2'}, FederalRegister::Article).next.count.should == 24
8
8
  end
data/spec/spec_helper.rb CHANGED
@@ -13,5 +13,5 @@ FakeWeb.allow_net_connect = false
13
13
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
14
14
 
15
15
  # RSpec.configure do |config|
16
- #
16
+ #
17
17
  # end
metadata CHANGED
@@ -1,125 +1,150 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: federal_register
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Andrew Carpenter
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-08-01 00:00:00.000000000 %:z
16
+
17
+ date: 2011-08-15 00:00:00 -07:00
13
18
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ type: :runtime
16
23
  name: httparty
17
- requirement: &2156251100 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 7
31
+ - 0
22
32
  version: 0.7.0
23
- type: :runtime
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
24
35
  prerelease: false
25
- version_requirements: *2156251100
26
- - !ruby/object:Gem::Dependency
27
- name: shoulda
28
- requirement: &2156250540 !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
36
  type: :development
37
+ name: shoulda
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ requirement: *id002
46
+ - !ruby/object:Gem::Dependency
35
47
  prerelease: false
36
- version_requirements: *2156250540
37
- - !ruby/object:Gem::Dependency
48
+ type: :development
38
49
  name: bundler
39
- requirement: &2156250000 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
42
52
  - - ~>
43
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 0
57
+ - 0
44
58
  version: 1.0.0
45
- type: :development
59
+ requirement: *id003
60
+ - !ruby/object:Gem::Dependency
46
61
  prerelease: false
47
- version_requirements: *2156250000
48
- - !ruby/object:Gem::Dependency
62
+ type: :development
49
63
  name: jeweler
50
- requirement: &2156249380 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ requirements:
53
66
  - - ~>
54
- - !ruby/object:Gem::Version
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 6
71
+ - 0
55
72
  version: 1.6.0
56
- type: :development
73
+ requirement: *id004
74
+ - !ruby/object:Gem::Dependency
57
75
  prerelease: false
58
- version_requirements: *2156249380
59
- - !ruby/object:Gem::Dependency
60
- name: rcov
61
- requirement: &2156248820 !ruby/object:Gem::Requirement
62
- none: false
63
- requirements:
64
- - - ! '>='
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
76
  type: :development
77
+ name: rcov
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ requirement: *id005
86
+ - !ruby/object:Gem::Dependency
68
87
  prerelease: false
69
- version_requirements: *2156248820
70
- - !ruby/object:Gem::Dependency
88
+ type: :development
71
89
  name: rspec
72
- requirement: &2156246240 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
90
+ version_requirements: &id006 !ruby/object:Gem::Requirement
91
+ requirements:
75
92
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '2.6'
78
- type: :development
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 2
96
+ - 6
97
+ version: "2.6"
98
+ requirement: *id006
99
+ - !ruby/object:Gem::Dependency
79
100
  prerelease: false
80
- version_requirements: *2156246240
81
- - !ruby/object:Gem::Dependency
101
+ type: :development
82
102
  name: rspec
83
- requirement: &2156245560 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
103
+ version_requirements: &id007 !ruby/object:Gem::Requirement
104
+ requirements:
86
105
  - - ~>
87
- - !ruby/object:Gem::Version
88
- version: '2.6'
89
- type: :development
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 2
109
+ - 6
110
+ version: "2.6"
111
+ requirement: *id007
112
+ - !ruby/object:Gem::Dependency
90
113
  prerelease: false
91
- version_requirements: *2156245560
92
- - !ruby/object:Gem::Dependency
114
+ type: :development
93
115
  name: activesupport
94
- requirement: &2156243940 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
116
+ version_requirements: &id008 !ruby/object:Gem::Requirement
117
+ requirements:
97
118
  - - ~>
98
- - !ruby/object:Gem::Version
99
- version: '3'
100
- type: :development
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 3
122
+ version: "3"
123
+ requirement: *id008
124
+ - !ruby/object:Gem::Dependency
101
125
  prerelease: false
102
- version_requirements: *2156243940
103
- - !ruby/object:Gem::Dependency
126
+ type: :development
104
127
  name: fakeweb
105
- requirement: &2156243060 !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
128
+ version_requirements: &id009 !ruby/object:Gem::Requirement
129
+ requirements:
108
130
  - - ~>
109
- - !ruby/object:Gem::Version
131
+ - !ruby/object:Gem::Version
132
+ segments:
133
+ - 1
134
+ - 3
135
+ - 0
110
136
  version: 1.3.0
111
- type: :development
112
- prerelease: false
113
- version_requirements: *2156243060
114
- description: Ruby API Client for FederalRegister.gov that handles searching articles
115
- and getting information about agencies
137
+ requirement: *id009
138
+ description: Ruby API Client for FederalRegister.gov that handles searching articles and getting information about agencies
116
139
  email: andrew@criticaljuncture.org
117
140
  executables: []
141
+
118
142
  extensions: []
119
- extra_rdoc_files:
143
+
144
+ extra_rdoc_files:
120
145
  - LICENSE.txt
121
146
  - README.rdoc
122
- files:
147
+ files:
123
148
  - .document
124
149
  - Gemfile
125
150
  - Gemfile.lock
@@ -142,31 +167,33 @@ files:
142
167
  - test/test_federal_register.rb
143
168
  has_rdoc: true
144
169
  homepage: http://github.com/criticaljuncture/federal_register
145
- licenses:
170
+ licenses:
146
171
  - MIT
147
172
  post_install_message:
148
173
  rdoc_options: []
149
- require_paths:
174
+
175
+ require_paths:
150
176
  - lib
151
- required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
- requirements:
154
- - - ! '>='
155
- - !ruby/object:Gem::Version
156
- version: '0'
157
- segments:
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ segments:
182
+ - 0
183
+ version: "0"
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ segments:
158
189
  - 0
159
- hash: 4374774013964272713
160
- required_rubygems_version: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
190
+ version: "0"
166
191
  requirements: []
192
+
167
193
  rubyforge_project:
168
- rubygems_version: 1.6.2
194
+ rubygems_version: 1.3.6
169
195
  signing_key:
170
196
  specification_version: 3
171
197
  summary: Ruby API Client for FederalRegister.gov
172
198
  test_files: []
199
+