Module: BinDiesel::InstanceMethods
- Defined in:
- lib/bin_diesel.rb
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
- #error_message(text) ⇒ Object
- #info_message(text) ⇒ Object
- #initialize(args = ["--help"]) ⇒ Object
- #message(text) ⇒ Object
- #post_initialize ⇒ Object
- #run ⇒ Object
Instance Method Details
#dry_run? ⇒ 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 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 text "** #{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 rescue OptionParser::MissingArgument => e e. exit unhappy_ending end @verbose = @options.verbose @dry_run = @options.dry_run setup_option_accessors begin post_initialize rescue Exception => e e. exit unhappy_ending end end |
#message(text) ⇒ Object
91 92 93 |
# File 'lib/bin_diesel.rb', line 91 def text puts text if verbose end |
#post_initialize ⇒ Object
87 88 89 |
# File 'lib/bin_diesel.rb', line 87 def post_initialize # TODO: EXPLAIN ME end |
#run ⇒ Object
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 |