3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/version_info/thor_tasks.rb', line 3
def self.install(opts = {})
Class.new(::Thor) do
@target = opts[:target]
class << self
attr_reader :target
end
namespace :vinfo
desc "file", "Show version file format & name"
def file
puts "#{VersionInfo.file_format.to_s} format: #{target::VERSION.file_name}"
end
desc "show", "Show tag. Create version file if none"
def show
puts target::VERSION.tag
target::VERSION.save unless File.exist?(target::VERSION.file_name)
end
desc "inspect", "Show complete version info"
def inspect
puts target::VERSION.inspect
end
desc "bump SEGMENT=patch", "bumps segment: [#{VersionInfo.segments.join(', ')}]"
def bump(sgm = :patch)
target::VERSION.bump(sgm)
puts "version changed to #{target::VERSION}"
target::VERSION.save
end
protected
def target
self.class.target
end
end
end
|