Class: Ecfr::RendererService::Diff
- Defined in:
- lib/ecfr/renderer_service/diff.rb
Defined Under Namespace
Classes: DiffTooLarge, Undiffable
Constant Summary
Constants inherited from Base
Constants inherited from Base
Base::SUPPORTED_ARRAY_ACCESSORS
Instance Attribute Summary collapse
-
#html ⇒ String
readonly
HTML document with inline changes.
Attributes inherited from Base
#metadata, #request_data, #response_status, #results
Class Method Summary collapse
Methods inherited from Base
base_url, service_name, service_path
Methods inherited from Base
basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key
Methods included from Extensible
Methods included from AttributeMethodDefinition
Methods inherited from Client
build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge
Methods included from ParallelClient
Constructor Details
This class inherits a constructor from Ecfr::Base
Instance Attribute Details
#html ⇒ String (readonly)
HTML document with inline changes
7 8 |
# File 'lib/ecfr/renderer_service/diff.rb', line 7 attribute :html, desc: "HTML document with inline changes" |
Class Method Details
.compare(old_date:, new_date:, hierarchy: {}, options: {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ecfr/renderer_service/diff.rb', line 10 def self.compare(old_date:, new_date:, hierarchy: {}, options: {}) hierarchy = hierarchy.dup complete = hierarchy.delete(:complete) [:skip_ancestry_checks] = 1 if complete title = hierarchy.delete(:title) view_mode = .delete(:view_mode) || :enhanced params = hierarchy.merge().merge(compare: old_date) begin new( { html: get( content_path(new_date, title, view_mode: view_mode), params ).body }.stringify_keys ) rescue Ecfr::Client::ResponseError, Ecfr::Client::ServerError # diff too large - diff service generated broken pipe error or 500 code raise DiffTooLarge rescue Ecfr::Client::UnknownStatusCode raise Undiffable end end |