Class: Rake::Application

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

Instance Method Summary collapse

Instance Method Details

#_runObject



10
# File 'lib/raken.rb', line 10

alias_method :_run, :run

#_standard_rake_optionsObject



9
# File 'lib/raken.rb', line 9

alias_method :_standard_rake_options, :standard_rake_options

#keyworded(opt) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/raken.rb', line 45

def keyworded opt
  JSON.parse('{' + opt.gsub(/(\w+):/, '"\1":') + '}').tap do |hash|
    hash.keys.each do |k|
      v = hash.delete(k)
      hash[k.to_sym] = v
    end
  end
rescue
  raise ArgumentError, "->#{opt}<- is not ruby keyword argument"
end

#pry_debug_alias(opt) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/raken.rb', line 56

def pry_debug_alias opt
  return unless opt
  {c: 'continue', s: 'step', n: 'next', f: 'finish'}.each_pair do |ali, cmd|
    Pry.commands.alias_command(ali, cmd) if opt.include?(ali.to_s)
  end
  Pry::Commands.command /^$/, "repeat last command" do
      _pry_.run_command Pry.history.to_a.last
  end if opt.include?('e')
end

#runObject



36
37
38
39
40
41
42
43
# File 'lib/raken.rb', line 36

def run
  _run
ensure
  tasks.each do |t|
    next unless t.beginning
    puts "#{t.name} #{t.beginning} -> #{t.ending} = #{t.duration}"
  end if options.time
end

#standard_rake_optionsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/raken.rb', line 12

def standard_rake_options
  [
    ['--time [all]',
     'time tasks',
     lambda { |value|
       options.time = value || true
     }
    ],
    ['--trace-tree OPTS',
     'https://github.com/turnon/trace_tree',
     lambda { |value|
       options.trace_tree = keyworded(value)
     }
    ],
    ['--pry [csnfe]',
     'invoke pry-byebug before task. `csnf` to enable stepping alias and `e` to repeat last command by hitting Enter',
     lambda { |value|
       options.pry_debug = true
       pry_debug_alias value
     }
    ]
  ] + _standard_rake_options
end