module BinDiesel::ClassMethods

Public Instance Methods

opts_accessor(*args) click to toggle source
# File lib/bin_diesel.rb, line 49
def opts_accessor *args
  OPTS[:accessible_options] += args
end
opts_banner(text) click to toggle source
# File lib/bin_diesel.rb, line 33
def opts_banner text
  OPTS[:banner] = text
end
opts_description(text) click to toggle source
# File lib/bin_diesel.rb, line 37
def opts_description text
  OPTS[:description] << text
end
opts_on(*opts, &block) click to toggle source
# File lib/bin_diesel.rb, line 41
def opts_on *opts, &block
  OPTS[:user_options] << {:options => opts, :block => block }
end
opts_required(*args) click to toggle source
# File lib/bin_diesel.rb, line 45
def opts_required *args
  OPTS[:required_options] += args
end
post_initialize(&block) click to toggle source
# File lib/bin_diesel.rb, line 27
def post_initialize &block
  define_method :post_initialize do
    instance_eval(&block)
  end
end
run(&block) click to toggle source
# File lib/bin_diesel.rb, line 11
def run &block
  define_method :run do
    begin
      puts "DRY RUN" if options.dry_run
      instance_eval(&block)
      ending = happy_ending
    rescue Exception => e
      error_message "FAILED: #{e.message}"
      puts e.backtrace
      ending = unhappy_ending
    ensure
      ending
    end
  end
end