federal_register 0.7.1 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a003dcebeeb80ec509aa695f35459a61700f798a3ab228ac0947b42942713d0a
4
- data.tar.gz: 8b1f3bb7602304fbe8c7eae23a2563e0432b9b6e090207aba77c4dca5807c29a
3
+ metadata.gz: 5b888ccd1e8ba93b75d9217a494435d52408cea9bb7dd76eceee8692183d3a8f
4
+ data.tar.gz: caad2387bb549a07e0cdd581ec40265f50b46a05c18f2b2c74b193819b5d8b6f
5
5
  SHA512:
6
- metadata.gz: b5aed81850d81cf4c5dc07547fd694214f5f5d6f033b1fe1033199ba18ab34ae69905e2809377b56efbee1cb4a19e4f408e36544803cfc54de315842cac5c95d
7
- data.tar.gz: 619b9ebd3fd143953e97d04f62e403e7e9ec0929d6e6630d1f13db070fc7144b21bda2813092f561acb6e759b32412407a22f4d80fc55bd6dfa12de54a633ead
6
+ metadata.gz: f507c18904701a263175b2cbf1d8d5fc631e6129b98217d139338ce9634e05d0f36ae9f689129bddcfc1999839537dd8a31330ca5e68b1938c349bc7a474fa25
7
+ data.tar.gz: 64cb7f390982d0e13d4e6ff6e3cf1239ad00fd6a9e53c63a7be90707323f13277d6446ddc2b3212dd4a3a15df6a5fe32a0a16a4274bffb44821c392ac8010c54
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "federal_register"
8
- s.version = "0.7.1"
8
+ s.version = "0.7.3"
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", "Bob Burbach"]
12
- s.date = "2019-05-13"
12
+ s.date = "2019-11-19"
13
13
  s.description = "Ruby API Client for FederalRegister.gov that handles searching documents and getting information about agencies"
14
14
  s.email = "andrew@criticaljuncture.org"
15
15
  s.extra_rdoc_files = [
@@ -11,9 +11,11 @@ class FederalRegister::Client
11
11
  end
12
12
  end
13
13
 
14
- class RecordNotFound < ResponseError; end
15
14
  class BadRequest < ResponseError; end
15
+ class GatewayTimeout < ResponseError; end
16
+ class RecordNotFound < ResponseError; end
16
17
  class ServerError < ResponseError; end
18
+ class ServiceUnavailable < ResponseError; end
17
19
 
18
20
  base_uri 'https://www.federalregister.gov/api/v1'
19
21
 
@@ -29,6 +31,10 @@ class FederalRegister::Client
29
31
  raise RecordNotFound.new(response)
30
32
  when 500
31
33
  raise ServerError.new(response)
34
+ when 503
35
+ raise ServiceUnavailable.new(response)
36
+ when 504
37
+ raise GatewayTimeout.new(response)
32
38
  else
33
39
  raise HTTParty::ResponseError.new(response)
34
40
  end
@@ -60,13 +60,21 @@ class FederalRegister::Document < FederalRegister::Base
60
60
  end
61
61
 
62
62
  def self.find(document_number, options={})
63
+ query = {}
64
+
65
+ if options[:publication_date].present?
66
+ publication_date = options[:publication_date]
67
+ publication_date = publication_date.is_a?(Date) ? publication_date.to_s(:iso) : publication_date
68
+
69
+ query.merge!(:publication_date => publication_date)
70
+ end
71
+
63
72
  if options[:fields].present?
64
- attributes = get("/documents/#{document_number}.json", :query => {:fields => options[:fields]}).parsed_response
65
- new(attributes)
66
- else
67
- attributes = get("/documents/#{document_number}.json").parsed_response
68
- new(attributes, :full => true)
73
+ query.merge!(:fields => options[:fields])
69
74
  end
75
+
76
+ attributes = get("/documents/#{document_number}.json", :query => query).parsed_response
77
+ new(attributes, :full => true)
70
78
  end
71
79
 
72
80
  # supports values like: '2016-26522', '2016-26522,2016-26594', '81 FR 76496', '81 FR 76496,81 FR 76685'
@@ -45,7 +45,7 @@ describe FederalRegister::Base do
45
45
  instance = @klass.new('panda' => date_string)
46
46
  lambda {
47
47
  instance.panda.should == "never going to get here"
48
- }.should raise_error
48
+ }.should raise_error ArgumentError
49
49
  end
50
50
  end
51
51
  end
@@ -84,10 +84,11 @@ describe FederalRegister::Base do
84
84
  context "when value is not a valid date string" do
85
85
  it "throws" do
86
86
  date_string = "foo"
87
- instance = @klass.new(:updated_at => date_string)
87
+ instance = @klass.new('updated_at' => date_string)
88
+
88
89
  lambda {
89
90
  instance.updated_at.should == '?'
90
- }.should raise_error
91
+ }.should raise_error ArgumentError
91
92
  end
92
93
  end
93
94
  end
@@ -29,6 +29,21 @@ describe FederalRegister::Document do
29
29
  result.end_page.should be(nil)
30
30
  end
31
31
 
32
+ it "fetches the document with the provided publication date (when present)" do
33
+ document_number = "2010-213"
34
+ publication_date = "2010-02-02"
35
+ FakeWeb.register_uri(
36
+ :get,
37
+ "https://www.federalregister.gov/api/v1/documents/#{document_number}.json?publication_date=#{publication_date}",
38
+ :content_type => "text/json",
39
+ :body => {:title => "Important Notice", :publication_date => publication_date}.to_json
40
+ )
41
+
42
+ result = FederalRegister::Document.find(document_number, :publication_date => publication_date)
43
+ result.title.should eql("Important Notice")
44
+ result.publication_date.should eql(Date.parse(publication_date))
45
+ end
46
+
32
47
  it "throws an error when a document doesn't exist" do
33
48
  document_number = "some-random-document"
34
49
  FakeWeb.register_uri(
@@ -13,6 +13,8 @@ FakeWeb.allow_net_connect = false
13
13
  # in ./support/ and its subdirectories.
14
14
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
15
15
 
16
- # RSpec.configure do |config|
17
- #
18
- # end
16
+ RSpec.configure do |config|
17
+ config.expect_with(:rspec) { |c| c.syntax = :should }
18
+ end
19
+
20
+
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.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Carpenter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-13 00:00:00.000000000 Z
12
+ date: 2019-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty