Class: CalendarAssistant::CLI::CommandService
- Inherits:
-
Object
- Object
- CalendarAssistant::CLI::CommandService
- Defined in:
- lib/calendar_assistant/cli/command_service.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
Instance Method Summary collapse
- #authorizer(profile_name: config.profile_name, token_store: config.token_store) ⇒ Object
- #calendar_assistant(datespec) ⇒ Object
-
#initialize(context:, options: {}) ⇒ CommandService
constructor
A new instance of CommandService.
- #service ⇒ Object
Constructor Details
#initialize(context:, options: {}) ⇒ CommandService
Returns a new instance of CommandService.
6 7 8 9 10 11 12 13 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 6 def initialize(context:, options: {}) @options = .dup @options[CalendarAssistant::Config::Keys::Options::CONTEXT] ||= context.to_s @config = CalendarAssistant::CLI::Config.new(options: @options) @authorizer = {} @out = CalendarAssistant::CLI::Printer.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 4 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 4 def @options end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
4 5 6 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 4 def out @out end |
Instance Method Details
#authorizer(profile_name: config.profile_name, token_store: config.token_store) ⇒ Object
22 23 24 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 22 def (profile_name: config.profile_name, token_store: config.token_store) @authorizer[profile_name] ||= Authorizer.new(profile_name, token_store) end |
#calendar_assistant(datespec) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 15 def calendar_assistant(datespec) ca = CalendarAssistant.new(config, service: service) ca.in_env do yield(ca, CalendarAssistant::CLI::Helpers.parse_datespec(datespec), out) end end |
#service ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/calendar_assistant/cli/command_service.rb', line 26 def service @service ||= begin if filename = config.setting(Config::Keys::Options::LOCAL_STORE) CalendarAssistant::LocalService.new(file: filename) else .service end end end |