Class: Rake::Task

Inherits:
Object
  • Object
show all
Includes:
Opt::KeywordArgs
Defined in:
lib/rake/opt/keyword_args/patches/rake/task.rb

Constant Summary

Constants included from Opt::KeywordArgs

Opt::KeywordArgs::PARAM_SEPARATOR

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Opt::KeywordArgs

included

Class Method Details

.__define_task_before_keyword_args__Object

Save the original define_task module method



51
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 51

alias_method "__define_task_before_keyword_args__", "define_task"

.define_task(*args, &block) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 52

def define_task(*args, &block)
  if Rake.application.last_args
    return define_parameterized_task(*args, &block)
  else
    return self.__define_task_before_keyword_args__(*args, &block)
  end
end

Instance Method Details

#__execute_before_keyword_args__Object

Save the original execute instance method



18
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 18

alias_method "__execute_before_keyword_args__", "execute"

#__invoke_before_keyword_args__Object

Save the original invoke instance method



7
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 7

alias_method "__invoke_before_keyword_args__", "invoke"

#execute(*args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 20

def execute (*args)
  if self.arg_options && args.first.is_a?(Hash)
    self.__execute_before_keyword_args__(Rake::TaskArguments.new(arg_names, [arg_hash_to_str(args.first)]))
  else
    self.__execute_before_keyword_args__(*args)
  end
end

#invoke(*args) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 9

def invoke (*args)
  if self.arg_options && args.first.is_a?(Hash)
    self.__invoke_before_keyword_args__(arg_hash_to_str(args.first))
  else
    self.__invoke_before_keyword_args__(*args)
  end
end

#invoke_prerequisites(task_args, invocation_chain) ⇒ Object

:nodoc:



28
29
30
31
32
33
34
35
36
37
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 28

def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
  if application.options.always_multitask
    invoke_prerequisites_concurrently(task_args, invocation_chain)
  else
    prerequisite_tasks.each do |p|
      merged_args = self.verify_and_merge_args(task_args)
      p.invoke_with_call_chain(extract_prerequisite_args(task_args,p), invocation_chain)
    end
  end
end

#invoke_prerequisites_concurrently(task_args, invocation_chain) ⇒ Object

:nodoc:



39
40
41
42
43
44
45
46
47
# File 'lib/rake/opt/keyword_args/patches/rake/task.rb', line 39

def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
  futures = prerequisite_tasks.map do |p|
    merged_args = self.verify_and_merge_args(task_args)
    application.thread_pool.future(p) do |r|
      r.invoke_with_call_chain(extract_prerequisite_args(task_args,p), invocation_chain)
    end
  end
  futures.each { |f| f.value }
end