Class: RuboCop::Schema::DocumentLoader
- Inherits:
-
Object
- Object
- RuboCop::Schema::DocumentLoader
- Defined in:
- lib/rubocop/schema/document_loader.rb
Constant Summary collapse
- DOCS_URL_TEMPLATE =
-'https://raw.githubusercontent.com/rubocop/%s/%s/docs/modules/ROOT/pages/cops%s.adoc'
- DEFAULTS_URL_TEMPLATE =
-'https://raw.githubusercontent.com/rubocop/%s/%s/config/default.yml'
- CORRECTIONS =
{ 'rubocop' => { # Fixes a typo that causes Asciidoctor to crash '1.10.0' => '174bda389c2c23cffb17e9d6128f5e6bdbc0e8a0' } }.freeze
Instance Method Summary collapse
- #defaults(spec) ⇒ Object
- #doc(spec, department = nil) ⇒ Asciidoctor::Document
-
#initialize(http_client) ⇒ DocumentLoader
constructor
A new instance of DocumentLoader.
Constructor Details
#initialize(http_client) ⇒ DocumentLoader
Returns a new instance of DocumentLoader.
20 21 22 23 24 |
# File 'lib/rubocop/schema/document_loader.rb', line 20 def initialize(http_client) @http_client = http_client @docs = {} @defaults = {} end |
Instance Method Details
#defaults(spec) ⇒ Object
27 28 29 30 |
# File 'lib/rubocop/schema/document_loader.rb', line 27 def defaults(spec) @defaults[spec] ||= YAML.safe_load @http_client.get(url_for_defaults(spec)), [Regexp, Symbol], [], true end |
#doc(spec, department = nil) ⇒ Asciidoctor::Document
35 36 37 38 |
# File 'lib/rubocop/schema/document_loader.rb', line 35 def doc(spec, department = nil) @docs[[spec, department]] ||= Asciidoctor.load @http_client.get url_for_doc(spec, department) end |