Module: Mattock::CommandTaskMixin

Includes:
CommandLineDSL
Included in:
Rake::CommandTask, Rake::FileCommandTask
Defined in:
lib/mattock/command-task.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommandLineDSL

#cmd, #escaped_command

Class Method Details

.included(sub) ⇒ Object



8
9
10
11
12
# File 'lib/mattock/command-task.rb', line 8

def self.included(sub)
  sub.extend CommandLineDSL
  sub.runtime_setting(:verify_command, nil)
  sub.runtime_setting(:command)
end

Instance Method Details

#action(args) ⇒ Object



42
43
44
# File 'lib/mattock/command-task.rb', line 42

def action(args)
  decorated(command).must_succeed!
end

#check_verification_commandObject



46
47
48
# File 'lib/mattock/command-task.rb', line 46

def check_verification_command
  !decorated(verify_command).succeeds?
end

#decorated(command) ⇒ Object



38
39
40
# File 'lib/mattock/command-task.rb', line 38

def decorated(command)
  command
end

#needed?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
# File 'lib/mattock/command-task.rb', line 50

def needed?
  finalize_configuration
  if verify_command.nil?
    super
  else
    check_verification_command
  end
end

#resolve_runtime_configurationObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mattock/command-task.rb', line 14

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

#verify_commandObject



31
32
33
34
35
36
# File 'lib/mattock/command-task.rb', line 31

def verify_command
  if @verify_command.respond_to?(:call)
    @verify_command = @verify_command.call
  end
  @verify_command
end