Module: Buildr::Extension::ClassMethods
- Defined in:
- lib/buildr/core/project.rb
Overview
Methods added to the extension module when including Extension.
Instance Method Summary collapse
-
#after_define(*args, &block) ⇒ Object
This block is called once for the project with the project instance, right after running the project definition.
-
#before_define(*args, &block) ⇒ Object
This block is called once for the project with the project instance, right before running the project definition.
-
#extended(base) ⇒ Object
:nodoc:.
-
#first_time(&block) ⇒ Object
This block will be called once for any particular extension included in Project.
-
#included(base) ⇒ Object
:nodoc:.
Instance Method Details
#after_define(*args, &block) ⇒ Object
This block is called once for the project with the project instance, right after running the project definition. You can use this to do any post-processing that depends on the project definition.
The block may be named and dependencies may be declared similar to Rake task dependencies:
after_define(:my_setup) do |project|
# do stuff on project
end
# my_setup code must run before :compile (but only after project is defined)
after_define(:compile => :my_setup)
860 861 862 863 864 865 866 867 868 |
# File 'lib/buildr/core/project.rb', line 860 def after_define(*args, &block) if args.empty? name = self.name deps = [] else name, args, deps = Buildr.application.resolve_args(args) end module_callbacks << Callback.new(:after_define, name, deps, block) end |
#before_define(*args, &block) ⇒ Object
This block is called once for the project with the project instance, right before running the project definition. You can use this to add tasks and set properties that will be used in the project definition.
The block may be named and dependencies may be declared similar to Rake task dependencies:
before_define(:my_setup) do |project|
# do stuff on project
end
# my_setup code must run before :compile
before_define(:compile => :my_setup)
836 837 838 839 840 841 842 843 844 |
# File 'lib/buildr/core/project.rb', line 836 def before_define(*args, &block) if args.empty? name = self.name deps = [] else name, args, deps = Buildr.application.resolve_args(args) end module_callbacks << Callback.new(:before_define, name, deps, block) end |
#extended(base) ⇒ Object
:nodoc:
803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/buildr/core/project.rb', line 803 def extended(base) #:nodoc: # When extending project, merge after_define callbacks and call before_define callback(s) # immediately if Project === base merge_callbacks(base.callbacks, module_callbacks.select { |cb| cb.phase == :after_define }) calls = module_callbacks.select { |cb| cb.phase == :before_define } calls.each do |cb| cb.blocks.each { |b| b.call(base) } unless base.calledback[cb] base.calledback[cb] = cb end end end |
#first_time(&block) ⇒ Object
This block will be called once for any particular extension included in Project. You can use this to setup top-level and local tasks.
818 819 820 |
# File 'lib/buildr/core/project.rb', line 818 def first_time(&block) module_callbacks << Callback.new(:first_time, self.name, [], block) end |
#included(base) ⇒ Object
:nodoc:
791 792 793 794 795 796 797 798 799 800 801 |
# File 'lib/buildr/core/project.rb', line 791 def included(base) #:nodoc: # When included in Project, add module instance, merge callbacks and call first_time. if Project == base && !base.extension_modules.include?(module_callbacks) base.extension_modules << module_callbacks merge_callbacks(base.global_callbacks, module_callbacks) first_time = module_callbacks.select { |c| c.phase == :first_time } first_time.each do |c| c.blocks.each { |b| b.call } end end end |