Class: Licensed::Commands::Command
- Inherits:
-
Object
- Object
- Licensed::Commands::Command
- Defined in:
- lib/licensed/commands/command.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Instance Method Summary collapse
-
#initialize(config:, reporter:) ⇒ Command
constructor
A new instance of Command.
-
#run(**options) ⇒ Object
Run the command.
Constructor Details
#initialize(config:, reporter:) ⇒ Command
Returns a new instance of Command.
9 10 11 12 |
# File 'lib/licensed/commands/command.rb', line 9 def initialize(config:, reporter:) @config = config @reporter = reporter end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/licensed/commands/command.rb', line 5 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/licensed/commands/command.rb', line 7 def @options end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
6 7 8 |
# File 'lib/licensed/commands/command.rb', line 6 def reporter @reporter end |
Instance Method Details
#run(**options) ⇒ Object
Run the command
options - Options to run the command with
Returns whether the command was a success
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/licensed/commands/command.rb', line 19 def run(**) @options = begin result = reporter.report_run(self) do config.apps.sort_by { |app| app["name"] } .map { |app| run_app(app) } .all? end ensure @options = nil end result end |