Sha256: 8a6ef527809035da3b156650c0230f0c6a42087f6fa5b239c9ee9eb0fa075ee6

Contents?: true

Size: 999 Bytes

Versions: 7

Compression:

Stored size: 999 Bytes

Contents

# encoding: UTF-8

require 'find'
require 'pathname'

module Gjp
  # runs programs from a gjp kit with gjp-specific options
  class KitRunner
    include Logger

    def initialize(project)      
      @project = project
    end

    # finds an executable in a bin/ subdirectory of kit
    def find_executable(name)
      @project.from_directory do
        Find.find("kit") do |path|
          if path =~ /bin\/#{name}$/
            log.debug("found #{name} executable: #{path}")
            return path
          end
        end
      end

      log.debug("#{name} executable not found")
      nil
    end

    # runs an external executable, returns true on success
    def run_executable(full_commandline)
      log.debug "running #{full_commandline}"
      Process.wait(Process.spawn(full_commandline))
      $?.exitstatus == 0
    end
  end

  class ExecutableNotFoundError < Exception
    attr_reader :executable

    def initialize(executable)
      @executable = executable
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gjp-0.36.0 lib/gjp/kit_runner.rb
gjp-0.35.0 lib/gjp/kit_runner.rb
gjp-0.34.0 lib/gjp/kit_runner.rb
gjp-0.33.0 lib/gjp/kit_runner.rb
gjp-0.32.0 lib/gjp/kit_runner.rb
gjp-0.31.0 lib/gjp/kit_runner.rb
gjp-0.30.0 lib/gjp/kit_runner.rb