ecfr 1.0.8 → 1.0.9

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: 3982b2145a3ab849c7fbbe13699265d5d3c75ca19be019e8b3e57bad78f6c2ee
4
- data.tar.gz: 2d4b94aa527179914dce1d89f6f781bde99af455abddccb8d1c409d199a811be
3
+ metadata.gz: cadbb3387da1a9a32e94246031dd6330160ad2aa8891d6fee6a78fd334553b6b
4
+ data.tar.gz: 58d7b650c1e6406d1ce1a9b6faf76e649762c3bf90a0305a38a5f0dd63580a28
5
5
  SHA512:
6
- metadata.gz: 964a37efcba4b38cbca2c9108f59ef9f972ab23f1b6904149b59bc3105370c351781f166397a9bb97fd9564e91cbc21f89ded0defcb64d678e57636b42db309b
7
- data.tar.gz: 55fefed80cbf964968660b8c625cf35189d21c55611bbfa0143ce3394e3408d5d5253817f73c115f7f53d0844b8afaf04d5e828c6d563ee1b947325799157f00
6
+ metadata.gz: 7e8feba398bf9e8aac36468a6292682526a1d95b412a8ac46b898d7c7a71c144081b5aca4cca2d386f24e359399d1e13599ff95f219047257a038c176d063959
7
+ data.tar.gz: 1cd02d613ead3929fe1957bade79bac560f37ccdfc531c59a4710524ccb781ca23c0fff44f3bc0e42f58126e0da9265f23874d41db4847c20bb5a328de669714
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.9] - 2023-05-12
4
+ ### Additions
5
+ - Add support for configuring the service path. This supports blue/green style deployments where the same service may be running but accessible at different subpaths.
6
+
3
7
  ## [1.0.8] - 2023-05-05
4
8
  ### Updates
5
9
  - Update Ecfr::RenderService::Diff to rescue expected error types and raise more specific diff errors
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ecfr
2
2
 
3
- Provides a Ruby API client for the eCFR.gov APIs.
3
+ Provides a Ruby API client for the eCFR.gov APIs. Not all services and API endpoints in this gem are publically available. See https://www.ecfr.gov/developers/documentation/api/v1 for public endpoint documentation.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,12 +12,14 @@ module Ecfr
12
12
  require_relative "issue"
13
13
  require_relative "site_notification"
14
14
 
15
- SERVICE_PATH = "/admin/api/admin"
16
-
17
15
  def self.base_url
18
16
  Ecfr.config.admin_service_url || Ecfr.config.base_url
19
17
  end
20
18
 
19
+ def self.service_path
20
+ Ecfr.config.admin_service_path || "/admin/api/admin"
21
+ end
22
+
21
23
  def self.service_name
22
24
  "Admin Service"
23
25
  end
data/lib/ecfr/client.rb CHANGED
@@ -121,7 +121,7 @@ module Ecfr
121
121
  # response_status set.
122
122
  #
123
123
  def self.perform(method, path, params: {}, client_options: {}, perform_options: {})
124
- path = [self::SERVICE_PATH, path].compact.join("/")
124
+ path = [service_path, path].compact.join("/")
125
125
 
126
126
  default_perform_options = {parse_response: true}
127
127
  perform_options = default_perform_options.merge(perform_options)
@@ -11,14 +11,23 @@ module Ecfr
11
11
  ofr_profile_service_base_url: "https://www.federalregister.gov/my/profile",
12
12
  # service url overrides
13
13
  admin_service_url: nil,
14
+ admin_service_path: nil,
14
15
  diff_service_url: nil,
16
+ diff_service_path: nil,
15
17
  ofr_profile_service_url: nil,
18
+ ofr_profile_service_path: nil,
16
19
  prince_xml_service_url: nil,
20
+ prince_xml_service_path: nil,
17
21
  renderer_service_url: nil,
22
+ renderer_service_path: nil,
18
23
  search_service_url: nil,
24
+ search_service_path: nil,
19
25
  subscriptions_service_url: nil,
26
+ subscriptions_service_path: nil,
20
27
  varnish_cache_service_url: nil,
28
+ varnish_cache_service_path: nil,
21
29
  versioner_service_url: nil,
30
+ versioner_service_path: nil,
22
31
  # basic auth - some endpoints require auth
23
32
  ecfr_basic_auth_username: nil,
24
33
  ecfr_basic_auth_password: nil,
@@ -19,7 +19,7 @@ module Ecfr
19
19
  {
20
20
  url: [
21
21
  base_url,
22
- self::SERVICE_PATH,
22
+ service_path,
23
23
  "/#{DOCUMENTATION_PATH}"
24
24
  ].reject(&:blank?).join,
25
25
  method: :get
@@ -17,7 +17,7 @@ module Ecfr
17
17
  def status_config
18
18
  url = [
19
19
  base_url,
20
- self::SERVICE_PATH,
20
+ service_path,
21
21
  STATUS_PATH
22
22
  ].reject(&:blank?)
23
23
  .join("/")
@@ -3,12 +3,14 @@ module Ecfr
3
3
  class Base < Ecfr::Base
4
4
  require_relative "status"
5
5
 
6
- SERVICE_PATH = "/api/diff"
7
-
8
6
  def self.base_url
9
7
  Ecfr.config.diff_service_url || Ecfr.config.base_url
10
8
  end
11
9
 
10
+ def self.service_path
11
+ Ecfr.config.diff_service_path || "/api/diff"
12
+ end
13
+
12
14
  def self.service_name
13
15
  "Diff Service"
14
16
  end
@@ -20,7 +20,7 @@ module Ecfr
20
20
  # errors or run in parallel
21
21
  def self.status_config
22
22
  {
23
- url: "#{base_url}/#{SERVICE_PATH}/#{STATUS_PATH}",
23
+ url: "#{base_url}/#{service_path}/#{STATUS_PATH}",
24
24
  method: :post,
25
25
  response_type: "html",
26
26
  options: {
@@ -3,13 +3,15 @@ module Ecfr
3
3
  class Base < Ecfr::Base
4
4
  require_relative "status"
5
5
 
6
+ def self.base_url
7
+ Ecfr.config.ofr_profile_service_url || Ecfr.config.ofr_profile_service_base_url
8
+ end
9
+
6
10
  # path is relative because we expect the ofr profile
7
11
  # api to be mounted at a subpath and an absolute url
8
12
  # here will cause the path in the config to be lost
9
- SERVICE_PATH = "api/profile"
10
-
11
- def self.base_url
12
- Ecfr.config.ofr_profile_service_url || Ecfr.config.ofr_profile_service_base_url
13
+ def self.service_path
14
+ Ecfr.config.ofr_profile_service_path || "api/profile"
13
15
  end
14
16
 
15
17
  def self.service_name
@@ -3,12 +3,14 @@ module Ecfr
3
3
  class Base < Ecfr::Base
4
4
  require_relative "pdf"
5
5
 
6
- SERVICE_PATH = ""
7
-
8
6
  def self.base_url
9
7
  Ecfr.config.prince_xml_service_url || Ecfr.config.base_url
10
8
  end
11
9
 
10
+ def self.service_path
11
+ Ecfr.config.prince_xml_service_path || ""
12
+ end
13
+
12
14
  def self.service_name
13
15
  "Prince XML Service"
14
16
  end
@@ -0,0 +1,33 @@
1
+ module Ecfr
2
+ module PrinceXmlService
3
+ class Status < Base
4
+ include DefaultStatusSetup
5
+
6
+ STATUS_PATH = "status"
7
+
8
+ def self.status
9
+ perform(
10
+ status_config[:method],
11
+ STATUS_PATH,
12
+ perform_options: {parse_response: false}
13
+ )
14
+ end
15
+
16
+ # .status_config is provided to support use cases
17
+ # in which the user wants to construct their own
18
+ # handling of status checks, e.g. to wrap in custom
19
+ # errors or run in parallel
20
+ def status_config
21
+ {
22
+ url: [
23
+ base_url,
24
+ service_path,
25
+ STATUS_PATH
26
+ ].reject(&:blank?).join("/"),
27
+ method: :get,
28
+ response_type: "html"
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -7,12 +7,14 @@ module Ecfr
7
7
  require_relative "diff"
8
8
  require_relative "origin"
9
9
 
10
- SERVICE_PATH = "/api/renderer"
11
-
12
10
  def self.base_url
13
11
  Ecfr.config.renderer_service_url || Ecfr.config.base_url
14
12
  end
15
13
 
14
+ def self.service_path
15
+ Ecfr.config.renderer_service_path || "/api/renderer"
16
+ end
17
+
16
18
  def self.service_name
17
19
  "Renderer Service"
18
20
  end
@@ -23,7 +25,7 @@ module Ecfr
23
25
  # content retrieval doesn't make use of the .perform worflow
24
26
  # and so we need to add service path here.
25
27
  def self.content_path(date, title_number, view_mode: "enhanced")
26
- "#{SERVICE_PATH}/#{HTML_PATH}/#{view_mode}/#{date}/title-#{title_number}"
28
+ "#{service_path}/#{HTML_PATH}/#{view_mode}/#{date}/title-#{title_number}"
27
29
  end
28
30
  private_class_method :content_path
29
31
  end
@@ -9,12 +9,14 @@ module Ecfr
9
9
  require_relative "date_facet"
10
10
  require_relative "title_facet"
11
11
 
12
- SERVICE_PATH = "/api/search"
13
-
14
12
  def self.base_url
15
13
  Ecfr.config.search_service_url || Ecfr.config.base_url
16
14
  end
17
15
 
16
+ def self.service_path
17
+ Ecfr.config.search_service_path || "/api/search"
18
+ end
19
+
18
20
  def self.service_name
19
21
  "Search Service"
20
22
  end
@@ -5,12 +5,14 @@ module Ecfr
5
5
 
6
6
  require_relative "subscription"
7
7
 
8
- SERVICE_PATH = "/api/subscriptions"
9
-
10
8
  def self.base_url
11
9
  Ecfr.config.subscriptions_service_url || Ecfr.config.base_url
12
10
  end
13
11
 
12
+ def self.service_path
13
+ Ecfr.config.subscriptions_service_path || "/api/subscriptions"
14
+ end
15
+
14
16
  def self.service_name
15
17
  "Subscriptions Service"
16
18
  end
data/lib/ecfr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ecfr
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.9"
5
5
  end
@@ -10,12 +10,14 @@ module Ecfr
10
10
  require_relative "title"
11
11
  require_relative "xml_content"
12
12
 
13
- SERVICE_PATH = "/api/versioner"
14
-
15
13
  def self.base_url
16
14
  Ecfr.config.versioner_service_url || Ecfr.config.base_url
17
15
  end
18
16
 
17
+ def self.service_path
18
+ Ecfr.config.versioner_service_path || "/api/versioner"
19
+ end
20
+
19
21
  def self.service_name
20
22
  "Versioner Service"
21
23
  end
@@ -45,7 +45,7 @@ module Ecfr
45
45
  options = default_options.merge(options.symbolize_keys)
46
46
 
47
47
  format = options.delete(:format)
48
- path = [self::SERVICE_PATH, structure_path(date, title_number, format)].join("/")
48
+ path = [service_path, structure_path(date, title_number, format)].join("/")
49
49
 
50
50
  client.build_url(path, options).to_s
51
51
  end
@@ -109,7 +109,7 @@ module Ecfr
109
109
  date = split[-2]
110
110
  title_number = split[-1].split("-")[1]
111
111
 
112
- path = "#{self.class::SERVICE_PATH}/#{self.class.send(:structure_path, date, title_number)}"
112
+ path = "#{self.class.service_path}/#{self.class.send(:structure_path, date, title_number)}"
113
113
 
114
114
  params = request_data[:params].except(:structure, :metadata)
115
115
 
@@ -51,7 +51,7 @@ module Ecfr
51
51
  end
52
52
 
53
53
  def self.xml_content_path(date, title_number)
54
- "#{SERVICE_PATH}/#{XML_PATH}/#{date}/title-#{title_number}.xml"
54
+ "#{service_path}/#{XML_PATH}/#{date}/title-#{title_number}.xml"
55
55
  end
56
56
  private_class_method :xml_content_path
57
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecfr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peregrinator
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-05 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -292,6 +292,7 @@ files:
292
292
  - lib/ecfr/parallel_client.rb
293
293
  - lib/ecfr/prince_xml_service/base.rb
294
294
  - lib/ecfr/prince_xml_service/pdf.rb
295
+ - lib/ecfr/prince_xml_service/status.rb.bak
295
296
  - lib/ecfr/renderer_service/base.rb
296
297
  - lib/ecfr/renderer_service/content.rb
297
298
  - lib/ecfr/renderer_service/diff.rb