Class: Autorake::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/autorake/application.rb

Direct Known Subclasses

MkConfig

Defined Under Namespace

Classes: Done, Option

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attr_bang(*syms) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/autorake/application.rb', line 24

def attr_bang *syms
  syms.each { |sym|
    define_method :"#{sym}!" do
      instance_variable_set :"@#{sym}", true
    end
  }
  nil
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/autorake/application.rb', line 35

def run
  process_options do
    while (arg = $*.shift) do
      case arg
        when /\A--/ then
          a, val = $'.split "=", 2
          do_option a do val || $*.shift end
        when /\A-/ then
          arg = $'
          until (a = arg.slice! 0, 1).empty? do
            do_option a do
              unless arg.empty? then
                arg.slice! 0, arg.length
              else
                $*.shift
              end
            end
          end
        else
          n, v = arg.split "="
          environ n, v||"1"
      end
    end
  end
  execute
rescue Done
rescue
  raise if @verbose
  $stderr.puts "#$! (#{$!.class})"
  exit 1
end