Class: Teems::Runner
- Inherits:
-
Object
- Object
- Teems::Runner
- Includes:
- ApiFactories
- Defined in:
- lib/teems/runner.rb
Overview
Dependency injection container providing services to commands
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#token_store ⇒ Object
readonly
Returns the value of attribute token_store.
Instance Method Summary collapse
-
#account ⇒ Object
Account helpers - always get fresh from token_store (important for token refresh).
- #api_client ⇒ Object
- #cache_store ⇒ Object
-
#clear_api_cache ⇒ Object
Clear any cached API instances after token refresh.
- #configured? ⇒ Boolean
-
#initialize(output: Formatters::Output.new, config: Services::Configuration.new, token_store: Services::TokenStore.new, api_client: nil, cache_store: Services::CacheStore.new) ⇒ Runner
constructor
A new instance of Runner.
-
#message_formatter ⇒ Object
Formatter helpers.
-
#refresh_tokens ⇒ Object
Attempt to refresh the skype_token.
-
#safari_js_runner ⇒ Object
Safari JS runner for SharePoint automation.
-
#token_extractor(auth_mode: :default) ⇒ Object
Token extractor for Safari automation.
-
#token_refresher ⇒ Object
Token refresher for automatic token refresh.
Methods included from ApiFactories
#calendar_api, #channels_api, #chats_api, #files_api, #meetings_api, #messages_api, #users_api
Constructor Details
#initialize(output: Formatters::Output.new, config: Services::Configuration.new, token_store: Services::TokenStore.new, api_client: nil, cache_store: Services::CacheStore.new) ⇒ Runner
Returns a new instance of Runner.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/teems/runner.rb', line 21 def initialize( output: Formatters::Output.new, config: Services::Configuration.new, token_store: Services::TokenStore.new, api_client: nil, cache_store: Services::CacheStore.new ) api_client ||= Services::ApiClient.new(endpoints: config['endpoints'] || {}) @output = output @config = config @token_store = token_store @services = { api_client: api_client, cache_store: cache_store } wire_up_warnings end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/teems/runner.rb', line 19 def config @config end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
19 20 21 |
# File 'lib/teems/runner.rb', line 19 def output @output end |
#token_store ⇒ Object (readonly)
Returns the value of attribute token_store.
19 20 21 |
# File 'lib/teems/runner.rb', line 19 def token_store @token_store end |
Instance Method Details
#account ⇒ Object
Account helpers - always get fresh from token_store (important for token refresh)
41 42 43 |
# File 'lib/teems/runner.rb', line 41 def account @token_store.account or raise ConfigError, 'No account configured. Run: teems auth login' end |
#api_client ⇒ Object
37 |
# File 'lib/teems/runner.rb', line 37 def api_client = @services[:api_client] |
#cache_store ⇒ Object
38 |
# File 'lib/teems/runner.rb', line 38 def cache_store = @services[:cache_store] |
#clear_api_cache ⇒ Object
Clear any cached API instances after token refresh
50 51 52 53 |
# File 'lib/teems/runner.rb', line 50 def clear_api_cache # API instances are not cached, but account is fetched fresh each time # This method exists for future extensibility end |
#configured? ⇒ Boolean
45 46 47 |
# File 'lib/teems/runner.rb', line 45 def configured? @token_store.configured? end |
#message_formatter ⇒ Object
Formatter helpers
56 57 58 |
# File 'lib/teems/runner.rb', line 56 def Formatters::MessageFormatter.new(output: @output, cache_store: cache_store) end |
#refresh_tokens ⇒ Object
Attempt to refresh the skype_token
76 77 78 |
# File 'lib/teems/runner.rb', line 76 def refresh_tokens token_refresher.refresh end |
#safari_js_runner ⇒ Object
Safari JS runner for SharePoint automation
61 62 63 |
# File 'lib/teems/runner.rb', line 61 def safari_js_runner Services::SafariJsRunner.new(output: @output) end |
#token_extractor(auth_mode: :default) ⇒ Object
Token extractor for Safari automation
66 67 68 |
# File 'lib/teems/runner.rb', line 66 def token_extractor(auth_mode: :default) Services::TokenExtractor.new(output: @output, auth_mode: auth_mode) end |
#token_refresher ⇒ Object
Token refresher for automatic token refresh
71 72 73 |
# File 'lib/teems/runner.rb', line 71 def token_refresher Services::TokenRefresher.new(token_store: @token_store, output: @output) end |