class Kender::Command
This class abstracts the shell commands we use
Attributes
success[R]
Public Class Methods
all()
click to toggle source
# File lib/kender/command.rb, line 42 def all @all ||= begin all_commands = commands.select(&:available?) # move rspec and cucumber to last places so faster tools run first 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()
click to toggle source
# File lib/kender/command.rb, line 38 def all_names all.map(&:name) end
all_success?()
click to toggle source
# File lib/kender/command.rb, line 26 def all_success? all.inject(true) {|all_result, command_result| all_result && command_result } end
commands()
click to toggle source
# File lib/kender/command.rb, line 30 def commands @commands ||= [] end
inherited(klass)
click to toggle source
# File lib/kender/command.rb, line 34 def inherited(klass) commands << klass.new end
Public Instance Methods
available?()
click to toggle source
# File lib/kender/command.rb, line 10 def available? abort "Command failed: #{name}, availability status undefined." end
execute()
click to toggle source
# File lib/kender/command.rb, line 14 def execute @success = run.success? end
name()
click to toggle source
# File lib/kender/command.rb, line 6 def name self.class.name.split("::").last.downcase.to_sym end
run()
click to toggle source
TODO: system reload all the gems again, avoid this.
# File lib/kender/command.rb, line 19 def run system(command) $? end
Private Instance Methods
in_gemfile?(gem_name)
click to toggle source
# File lib/kender/command.rb, line 60 def in_gemfile?(gem_name) Bundler.definition.dependencies.any?{ |dep| dep.name == gem_name } end