Class: Bipm::Data::Importer::Strategies::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bipm/data/importer/strategies/base.rb

Overview

Abstract strategy. Subclasses implement call and override recording_mode. The Fetcher queries recording_mode to decide whether to disable VCR/WebMock before invoking — the CLI never touches VCR directly.

Direct Known Subclasses

SpaMeetings, StaticIndex

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, base_dir:, languages: Language.all) ⇒ Base

Returns a new instance of Base.



16
17
18
19
20
# File 'lib/bipm/data/importer/strategies/base.rb', line 16

def initialize(body:, base_dir:, languages: Language.all)
  @body = body
  @base_dir = base_dir
  @languages = languages.map { |l| l.is_a?(Language) ? l : Language.find(l) }
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



14
15
16
# File 'lib/bipm/data/importer/strategies/base.rb', line 14

def base_dir
  @base_dir
end

#bodyObject (readonly)

Returns the value of attribute body.



14
15
16
# File 'lib/bipm/data/importer/strategies/base.rb', line 14

def body
  @body
end

#languagesObject (readonly)

Returns the value of attribute languages.



14
15
16
# File 'lib/bipm/data/importer/strategies/base.rb', line 14

def languages
  @languages
end

Class Method Details

.recording_modeObject

:live -> HTTP requests bypass VCR/WebMock entirely. :cassette -> VCR replays recorded responses (records new episodes when BIPM_VCR_RECORD is set).



29
30
31
# File 'lib/bipm/data/importer/strategies/base.rb', line 29

def self.recording_mode
  :cassette
end

Instance Method Details

#call(agent:) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/bipm/data/importer/strategies/base.rb', line 22

def call(agent:)
  raise NotImplementedError, "#{self.class}#call not implemented"
end

#recording_modeObject



33
34
35
# File 'lib/bipm/data/importer/strategies/base.rb', line 33

def recording_mode
  self.class.recording_mode
end