Class: VersionInfo::RakeTasks

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/version_info/rake_tasks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path, opts) ⇒ RakeTasks

Returns a new instance of RakeTasks.



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

def initialize(root_path, opts)
  @root_path = root_path
  @target = opts[:target]
end

Instance Attribute Details

#root_pathObject (readonly)

Returns the value of attribute root_path.



10
11
12
# File 'lib/version_info/rake_tasks.rb', line 10

def root_path
  @root_path
end

#targetObject (readonly)

Returns the value of attribute target.



11
12
13
# File 'lib/version_info/rake_tasks.rb', line 11

def target
  @target
end

Class Method Details

.install(opts = {}) ⇒ Object



5
6
7
8
# File 'lib/version_info/rake_tasks.rb', line 5

def self.install(opts = {})
  dir = File.dirname(Rake.application.rakefile_location)
  self.new(dir, opts).install
end

Instance Method Details

#installObject



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
# File 'lib/version_info/rake_tasks.rb', line 18

def install
  namespace :vinfo do

    desc "Show version file format & name"
    task :file do
      puts "#{VersionInfo.file_format.to_s} format: #{target::VERSION.file_name}"
    end

    desc "Show complete version info"
    task :inspect do
      puts target::VERSION.inspect
    end

    desc "Show tag. Create version file if none"
    task :show do
      puts target::VERSION.tag
      target::VERSION.save unless File.exist?(target::VERSION.file_name)
    end
    
    VersionInfo.segments.each do |sgm|
      desc "Bumps version segment #{sgm.to_s.upcase}"
      task sgm.to_sym do
        target::VERSION.bump(sgm)
        puts "version changed to #{target::VERSION}"
        target::VERSION.save
      end
    end
  end
end