Class: MetaRake::Task
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- MetaRake::Task
- Includes:
- FileUtils
- Defined in:
- lib/metarake/task.rb
Overview
An abstract Rake task that builds a project if it is not published. The individual methods need to be implemented in a subclass. Concrete implementation are provided in Builder and Publisher modules. Complete sample Rakefiles are included in the examples directory.
Class Method Summary collapse
-
.discover! ⇒ Enumerable
Discover projects and build tasks for them.
-
.projects ⇒ Enumerable
abstract
Discovered project names.
Instance Method Summary collapse
-
#execute(*args) ⇒ Object
Publish the project after executing the task.
-
#initialize(*args) ⇒ Task
constructor
Automatically add action calling the #build method if it’s dtefined.
-
#needed? ⇒ Boolean
Project is “needed” only if it’s not published.
-
#publish! ⇒ Object
abstract
Runs after the project has been built in order to publish the build artifacts.
-
#published? ⇒ TrueClass, FalseClass
abstract
True if project is already published and doesn’t need to be rebuilt.
- #targets ⇒ Object abstract
Constructor Details
#initialize(*args) ⇒ Task
Automatically add action calling the #build method if it’s dtefined.
52 53 54 55 |
# File 'lib/metarake/task.rb', line 52 def initialize(*args) super @actions << lambda { |t| t.build } if self.respond_to?(:build) end |
Class Method Details
.discover! ⇒ Enumerable
Discover projects and build tasks for them.
25 26 27 28 29 30 31 |
# File 'lib/metarake/task.rb', line 25 def discover! projects.map do |prj| t = Rake.application.define_task(self, prj) t.comment = "Build #{prj}" t end end |
.projects ⇒ Enumerable
Discover projects to build.
Returns discovered project names.
17 18 19 |
# File 'lib/metarake/task.rb', line 17 def projects raise NotImplementedError end |
Instance Method Details
#execute(*args) ⇒ Object
Publish the project after executing the task.
63 64 65 66 67 68 69 70 |
# File 'lib/metarake/task.rb', line 63 def execute(*args) super if application..dryrun $stderr.puts "** Publish (dry run) #{name}" else self.publish! end end |
#needed? ⇒ Boolean
Project is “needed” only if it’s not published.
58 59 60 |
# File 'lib/metarake/task.rb', line 58 def needed? !self.published? end |
#publish! ⇒ Object
Publishes the project
Runs after the project has been built in order to publish the build artifacts.
42 43 44 |
# File 'lib/metarake/task.rb', line 42 def publish! raise NotImplementedError end |
#published? ⇒ TrueClass, FalseClass
Check whether the project has been published
Returns True if project is already published and doesn’t need to be rebuilt.
36 37 38 |
# File 'lib/metarake/task.rb', line 36 def published? raise NotImplementedError end |
#targets ⇒ Object
Array of project’s targets
47 48 49 |
# File 'lib/metarake/task.rb', line 47 def targets raise NotImplementedError end |