Class: MiddlemanWebpacked::CommandRunner
- Inherits:
-
Object
- Object
- MiddlemanWebpacked::CommandRunner
- Defined in:
- lib/middleman-webpacked/command_runner.rb
Constant Summary collapse
- AVAILABLE_MODE =
%i[production development none]
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #command ⇒ Object
- #entries ⇒ Object
-
#initialize(app, options) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #loaders ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(app, options) ⇒ CommandRunner
Returns a new instance of CommandRunner.
24 25 26 27 28 29 30 |
# File 'lib/middleman-webpacked/command_runner.rb', line 24 def initialize(app, ) @app = app @options = @arguments = [] setup end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
22 23 24 |
# File 'lib/middleman-webpacked/command_runner.rb', line 22 def app @app end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
22 23 24 |
# File 'lib/middleman-webpacked/command_runner.rb', line 22 def mode @mode end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/middleman-webpacked/command_runner.rb', line 22 def @options end |
Class Method Details
.bin(path = nil) ⇒ Object
6 7 8 9 |
# File 'lib/middleman-webpacked/command_runner.rb', line 6 def bin(path = nil) return @bin if path.nil? @bin = path end |
.mode(new_mode = nil) ⇒ Object
11 12 13 14 |
# File 'lib/middleman-webpacked/command_runner.rb', line 11 def mode(new_mode = nil) return @mode if new_mode.nil? @mode = new_mode if AVAILABLE_MODE.include?(new_mode) end |
.satisfy? ⇒ Boolean
16 17 18 19 |
# File 'lib/middleman-webpacked/command_runner.rb', line 16 def satisfy? return false if bin.nil? File.exist?(bin) end |
Instance Method Details
#command ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/middleman-webpacked/command_runner.rb', line 48 def command [ self.class.bin, "--mode #{self.class.mode}" ] .concat(entries) .concat(@arguments) .join(' ') end |
#entries ⇒ Object
42 43 44 45 46 |
# File 'lib/middleman-webpacked/command_runner.rb', line 42 def entries .entry.map do |name, path| "--entry #{name}=./src/#{path}" end end |
#loaders ⇒ Object
36 37 38 39 40 |
# File 'lib/middleman-webpacked/command_runner.rb', line 36 def loaders @loaders.map do |type, loader| "--module-bind #{type}=#{loader}-loader" end end |
#setup ⇒ Object
32 33 34 |
# File 'lib/middleman-webpacked/command_runner.rb', line 32 def setup raise NotImplementedError, "The command didn't setup for execute" end |