Module: Tap::Support::Gems::Rake

Defined in:
lib/tap/support/gems/rake.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env.



22
23
24
# File 'lib/tap/support/gems/rake.rb', line 22

def env
  @env
end

Class Method Details

.extended(base) ⇒ Object



17
18
19
20
# File 'lib/tap/support/gems/rake.rb', line 17

def self.extended(base)
  Tap::Env.instance_for(Dir.pwd).activate unless Tap::Env.instance
  base.env = Tap::Env.instance
end

Instance Method Details

#collect_tasks(*args) ⇒ Object



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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/tap/support/gems/rake.rb', line 41

def collect_tasks(*args)
  # a little song and dance for compliance with
  # rake pre- and post-0.8.2
  argv = args.empty? ? ARGV : args[0]
  argv.collect! do |arg|
    next(arg) unless arg =~ /^:([a-z_\d]+):(.*)$/
    env_pattern = $1
    rake_task = $2
  
    next(arg) unless entry = env.find(:envs, env_pattern, false)
  
    mini_path, env = entry
    root_path = env.root.root
  
    if have_rakefile(root_path)
      # load sequence echos that in raw_load_rakefile
      puts "(in #{root_path})" unless options.silent
      current_global_rakefile = $rakefile
      $rakefile = @rakefile
    
      namespaces = Tap::Root.split(mini_path, false).delete_if do |segment| 
        segment.empty?
      end
    
      #if @rakefile != ''
      eval nest_namespace(%Q{load "#{File.join(root_path, @rakefile)}"}, namespaces.dup)
      #end
    
      $rakefile = current_global_rakefile
      @rakefile = nil
    
      namespaces << rake_task
      namespaces.join(":")
    else
      fail "No Rakefile found for '#{env_pattern}' (looking for: #{@rakefiles.join(', ')})"
    end
  end
  
  super
end

#enq_top_level(app) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tap/support/gems/rake.rb', line 24

def enq_top_level(app)
  # takes the place of rake.top_level
  if options.show_tasks
    display_tasks_and_comments
    exit
  elsif options.show_prereqs
    display_prerequisites
    exit
  else
    top_level_tasks.each do |task_string|
      name, args = parse_task_string(task_string)
      task = self[name]
      app.mq(task, :invoke, *args)
    end
  end  
end

#have_rakefile(dir = nil) ⇒ Object



82
83
84
85
# File 'lib/tap/support/gems/rake.rb', line 82

def have_rakefile(dir=nil)
  return super() if dir == nil
  Tap::Root.chdir(dir) { super() }
end