Class: Rake::Task

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#beginningObject (readonly)

Returns the value of attribute beginning.



69
70
71
# File 'lib/raken.rb', line 69

def beginning
  @beginning
end

#endingObject (readonly)

Returns the value of attribute ending.



69
70
71
# File 'lib/raken.rb', line 69

def ending
  @ending
end

Instance Method Details

#_enhanceObject



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

alias_method :_enhance, :enhance

#apply_task_body(blk, *params) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/raken.rb', line 81

def apply_task_body blk, *params
  if application.options.time &&
      (application.options.time == 'all' || ARGV.include?(name))
    org_blk = blk
    blk = lambda { |*args|
      begin
        @beginning = Time.now
        org_blk.call *args
      ensure
        @ending = Time.now
      end
    }
  end

  return blk.call *params unless ARGV.include?(name)

  if application.options.trace_tree
    binding.trace_tree(**application.options.trace_tree) do
      blk.call *params
    end
  elsif application.options.pry_debug
    binding.pry
    blk.call *params
  else
    blk.call *params
  end
end

#durationObject



109
110
111
# File 'lib/raken.rb', line 109

def duration
  @ending - @beginning
end

#enhance(*args, &blk) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/raken.rb', line 71

def enhance *args, &blk
  if block_given?
    _enhance *args do |*params|
      apply_task_body blk, *params
    end
  else
    _enhance *args
  end
end