Class: Rookie::Tasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/rookie/tasks.rb,
lib/rookie/tasks/gem.rb,
lib/rookie/tasks/git.rb,
lib/rookie/tasks/console.rb

Overview

Provides many useful tasks, like the Gem, Git and Console tasks.

Don't forget to call #define_tasks! after creating an instance of this class!

Defined Under Namespace

Classes: Console, Gem, Git

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemspec, opts = {}) {|_self| ... } ⇒ Tasks

Initializes the tasks with the given gem specification and options.

Yields the new instance if given a block.

Yields:

  • (_self)

Yield Parameters:

  • _self (Rookie::Tasks)

    the object that the method was called on



26
27
28
29
30
31
# File 'lib/rookie/tasks.rb', line 26

def initialize(gemspec, opts = {})
  self.gem = Tasks::Gem.new gemspec
  self.git = Tasks::Git.new gem.spec.version.to_s
  self.console = Tasks::Console.new gem.spec, opts
  yield self if block_given?
end

Instance Attribute Details

#consoleObject

The Console task.



21
22
23
# File 'lib/rookie/tasks.rb', line 21

def console
  @console
end

#gemObject

The Gem task.



15
16
17
# File 'lib/rookie/tasks.rb', line 15

def gem
  @gem
end

#gitObject

The Git task.



18
19
20
# File 'lib/rookie/tasks.rb', line 18

def git
  @git
end

Instance Method Details

#define_tasks!Object

Defines the tasks for all initialized (not nil) tasks.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rookie/tasks.rb', line 34

def define_tasks!
  setup_tasks, clean_tasks, release_tasks = [], [], []

  if git
    git.define_tasks!
    release_tasks << 'git:release'
  end

  if gem
    gem.define_tasks!
    setup_tasks << 'gem:setup'
    clean_tasks << 'gem:clean'
    release_tasks << 'gem:release'
  end

  console.define_tasks! if console

  desc 'Setup project'
  task :setup => setup_tasks

  desc 'Remove temporary files'
  task :clean => clean_tasks

  desc 'Release project'
  task :release => release_tasks + clean_tasks

  task :default => :setup
end