Module: Grably::Core::ApplicationEnchancer

Included in:
Rake::Application
Defined in:
lib/grably/core/app/enchancer.rb

Overview

Wraps top_level method. To hook start/finish

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other_class) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/grably/core/app/enchancer.rb', line 6

def included(other_class) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  other_class.class_eval do
    alias_method :old_top, :top_level

    def top_level(*_args)
      puts 'Building profile '.yellow.bright + c.profile.join('/')
      if Grably.export?
        old_top
        export(Grably.export_path)
      else
        measure_time { old_top }
      end
    end
  end
end

Instance Method Details

#export(path) ⇒ Object



23
24
25
26
# File 'lib/grably/core/app/enchancer.rb', line 23

def export(path)
  return unless path
  save_obj(Grably.export_path, Grably.exports)
end

#measure_timeObject



28
29
30
31
32
33
# File 'lib/grably/core/app/enchancer.rb', line 28

def measure_time
  ts = Time.now
  yield
  te = Time.now
  puts "Total time: #{te - ts} seconds (#{ts} -> #{te})".yellow.bright
end