Class: Kender::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/kender/command.rb
Overview
This class abstracts the shell commands we use
Direct Known Subclasses
Brakeman, BundleAudit, ConsistencyFail, Cucumber, FactoryGirlLint, I18nVerify, Jasmine, PBDuplicates, Rdlint, Reek, Rspec, Shamus, TestUnit
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#success ⇒ Object
Returns the value of attribute success.
4
5
6
|
# File 'lib/kender/command.rb', line 4
def success
@success
end
|
Class Method Details
.all ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/kender/command.rb', line 42
def all
@all ||= begin
all_commands = commands.select(&:available?)
if command = all_commands.find{ |command| command.name == :rspec }
all_commands.delete_if{ |command| command.name == :rspec }.push(command)
end
if command = all_commands.find{ |command| command.name == :cucumber }
all_commands.delete_if{ |command| command.name == :cucumber }.push(command)
end
all_commands
end
end
|
.all_names ⇒ Object
38
39
40
|
# File 'lib/kender/command.rb', line 38
def all_names
all.map(&:name)
end
|
.all_success? ⇒ Boolean
26
27
28
|
# File 'lib/kender/command.rb', line 26
def all_success?
all.inject(true) {|all_result, command_result| all_result && command_result }
end
|
.commands ⇒ Object
30
31
32
|
# File 'lib/kender/command.rb', line 30
def commands
@commands ||= []
end
|
.inherited(klass) ⇒ Object
34
35
36
|
# File 'lib/kender/command.rb', line 34
def inherited(klass)
commands << klass.new
end
|
Instance Method Details
#available? ⇒ Boolean
10
11
12
|
# File 'lib/kender/command.rb', line 10
def available?
abort "Command failed: #{name}, availability status undefined."
end
|
#execute ⇒ Object
14
15
16
|
# File 'lib/kender/command.rb', line 14
def execute
@success = run.success?
end
|
#name ⇒ Object
6
7
8
|
# File 'lib/kender/command.rb', line 6
def name
self.class.name.split("::").last.downcase.to_sym
end
|
#run ⇒ Object
TODO: system reload all the gems again, avoid this.
19
20
21
22
|
# File 'lib/kender/command.rb', line 19
def run
system(command)
$?
end
|