Module: Mattock::CommandTaskMixin
- Includes:
- Caliph::CommandLineDSL
- Included in:
- Rake::CommandTask, Rake::FileCommandTask
- Defined in:
- lib/mattock/command-task.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action(args) ⇒ Object
- #check_verification_command ⇒ Object
- #decorated(command) ⇒ Object
- #needed? ⇒ Boolean
- #resolve_runtime_configuration ⇒ Object
- #shell ⇒ Object
- #verify_command ⇒ Object
Class Method Details
.included(sub) ⇒ Object
15 16 17 18 19 |
# File 'lib/mattock/command-task.rb', line 15 def self.included(sub) sub.extend Caliph::CommandLineDSL sub.runtime_setting(:verify_command, nil) sub.runtime_setting(:command) end |
.shell ⇒ Object
49 50 51 |
# File 'lib/mattock/command-task.rb', line 49 def self.shell @shell ||= Caliph.new end |
Instance Method Details
#action(args) ⇒ Object
57 58 59 |
# File 'lib/mattock/command-task.rb', line 57 def action(args) shell.run(decorated(command)).must_succeed! end |
#check_verification_command ⇒ Object
61 62 63 |
# File 'lib/mattock/command-task.rb', line 61 def check_verification_command !shell.run(decorated(verify_command)).succeeds? end |
#decorated(command) ⇒ Object
45 46 47 |
# File 'lib/mattock/command-task.rb', line 45 def decorated(command) command end |
#needed? ⇒ Boolean
65 66 67 68 69 70 71 72 |
# File 'lib/mattock/command-task.rb', line 65 def needed? finalize_configuration if verify_command.nil? super else check_verification_command end end |
#resolve_runtime_configuration ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mattock/command-task.rb', line 21 def resolve_runtime_configuration super #If there's a second troublesome command, this becomes a class-level #array if not verify_command.nil? and verify_command.name == "bundle" unless BundleCommandTask === self warn "Verify command is 'bundle' - this sometimes has unexpected results. Consider BundleCommandTask" end end if command.name == "bundle" unless BundleCommandTask === self warn "Command is 'bundle' - this sometimes has unexpected results. Consider BundleCommandTask" end end end |
#shell ⇒ Object
53 54 55 |
# File 'lib/mattock/command-task.rb', line 53 def shell CommandTaskMixin.shell end |
#verify_command ⇒ Object
38 39 40 41 42 43 |
# File 'lib/mattock/command-task.rb', line 38 def verify_command if @verify_command.respond_to?(:call) @verify_command = @verify_command.call end @verify_command end |