Module: BinDiesel::ClassMethods

Defined in:
lib/bin_diesel.rb

Instance Method Summary collapse

Instance Method Details

#opts_accessor(*args) ⇒ Object



49
50
51
# File 'lib/bin_diesel.rb', line 49

def opts_accessor *args
  OPTS[:accessible_options] += args
end

#opts_banner(text) ⇒ Object



33
34
35
# File 'lib/bin_diesel.rb', line 33

def opts_banner text
  OPTS[:banner] = text
end

#opts_description(text) ⇒ Object



37
38
39
# File 'lib/bin_diesel.rb', line 37

def opts_description text
  OPTS[:description] << text
end

#opts_on(*opts, &block) ⇒ Object



41
42
43
# File 'lib/bin_diesel.rb', line 41

def opts_on *opts, &block
  OPTS[:user_options] << {:options => opts, :block => block }
end

#opts_required(*args) ⇒ Object



45
46
47
# File 'lib/bin_diesel.rb', line 45

def opts_required *args
  OPTS[:required_options] += args
end

#post_initialize(&block) ⇒ Object



27
28
29
30
31
# File 'lib/bin_diesel.rb', line 27

def post_initialize &block
  define_method :post_initialize do
    instance_eval(&block)
  end
end

#run(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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