Sha256: 804c6e54b6e4a65679cb3c3a11fd1eb4ff40cfd0188599a5e1e6dd0859ec4c99

Contents?: true

Size: 1.08 KB

Versions: 21

Compression:

Stored size: 1.08 KB

Contents

class PreCommit
  attr_reader :actor
  def initialize(actor)
    @actor = actor
  end

  protected
  def rake_invoke(task_name)
    Rake::Task[task_name].invoke
  end

  def rake_sh(task_name, env_hash={})
    env = env_hash.collect{|key, value| "#{key}=#{value}"}.join(' ')
    rake = (PLATFORM == "i386-mswin32") ? "rake.bat" : "rake"
    cmd = "#{rake} #{task_name} #{env} --trace"
    output = silent_sh(cmd)
    puts output
    if shell_error?(output)
      raise "ERROR while running rake: #{cmd}"
    end
  end

  def silent_sh(cmd, &block)
    output = nil
    IO.popen(cmd) do |io|
      output = io.read
      output.each_line do |line|
        block.call(line) if block
      end
    end
    output
  end

  def shell_error?(output)
    output =~ /ERROR/n || error_code?
  end

  def error_code?
    $?.exitstatus != 0
  end

  def root_dir
    dir = File.dirname(__FILE__)
    File.expand_path("#{dir}/../../../..")
  end  

  def method_missing(method_name, *args, &block)
    if actor.respond_to?(method_name)
      actor.send(method_name, *args, &block)
    else
      super
    end
  end
end

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.0 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.1 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.3 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.2 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.4 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
picolena-0.1.5 rails_plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.5.1 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.5 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.7 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.6 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.8 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
radiant-0.6.9 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
rspec-1.1.3 pre_commit/lib/pre_commit/pre_commit.rb
spree-0.2.0 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
typo-5.0.3.98.1 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
typo-5.0.3.98 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
typo-5.1.2 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
typo-5.1.1 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb
typo-5.1.3 vendor/plugins/rspec/pre_commit/lib/pre_commit/pre_commit.rb