federal_register 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +32 -0
- data/README.md +41 -0
- data/VERSION +1 -1
- data/federal_register.gemspec +13 -12
- data/lib/federal_register.rb +1 -0
- data/lib/federal_register/agency.rb +3 -1
- data/lib/federal_register/article.rb +47 -7
- data/lib/federal_register/base.rb +4 -4
- data/lib/federal_register/client.rb +16 -3
- data/lib/federal_register/public_inspection_document.rb +5 -0
- data/lib/federal_register/result_set.rb +3 -1
- data/lib/federal_register/utilities.rb +8 -0
- data/spec/agency_spec.rb +2 -18
- data/spec/article_spec.rb +34 -5
- data/spec/base_spec.rb +1 -14
- data/spec/public_inspection_document_spec.rb +5 -5
- data/spec/result_set_spec.rb +2 -2
- metadata +27 -26
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -35
data/LICENSE.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
As a work of the United States Government, this project is in the
|
2
|
+
public domain within the United States.
|
3
|
+
|
4
|
+
Additionally, we waive copyright and related rights in the work
|
5
|
+
worldwide through the CC0 1.0 Universal public domain dedication.
|
6
|
+
|
7
|
+
## CC0 1.0 Universal Summary
|
8
|
+
|
9
|
+
This is a human-readable summary of the
|
10
|
+
[Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
|
11
|
+
|
12
|
+
### No Copyright
|
13
|
+
|
14
|
+
The person who associated a work with this deed has dedicated the work to
|
15
|
+
the public domain by waiving all of his or her rights to the work worldwide
|
16
|
+
under copyright law, including all related and neighboring rights, to the
|
17
|
+
extent allowed by law.
|
18
|
+
|
19
|
+
You can copy, modify, distribute and perform the work, even for commercial
|
20
|
+
purposes, all without asking permission.
|
21
|
+
|
22
|
+
### Other Information
|
23
|
+
|
24
|
+
In no way are the patent or trademark rights of any person affected by CC0,
|
25
|
+
nor are the rights that other persons may have in the work or in how the
|
26
|
+
work is used, such as publicity or privacy rights.
|
27
|
+
|
28
|
+
Unless expressly stated otherwise, the person who associated a work with
|
29
|
+
this deed makes no warranties about the work, and disclaims liability for
|
30
|
+
all uses of the work, to the fullest extent permitted by applicable law.
|
31
|
+
When using or citing the work, you should not imply endorsement by the
|
32
|
+
author or the affirmer.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# federal_register
|
2
|
+
|
3
|
+
Ruby API Client for FederalRegister.gov that handles searching articles and getting basic information about agencies.
|
4
|
+
|
5
|
+
For more information about the FederalRegister.gov API, see http://www.federalregister.gov/learn/developers
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
FederalRegister::Article.find('2011-17721').title
|
11
|
+
result_set = FederalRegister::Article.search(:conditions => {:term => "Accessibility"})
|
12
|
+
# or result_set = FederalRegister.find_all('2011-17721','2011-17722')
|
13
|
+
result_set.count
|
14
|
+
result_set.results.each do |article|
|
15
|
+
puts "#{article.title} by #{article.agencies.map(&:name)}"
|
16
|
+
end
|
17
|
+
|
18
|
+
FederalRegister::Agency.all.each do |agency|
|
19
|
+
puts agency.name
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Contributing to federal_register
|
24
|
+
|
25
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
26
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
27
|
+
* Fork the project
|
28
|
+
* Start a feature/bugfix branch
|
29
|
+
* Commit and push until you are happy with your contribution
|
30
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
31
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
32
|
+
|
33
|
+
## Copyright
|
34
|
+
|
35
|
+
This project is in the public domain within the United States, and
|
36
|
+
copyright and related rights in the work worldwide are waived through
|
37
|
+
the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
|
38
|
+
|
39
|
+
All contributions to this project will be released under the CC0
|
40
|
+
dedication. By submitting a pull request, you are agreeing to comply
|
41
|
+
with this waiver of copyright interest.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/federal_register.gemspec
CHANGED
@@ -4,25 +4,25 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.5.
|
7
|
+
s.name = "federal_register"
|
8
|
+
s.version = "0.5.1"
|
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 =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2015-02-06"
|
13
|
+
s.description = "Ruby API Client for FederalRegister.gov that handles searching articles and getting information about agencies"
|
14
|
+
s.email = "andrew@criticaljuncture.org"
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.
|
17
|
-
"README.
|
16
|
+
"LICENSE.md",
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".watchr",
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
|
-
"LICENSE.
|
25
|
-
"README.
|
24
|
+
"LICENSE.md",
|
25
|
+
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"federal_register.gemspec",
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/federal_register/client.rb",
|
34
34
|
"lib/federal_register/public_inspection_document.rb",
|
35
35
|
"lib/federal_register/result_set.rb",
|
36
|
+
"lib/federal_register/utilities.rb",
|
36
37
|
"spec/agency_spec.rb",
|
37
38
|
"spec/article_spec.rb",
|
38
39
|
"spec/base_spec.rb",
|
@@ -40,11 +41,11 @@ Gem::Specification.new do |s|
|
|
40
41
|
"spec/result_set_spec.rb",
|
41
42
|
"spec/spec_helper.rb"
|
42
43
|
]
|
43
|
-
s.homepage =
|
44
|
+
s.homepage = "http://github.com/criticaljuncture/federal_register"
|
44
45
|
s.licenses = ["MIT"]
|
45
46
|
s.require_paths = ["lib"]
|
46
|
-
s.rubygems_version =
|
47
|
-
s.summary =
|
47
|
+
s.rubygems_version = "1.8.11"
|
48
|
+
s.summary = "Ruby API Client for FederalRegister.gov"
|
48
49
|
|
49
50
|
if s.respond_to? :specification_version then
|
50
51
|
s.specification_version = 3
|
data/lib/federal_register.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
class FederalRegister::Agency < FederalRegister::Base
|
2
2
|
add_attribute :description,
|
3
|
-
:id,
|
4
3
|
:json_url,
|
5
4
|
:logo,
|
6
5
|
:name,
|
7
6
|
:recent_articles_url,
|
8
7
|
:short_name,
|
9
8
|
:url
|
9
|
+
add_attribute :id,
|
10
|
+
:parent_id,
|
11
|
+
:type => :integer
|
10
12
|
|
11
13
|
def self.all
|
12
14
|
response = get('/agencies.json')
|
@@ -1,47 +1,81 @@
|
|
1
1
|
class FederalRegister::Article < FederalRegister::Base
|
2
|
+
extend FederalRegister::Utilities
|
2
3
|
class InvalidDocumentNumber < ArgumentError; end
|
4
|
+
|
3
5
|
add_attribute :abstract,
|
4
6
|
:abstract_html_url,
|
5
7
|
:action,
|
6
8
|
:agencies,
|
9
|
+
:agency_names,
|
7
10
|
:body_html_url,
|
8
11
|
:cfr_references,
|
12
|
+
:citation,
|
13
|
+
:comment_url,
|
14
|
+
:corrections,
|
15
|
+
:correction_of,
|
9
16
|
:dates,
|
10
17
|
:docket_id,
|
11
18
|
:docket_ids,
|
12
19
|
:document_number,
|
13
20
|
:end_page,
|
21
|
+
:excerpts,
|
22
|
+
:executive_order_notes,
|
23
|
+
:executive_order_number,
|
14
24
|
:full_text_xml_url,
|
15
25
|
:html_url,
|
16
26
|
:json_url,
|
17
27
|
:mods_url,
|
18
28
|
:pdf_url,
|
29
|
+
:president,
|
30
|
+
:public_inspection_pdf_url,
|
31
|
+
:regulation_id_number_info,
|
19
32
|
:regulation_id_numbers,
|
33
|
+
:regulations_dot_gov_info,
|
34
|
+
:regulations_dot_gov_url,
|
20
35
|
:start_page,
|
21
36
|
:subtype,
|
37
|
+
:raw_text_url,
|
22
38
|
:title,
|
39
|
+
:toc_subject,
|
40
|
+
:toc_doc,
|
23
41
|
:type,
|
24
42
|
:volume
|
25
43
|
|
26
44
|
add_attribute :comments_close_on,
|
27
45
|
:effective_on,
|
28
46
|
:publication_date,
|
47
|
+
:signing_date,
|
29
48
|
:type => :date
|
30
49
|
|
31
50
|
def self.search(args)
|
32
51
|
FederalRegister::ResultSet.fetch("/articles.json", :query => args, :result_class => self)
|
33
52
|
end
|
53
|
+
|
54
|
+
def self.search_metadata(args)
|
55
|
+
FederalRegister::ResultSet.fetch("/articles.json", :query => args.merge(:metadata_only => '1'), :result_class => self)
|
56
|
+
end
|
34
57
|
|
35
|
-
def self.find(document_number)
|
58
|
+
def self.find(document_number, options={})
|
36
59
|
validate_document_number!(document_number)
|
37
|
-
|
38
|
-
|
60
|
+
if options[:fields].present?
|
61
|
+
attributes = get("/articles/#{document_number}.json", :query => {:fields => options[:fields]})
|
62
|
+
new(attributes)
|
63
|
+
else
|
64
|
+
attributes = get("/articles/#{document_number}.json")
|
65
|
+
new(attributes, :full => true)
|
66
|
+
end
|
39
67
|
end
|
40
68
|
|
41
|
-
def self.find_all(*
|
69
|
+
def self.find_all(*args)
|
70
|
+
options, document_numbers = extract_options(args)
|
71
|
+
|
72
|
+
fetch_options = {:result_class => self}
|
73
|
+
fetch_options.merge!(:query => {:fields => options[:fields]}) if options[:fields]
|
74
|
+
|
42
75
|
document_numbers = document_numbers.flatten
|
43
76
|
document_numbers.each {|doc_num| validate_document_number!(doc_num)}
|
44
|
-
|
77
|
+
|
78
|
+
result_set = FederalRegister::ResultSet.fetch("/articles/#{document_numbers.join(',')}.json", fetch_options)
|
45
79
|
end
|
46
80
|
|
47
81
|
def agencies
|
@@ -50,9 +84,15 @@ class FederalRegister::Article < FederalRegister::Base
|
|
50
84
|
end
|
51
85
|
end
|
52
86
|
|
53
|
-
%w(full_text_xml abstract_html body_html mods).each do |file_type|
|
87
|
+
%w(full_text_xml abstract_html body_html raw_text mods).each do |file_type|
|
54
88
|
define_method file_type do
|
55
|
-
|
89
|
+
begin
|
90
|
+
self.class.get(send("#{file_type}_url")).body
|
91
|
+
rescue FederalRegister::Client::RecordNotFound
|
92
|
+
nil
|
93
|
+
rescue
|
94
|
+
raise send("#{file_type}_url").inspect
|
95
|
+
end
|
56
96
|
end
|
57
97
|
end
|
58
98
|
|
@@ -21,13 +21,13 @@ class FederalRegister::Base < FederalRegister::Client
|
|
21
21
|
if ! val.is_a?(DateTime)
|
22
22
|
val = DateTime.parse(val.to_s)
|
23
23
|
end
|
24
|
+
when :integer
|
25
|
+
if ! val.is_a?(Fixnum)
|
26
|
+
val = val.to_i
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
|
-
if ! val && ! full? && respond_to?(:json_url) && @attributes['json_url']
|
28
|
-
fetch_full
|
29
|
-
val = send(attr)
|
30
|
-
end
|
31
31
|
val
|
32
32
|
end
|
33
33
|
end
|
@@ -1,10 +1,21 @@
|
|
1
1
|
class FederalRegister::Client
|
2
2
|
include HTTParty
|
3
3
|
|
4
|
-
class
|
5
|
-
|
4
|
+
class ResponseError < HTTParty::ResponseError
|
5
|
+
def message
|
6
|
+
response.body
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class RecordNotFound < ResponseError; end
|
15
|
+
class BadRequest < ResponseError; end
|
16
|
+
class ServerError < ResponseError; end
|
6
17
|
|
7
|
-
base_uri '
|
18
|
+
base_uri 'https://www.federalregister.gov/api/v1'
|
8
19
|
|
9
20
|
def self.get(url, *options)
|
10
21
|
response = super
|
@@ -12,6 +23,8 @@ class FederalRegister::Client
|
|
12
23
|
case response.code
|
13
24
|
when 200
|
14
25
|
response
|
26
|
+
when 400
|
27
|
+
raise BadRequest.new(response)
|
15
28
|
when 404
|
16
29
|
raise RecordNotFound.new(response)
|
17
30
|
when 500
|
@@ -9,6 +9,7 @@ class FederalRegister::PublicInspectionDocument < FederalRegister::Base
|
|
9
9
|
:pdf_file_size,
|
10
10
|
:num_pages,
|
11
11
|
:title,
|
12
|
+
:toc_doc,
|
12
13
|
:toc_subject,
|
13
14
|
:type
|
14
15
|
|
@@ -22,6 +23,10 @@ class FederalRegister::PublicInspectionDocument < FederalRegister::Base
|
|
22
23
|
FederalRegister::ResultSet.fetch("/public-inspection-documents.json", :query => args, :result_class => self)
|
23
24
|
end
|
24
25
|
|
26
|
+
def self.search_metadata(args)
|
27
|
+
FederalRegister::ResultSet.fetch("/public-inspection-documents.json", :query => args.merge(:metadata_only => '1'), :result_class => self)
|
28
|
+
end
|
29
|
+
|
25
30
|
def self.find(document_number)
|
26
31
|
attributes = get("/public-inspection-documents/#{document_number}.json")
|
27
32
|
new(attributes, :full => true)
|
@@ -1,13 +1,15 @@
|
|
1
1
|
class FederalRegister::ResultSet < FederalRegister::Client
|
2
2
|
include Enumerable
|
3
3
|
|
4
|
-
attr_reader :count, :total_pages, :results, :errors
|
4
|
+
attr_reader :count, :total_pages, :results, :errors, :description
|
5
5
|
|
6
6
|
def initialize(attributes, result_class)
|
7
7
|
@result_class = result_class
|
8
8
|
@count = attributes['count']
|
9
9
|
@total_pages = attributes['total_pages']
|
10
10
|
@results = (attributes['results'] || []).map{|result| @result_class.new(result) }
|
11
|
+
|
12
|
+
@description = attributes['description']
|
11
13
|
|
12
14
|
@prev_url = attributes['previous_page_url']
|
13
15
|
@next_url = attributes['next_page_url']
|
data/spec/agency_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe FederalRegister::Agency do
|
4
4
|
describe ".all" do
|
5
5
|
before(:each) do
|
6
|
-
FakeWeb.register_uri(:get, "
|
6
|
+
FakeWeb.register_uri(:get, "https://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
|
@@ -21,7 +21,7 @@ describe FederalRegister::Agency do
|
|
21
21
|
|
22
22
|
describe "attribute loading" do
|
23
23
|
before(:each) do
|
24
|
-
@agency = FederalRegister::Agency.new({'name' => "Commerce Department", 'json_url' => "
|
24
|
+
@agency = FederalRegister::Agency.new({'name' => "Commerce Department", 'json_url' => "https://www.federalregister.gov/api/v1/agencies/1.json"})
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "existing attribute" do
|
@@ -35,21 +35,5 @@ describe FederalRegister::Agency do
|
|
35
35
|
lambda {@agency.non_existent_attribute}.should raise_error NoMethodError
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
describe "missing attribute" do
|
40
|
-
FakeWeb.register_uri(:get, "http://api.federalregister.gov/v1/agencies/1.json", :body => {:description => "Lorem ipsum"}.to_json, :content_type =>"text/json")
|
41
|
-
it "should lazy-load from the json_url" do
|
42
|
-
@agency.send(:attributes)['description'].should be_nil
|
43
|
-
@agency.description.should == "Lorem ipsum"
|
44
|
-
@agency.send(:attributes)['description'].should == "Lorem ipsum"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "missing attribute when no full json" do
|
49
|
-
it "should lazy-load from the json_url" do
|
50
|
-
@agency = FederalRegister::Agency.new({'name' => "Commerce Department"})
|
51
|
-
@agency.description.should be_nil
|
52
|
-
end
|
53
|
-
end
|
54
38
|
end
|
55
39
|
end
|
data/spec/article_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe FederalRegister::Article do
|
|
6
6
|
document_number = "2010-213"
|
7
7
|
FakeWeb.register_uri(
|
8
8
|
:get,
|
9
|
-
"
|
9
|
+
"https://www.federalregister.gov/api/v1/articles/#{document_number}.json",
|
10
10
|
:content_type =>"text/json",
|
11
11
|
:body => {:title => "Important Notice"}.to_json
|
12
12
|
)
|
@@ -14,11 +14,26 @@ describe FederalRegister::Article do
|
|
14
14
|
FederalRegister::Article.find(document_number).title.should == 'Important Notice'
|
15
15
|
end
|
16
16
|
|
17
|
+
it "fetches the document with only requested fields (when present)" do
|
18
|
+
document_number = "2010-213"
|
19
|
+
FakeWeb.register_uri(
|
20
|
+
:get,
|
21
|
+
"https://www.federalregister.gov/api/v1/articles/#{document_number}.json?fields[]=title&fields[]=start_page",
|
22
|
+
:content_type => "text/json",
|
23
|
+
:body => {:title => "Important Notice", :start_page => 12345}.to_json
|
24
|
+
)
|
25
|
+
|
26
|
+
result = FederalRegister::Article.find(document_number, :fields => ["title", "start_page"])
|
27
|
+
result.title.should eql("Important Notice")
|
28
|
+
result.start_page.should eql(12345)
|
29
|
+
result.end_page.should be(nil)
|
30
|
+
end
|
31
|
+
|
17
32
|
it "throws an error when a document doesn't exist" do
|
18
33
|
document_number = "some-random-document"
|
19
34
|
FakeWeb.register_uri(
|
20
35
|
:get,
|
21
|
-
"
|
36
|
+
"https://www.federalregister.gov/api/v1/articles/#{document_number}.json",
|
22
37
|
:content_type =>"text/json",
|
23
38
|
:status => 404
|
24
39
|
)
|
@@ -34,7 +49,7 @@ describe FederalRegister::Article do
|
|
34
49
|
it "fetches multiple matching documents" do
|
35
50
|
FakeWeb.register_uri(
|
36
51
|
:get,
|
37
|
-
"
|
52
|
+
"https://www.federalregister.gov/api/v1/articles/abc,def.json",
|
38
53
|
:content_type =>"text/json",
|
39
54
|
:body => {:results => [{:document_number => "abc"}, {:document_number => "def"}]}.to_json
|
40
55
|
)
|
@@ -42,6 +57,20 @@ describe FederalRegister::Article do
|
|
42
57
|
result_set.results.map(&:document_number).sort.should === ['abc','def']
|
43
58
|
end
|
44
59
|
|
60
|
+
it "fetches multiple matching documents with only requested fields (when present)" do
|
61
|
+
FakeWeb.register_uri(
|
62
|
+
:get,
|
63
|
+
"https://www.federalregister.gov/api/v1/articles/abc,def.json?fields[]=document_number&fields[]=title",
|
64
|
+
:content_type =>"text/json",
|
65
|
+
:body => {:results => [{:document_number => "abc", :title => "Important Notice"},
|
66
|
+
{:document_number => "def", :title => "Important Rule"}]}.to_json
|
67
|
+
)
|
68
|
+
result_set = FederalRegister::Article.find_all('abc','def', :fields => ["document_number", "title"])
|
69
|
+
result_set.results.map(&:document_number).sort.should === ['abc','def']
|
70
|
+
result_set.results.map(&:title).sort.should === ['Important Notice','Important Rule']
|
71
|
+
result_set.results.map(&:start_page).should === [nil, nil]
|
72
|
+
end
|
73
|
+
|
45
74
|
it "throws an error when given an invalid document number" do
|
46
75
|
lambda{ FederalRegister::Article.find_all('123-456','an! invalid! document! number!') }.should raise_error FederalRegister::Article::InvalidDocumentNumber
|
47
76
|
end
|
@@ -51,7 +80,7 @@ describe FederalRegister::Article do
|
|
51
80
|
before(:each) do
|
52
81
|
FakeWeb.register_uri(
|
53
82
|
:get,
|
54
|
-
"
|
83
|
+
"https://www.federalregister.gov/api/v1/articles.json?conditions[term]=Fish",
|
55
84
|
:content_type =>"text/json",
|
56
85
|
:body => {:count => 3}.to_json
|
57
86
|
)
|
@@ -88,7 +117,7 @@ describe FederalRegister::Article do
|
|
88
117
|
document_number = "2010-213"
|
89
118
|
FakeWeb.register_uri(
|
90
119
|
:get,
|
91
|
-
"
|
120
|
+
"https://www.federalregister.gov/api/v1/articles/#{document_number}.json",
|
92
121
|
:content_type =>"text/json",
|
93
122
|
:body => {:title => "Important Notice", :docket_ids => ['ABC','123']}.to_json
|
94
123
|
)
|
data/spec/base_spec.rb
CHANGED
@@ -9,19 +9,6 @@ describe FederalRegister::Base do
|
|
9
9
|
instance.foo.should == "bar"
|
10
10
|
end
|
11
11
|
|
12
|
-
it 'creates a getter method that lazy loads the full data' do
|
13
|
-
klass = Class.new(FederalRegister::Base)
|
14
|
-
klass.add_attribute(:foo, :json_url)
|
15
|
-
instance = klass.new('json_url' => 'http://example.com/details')
|
16
|
-
FakeWeb.register_uri(
|
17
|
-
:get,
|
18
|
-
"http://example.com/details",
|
19
|
-
:content_type =>"text/json",
|
20
|
-
:body => {:foo => "bar"}.to_json
|
21
|
-
)
|
22
|
-
instance.foo.should == 'bar'
|
23
|
-
end
|
24
|
-
|
25
12
|
context "when attribute is of type date" do
|
26
13
|
before(:each) do
|
27
14
|
@klass = Class.new(FederalRegister::Base)
|
@@ -119,7 +106,7 @@ describe FederalRegister::Base do
|
|
119
106
|
end
|
120
107
|
|
121
108
|
after(:all) do
|
122
|
-
FederalRegister::Base.override_base_uri('
|
109
|
+
FederalRegister::Base.override_base_uri('https://www.federalregister.gov/api/v1')
|
123
110
|
end
|
124
111
|
end
|
125
112
|
end
|
@@ -6,7 +6,7 @@ describe FederalRegister::PublicInspectionDocument do
|
|
6
6
|
document_number = "2010-213"
|
7
7
|
FakeWeb.register_uri(
|
8
8
|
:get,
|
9
|
-
"
|
9
|
+
"https://www.federalregister.gov/api/v1/public-inspection-documents/#{document_number}.json",
|
10
10
|
:content_type =>"text/json",
|
11
11
|
:body => {:title => "Important Notice"}.to_json
|
12
12
|
)
|
@@ -18,7 +18,7 @@ describe FederalRegister::PublicInspectionDocument do
|
|
18
18
|
document_number = "some-random-document"
|
19
19
|
FakeWeb.register_uri(
|
20
20
|
:get,
|
21
|
-
"
|
21
|
+
"https://www.federalregister.gov/api/v1/public-inspection-documents/#{document_number}.json",
|
22
22
|
:content_type =>"text/json",
|
23
23
|
:status => 404
|
24
24
|
)
|
@@ -30,7 +30,7 @@ describe FederalRegister::PublicInspectionDocument do
|
|
30
30
|
it "fetches multiple matching documents" do
|
31
31
|
FakeWeb.register_uri(
|
32
32
|
:get,
|
33
|
-
"
|
33
|
+
"https://www.federalregister.gov/api/v1/public-inspection-documents/abc,def.json",
|
34
34
|
:content_type =>"text/json",
|
35
35
|
:body => {:results => [{:document_number => "abc"}, {:document_number => "def"}]}.to_json
|
36
36
|
)
|
@@ -43,7 +43,7 @@ describe FederalRegister::PublicInspectionDocument do
|
|
43
43
|
it "fetches the document on PI on a given date" do
|
44
44
|
FakeWeb.register_uri(
|
45
45
|
:get,
|
46
|
-
"
|
46
|
+
"https://www.federalregister.gov/api/v1/public-inspection-documents.json?conditions[available_on]=2011-10-15",
|
47
47
|
:content_type =>"text/json",
|
48
48
|
:body => {:results => [{:document_number => "abc"}, {:document_number => "def"}]}.to_json
|
49
49
|
)
|
@@ -56,7 +56,7 @@ describe FederalRegister::PublicInspectionDocument do
|
|
56
56
|
it "fetches the PI documents from the current issue" do
|
57
57
|
FakeWeb.register_uri(
|
58
58
|
:get,
|
59
|
-
"
|
59
|
+
"https://www.federalregister.gov/api/v1/public-inspection-documents/current.json",
|
60
60
|
:content_type =>"text/json",
|
61
61
|
:body => {:results => [{:document_number => "abc"}, {:document_number => "def"}]}.to_json
|
62
62
|
)
|
data/spec/result_set_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe FederalRegister::ResultSet do
|
4
4
|
describe "#next" do
|
5
5
|
it "loads the next_page_url" do
|
6
|
-
FakeWeb.register_uri(:get, "
|
7
|
-
FederalRegister::ResultSet.new({'next_page_url' => '
|
6
|
+
FakeWeb.register_uri(:get, "https://www.federalregister.gov/api/v1/fishes?page=2", :body => {:count => 24}.to_json, :content_type =>"text/json")
|
7
|
+
FederalRegister::ResultSet.new({'next_page_url' => 'https://www.federalregister.gov/api/v1/fishes?page=2'}, FederalRegister::Article).next.count.should == 24
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: federal_register
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70102078955580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.7.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70102078955580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &70102078954740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70102078954740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70102078953820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70102078953820
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70102078952760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70102078952760
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70102078967720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70102078967720
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70102078966280 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.6'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70102078966280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70102078964840 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.6'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70102078964840
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: activesupport
|
93
|
-
requirement: &
|
93
|
+
requirement: &70102078963560 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '3'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70102078963560
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: fakeweb
|
104
|
-
requirement: &
|
104
|
+
requirement: &70102078961920 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,22 +109,22 @@ dependencies:
|
|
109
109
|
version: 1.3.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70102078961920
|
113
113
|
description: Ruby API Client for FederalRegister.gov that handles searching articles
|
114
114
|
and getting information about agencies
|
115
115
|
email: andrew@criticaljuncture.org
|
116
116
|
executables: []
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files:
|
119
|
-
- LICENSE.
|
120
|
-
- README.
|
119
|
+
- LICENSE.md
|
120
|
+
- README.md
|
121
121
|
files:
|
122
122
|
- .document
|
123
123
|
- .watchr
|
124
124
|
- Gemfile
|
125
125
|
- Gemfile.lock
|
126
|
-
- LICENSE.
|
127
|
-
- README.
|
126
|
+
- LICENSE.md
|
127
|
+
- README.md
|
128
128
|
- Rakefile
|
129
129
|
- VERSION
|
130
130
|
- federal_register.gemspec
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/federal_register/client.rb
|
136
136
|
- lib/federal_register/public_inspection_document.rb
|
137
137
|
- lib/federal_register/result_set.rb
|
138
|
+
- lib/federal_register/utilities.rb
|
138
139
|
- spec/agency_spec.rb
|
139
140
|
- spec/article_spec.rb
|
140
141
|
- spec/base_spec.rb
|
@@ -156,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
segments:
|
158
159
|
- 0
|
159
|
-
hash:
|
160
|
+
hash: 2337510225236876614
|
160
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
162
|
none: false
|
162
163
|
requirements:
|
@@ -165,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
166
|
version: '0'
|
166
167
|
requirements: []
|
167
168
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.
|
169
|
+
rubygems_version: 1.8.11
|
169
170
|
signing_key:
|
170
171
|
specification_version: 3
|
171
172
|
summary: Ruby API Client for FederalRegister.gov
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Andrew Carpenter
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
= federal_register
|
2
|
-
|
3
|
-
Ruby API Client for FederalRegister.gov that handles searching articles and getting basic information about agencies.
|
4
|
-
|
5
|
-
For more information about the FederalRegister.gov API, see http://www.federalregister.gov/learn/developers
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
FederalRegister::Article.find('2011-17721').title
|
10
|
-
result_set = FederalRegister::Article.search(:conditions => {:term => "Accessibility"})
|
11
|
-
# or result_set = FederalRegister.find_all('2011-17721','2011-17722')
|
12
|
-
result_set.count
|
13
|
-
result_set.results.each do |article|
|
14
|
-
puts "#{article.title} by #{article.agencies.map(&:name)}"
|
15
|
-
end
|
16
|
-
|
17
|
-
FederalRegister::Agency.all.each do |agency|
|
18
|
-
puts agency.name
|
19
|
-
end
|
20
|
-
|
21
|
-
== Contributing to federal_register
|
22
|
-
|
23
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
24
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
25
|
-
* Fork the project
|
26
|
-
* Start a feature/bugfix branch
|
27
|
-
* Commit and push until you are happy with your contribution
|
28
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
29
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
30
|
-
|
31
|
-
== Copyright
|
32
|
-
|
33
|
-
Copyright (c) 2011 Critical Juncture. See LICENSE.txt for
|
34
|
-
further details.
|
35
|
-
|