Class: TRMNLP::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/trmnlp/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_dir, reporter: Reporter.new) ⇒ Context

Returns a new instance of Context.



16
17
18
19
20
# File 'lib/trmnlp/context.rb', line 16

def initialize(root_dir, reporter: Reporter.new)
  @paths = Paths.new(root_dir)
  @config = Config.new(paths)
  @reporter = reporter
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



14
15
16
# File 'lib/trmnlp/context.rb', line 14

def config
  @config
end

#pathsObject (readonly)

Returns the value of attribute paths.



14
15
16
# File 'lib/trmnlp/context.rb', line 14

def paths
  @paths
end

#reporterObject (readonly)

Returns the value of attribute reporter.



14
15
16
# File 'lib/trmnlp/context.rb', line 14

def reporter
  @reporter
end

Instance Method Details

#pollerObject

Context is the composition root: it wires and memoizes the runtime object graph. Callers take the collaborator they need and talk to it directly — Context does not forward methods on their behalf.



25
# File 'lib/trmnlp/context.rb', line 25

def poller = @poller ||= Poller.new(config:, paths:, reporter:)

#rendererObject



28
# File 'lib/trmnlp/context.rb', line 28

def renderer = @renderer ||= Renderer.new(config:, paths:, user_data_assembler:)

#transform_pipelineObject



26
# File 'lib/trmnlp/context.rb', line 26

def transform_pipeline = @transform_pipeline ||= TransformPipeline.new(config:, paths:, reporter:)

#user_data_assemblerObject



27
# File 'lib/trmnlp/context.rb', line 27

def user_data_assembler = @user_data_assembler ||= UserDataAssembler.new(config:, paths:, transform_pipeline:)

#validate!Object

Raises:



31
32
33
# File 'lib/trmnlp/context.rb', line 31

def validate!
  raise NotAPlugin, "not a plugin directory (did not find #{paths.trmnlp_config})" unless paths.valid?
end

#watcherObject



29
# File 'lib/trmnlp/context.rb', line 29

def watcher = @watcher ||= Watcher.new(config:, user_data_assembler:, transform_pipeline:, reporter:)