Sha256: 19d5f21c8727f52337817f9143a30236f490ea286740286d3a6c6f636074dd06

Contents?: true

Size: 1000 Bytes

Versions: 4

Compression:

Stored size: 1000 Bytes

Contents

require 'scaffolder'

class Scaffolder::Tool
  require 'scaffolder/tool_index'

  attr :scaffold_file
  attr :sequence_file
  attr :settings

  def initialize(settings)
    @scaffold_file = settings.rest.first
    @sequence_file = settings.rest.last
    @settings = settings
  end

  def run(out=STDOUT,err=STDERR)
    begin
      message = execute
    rescue Exception => e
      err.puts("Error. #{e.message}")
      exit(1)
    else
      out.puts(message) if message
      exit(0)
    end
  end

  def scaffold
    {:Scaffold => @scaffold_file, :Sequence => @sequence_file}.each do |name,file|
      unless File.exists?(file)
        raise ArgumentError.new("#{name} file not found: #{file}")
      end
      if File.size(file) == 0
        raise ArgumentError.new("#{name} file is empty: #{file}")
      end
    end

    Scaffolder.new(YAML.load(File.read(@scaffold_file)),@sequence_file)
  end

  Dir["#{File.dirname(__FILE__)}/tool/*.rb"].each do |f|
    require File.expand_path(f)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scaffolder-tools-0.1.3 lib/scaffolder/tool.rb
scaffolder-tools-0.1.2 lib/scaffolder/tool.rb
scaffolder-tools-0.1.1 lib/scaffolder/tool.rb
scaffolder-tools-0.1.0 lib/scaffolder/tool.rb