Class: Tumbler::RakeTasks

Inherits:
Object
  • Object
show all
Defined in:
lib/tumbler/rake_tasks.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ RakeTasks

Returns a new instance of RakeTasks.



13
14
15
# File 'lib/tumbler/rake_tasks.rb', line 13

def initialize(manager)
  @manager = manager
end

Class Method Details

.register(base, name) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/tumbler/rake_tasks.rb', line 4

def self.register(base, name)
  if manager = Tumbler.load(base)
    tasks = RakeTasks.new(manager)
    tasks.activate_project_tasks(name)
  else
    raise "This is not properly configured for tumbler probably due to a lack of a Tumbler configuration file."
  end
end

Instance Method Details

#activate_project_tasks(protect_namespace) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/tumbler/rake_tasks.rb', line 17

def activate_project_tasks(protect_namespace)
  tasks = proc do
    namespace :tumbler do
      task :preflight do
      end
    end

    namespace :gem do
      desc "Build the gem"
      task :build => 'tumbler:preflight' do
        @manager.gem.build
      end

      desc "Push the gem"
      task :push => 'tumbler:preflight' do
        @manager.gem.push
      end

      desc "Install the gem"
      task :install => 'tumbler:preflight' do
        @manager.gem.install
      end
    end

    namespace :version do
      desc "Tag current version into git"
      task :tag => 'tumbler:preflight' do
        @manager.tag
      end
    
      desc "Push current version into git"
      task :push => 'tumbler:preflight' do
        @manager.tag_and_push
      end
    
      @manager.version.field_names.each do |field|
        namespace field do 
          desc "Bump version from #{@manager.version.to_s} ->  #{@manager.version.value.bump(field).to_s}"
          task :bump => 'tumbler:preflight' do
            @manager.bump_and_commit(field)
          end

          task :push => 'tumbler:preflight' do
            @manager.tag_and_push(field)
          end

          desc "Bump version from #{@manager.version.to_s} ->  #{@manager.version.value.bump(field).to_s} and push"
          task :release => 'tumbler:preflight' do
            @manager.bump_and_push(field)
          end
        end
      end
    end
  end

  if protect_namespace
    namespace protect_namespace, &tasks
  else
    tasks.call
  end
end