Class: TRMNLP::Context
- Inherits:
-
Object
- Object
- TRMNLP::Context
- Defined in:
- lib/trmnlp/context.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Instance Method Summary collapse
-
#initialize(root_dir, reporter: Reporter.new) ⇒ Context
constructor
A new instance of Context.
- #oauth_session ⇒ Object
-
#poller ⇒ Object
Context is the composition root: it wires and memoizes the runtime object graph.
- #renderer ⇒ Object
- #transform_pipeline ⇒ Object
- #user_data_assembler ⇒ Object
- #validate! ⇒ Object
- #watcher ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/trmnlp/context.rb', line 14 def config @config end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
14 15 16 |
# File 'lib/trmnlp/context.rb', line 14 def paths @paths end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
14 15 16 |
# File 'lib/trmnlp/context.rb', line 14 def reporter @reporter end |
Instance Method Details
#oauth_session ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/trmnlp/context.rb', line 27 def oauth_session @oauth_session ||= begin provider = OAuth::Provider.new(config.plugin.settings) OAuth::Session.new(provider:, token_store: OAuth::TokenStore.new(paths.oauth_tokens), client: OAuth::Client.new(provider)) end end |
#poller ⇒ Object
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:, oauth_session:, reporter:) |
#renderer ⇒ Object
38 |
# File 'lib/trmnlp/context.rb', line 38 def renderer = @renderer ||= Renderer.new(config:, paths:, user_data_assembler:) |
#transform_pipeline ⇒ Object
36 |
# File 'lib/trmnlp/context.rb', line 36 def transform_pipeline = @transform_pipeline ||= TransformPipeline.new(config:, paths:, reporter:) |
#user_data_assembler ⇒ Object
37 |
# File 'lib/trmnlp/context.rb', line 37 def user_data_assembler = @user_data_assembler ||= UserDataAssembler.new(config:, paths:, transform_pipeline:) |
#validate! ⇒ Object
41 42 43 |
# File 'lib/trmnlp/context.rb', line 41 def validate! raise NotAPlugin, "not a plugin directory (did not find #{paths.trmnlp_config})" unless paths.valid? end |