Module: BinDiesel::InstanceMethods

Defined in:
lib/bin_diesel.rb

Instance Method Summary collapse

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/bin_diesel.rb', line 79

def dry_run?
  @options.dry_run
end

#error_message(text) ⇒ Object



99
100
101
102
# File 'lib/bin_diesel.rb', line 99

def error_message text
  # Always print out error messages, regardless of verbose mode
  puts "!! #{text}"
end

#info_message(text) ⇒ Object



95
96
97
# File 'lib/bin_diesel.rb', line 95

def info_message text
  message "** #{text}"
end

#initialize(args = ["--help"]) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bin_diesel.rb', line 55

def initialize args=["--help"]
  @args = args
  @options = OpenStruct.new(:dry_run => false, :verbose => false)

  begin
    parse_options
  rescue OptionParser::MissingArgument => e
    error_message e.message
    exit unhappy_ending
  end

  @verbose = @options.verbose
  @dry_run = @options.dry_run

  setup_option_accessors

  begin
    post_initialize
  rescue Exception => e
    error_message e.message
    exit unhappy_ending
  end
end

#message(text) ⇒ Object



91
92
93
# File 'lib/bin_diesel.rb', line 91

def message text
  puts text if verbose
end

#post_initializeObject



87
88
89
# File 'lib/bin_diesel.rb', line 87

def post_initialize
  # TODO: EXPLAIN ME
end

#runObject

Raises:

  • (NotImplementedError)


83
84
85
# File 'lib/bin_diesel.rb', line 83

def run
  raise NotImplementedError, "#{self.class} does not implement method run. You may do this explictly, or via the class level DSL (recommended):\nrun do\n ...\nend"
end