Class: ARake::Application

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

Instance Method Summary collapse

Constructor Details

#initialize(top_level_self) ⇒ Application

Returns a new instance of Application.



11
12
13
14
15
16
# File 'lib/arake.rb', line 11

def initialize(top_level_self)
  @_rake = nil
  @_watchr = nil
  @_watchr_script = nil
  @top_level_self = top_level_self
end

Instance Method Details

#_create_custom_watchrObject



44
45
46
# File 'lib/arake.rb', line 44

def _create_custom_watchr
  Watchr::Controller.new(watchr_script, Watchr.handler.new)
end

#_create_custom_watchr_scriptObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/arake.rb', line 56

def _create_custom_watchr_script
  a = self
  s = Watchr::Script.new
  (class << s; self; end).class_eval do
    define_method :parse! do
      @ec.instance_eval do
        a.rake_tasks.each do |t|
          t.prerequisites.each do |p|
            watch "^#{Regexp.escape p}$" do
              a.rake.reenable_all_tasks
              a.rake.invoke_root_tasks_of(t)
            end
          end
        end
      end
    end
  end
  s
end

#rakeObject

Misc.



32
33
34
# File 'lib/arake.rb', line 32

def rake
  @_rake ||= CustomRakeAppliation.new
end

#rake_tasksObject



36
37
38
# File 'lib/arake.rb', line 36

def rake_tasks
  rake.tasks
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/arake.rb', line 18

def run
  original_Rake_application = Rake.application
  begin
    Rake.application = rake

    Rake.application.run
    watchr.run
  ensure
    Rake.application = original_Rake_application
  end
end

#watchrObject



40
41
42
# File 'lib/arake.rb', line 40

def watchr
  @_watchr ||= _create_custom_watchr
end

#watchr_rulesObject



48
49
50
# File 'lib/arake.rb', line 48

def watchr_rules
  watchr_script.rules
end

#watchr_scriptObject



52
53
54
# File 'lib/arake.rb', line 52

def watchr_script
  @_watchr_script ||= _create_custom_watchr_script
end