Class: KBuilder::Watch::Execute
- Inherits:
-
Object
- Object
- KBuilder::Watch::Execute
- Defined in:
- lib/k_builder/watch/execute.rb
Overview
Execute based on CLI options
Constant Summary collapse
- DEFAULT_ACTIONS =
{ help: KBuilder::Watch::ActionDisplayHelp, debug: KBuilder::Watch::ActionDisplayDebug, new_builder: KBuilder::Watch::ActionNewBuilder, watcher: KBuilder::Watch::ActionWatcher }.freeze
Instance Attribute Summary collapse
-
#actions ⇒ Object
watcher = KBuilder::Watch::Watcher.new(cli.watch_path) watcher.start.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options, actions: DEFAULT_ACTIONS) ⇒ Execute
constructor
Execute one or more actions based on supplied options.
- #run ⇒ Object
- #run_action(action_key) ⇒ Object
Constructor Details
#initialize(options, actions: DEFAULT_ACTIONS) ⇒ Execute
Execute one or more actions based on supplied options
You can use dependency injection to provide your actions
28 29 30 31 |
# File 'lib/k_builder/watch/execute.rb', line 28 def initialize(, actions: DEFAULT_ACTIONS) @actions = actions @options = end |
Instance Attribute Details
#actions ⇒ Object
watcher = KBuilder::Watch::Watcher.new(cli.watch_path) watcher.start
22 23 24 |
# File 'lib/k_builder/watch/execute.rb', line 22 def actions @actions end |
#options ⇒ Object
Returns the value of attribute options.
23 24 25 |
# File 'lib/k_builder/watch/execute.rb', line 23 def @options end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/k_builder/watch/execute.rb', line 40 def run if .help? run_action(:help) exit end if .debug? run_action(:debug) exit end if .new? run_action(:new_builder) # Originally I allowed new to proceed straight into watcher, but it is problematic to mix # builder creation in with builder watching, they are two different tasks that should be # run separately exit end run_action(:watcher) end |