Module: Versionify
- Extended by:
- Rake::DSL
- Defined in:
- lib/versionify.rb,
lib/versionify/version.rb
Constant Summary collapse
- VERSION =
"0.2.4"
Class Method Summary collapse
- .bump(level = :patch) ⇒ Object
- .get_version ⇒ Object
- .install_rake_tasks ⇒ Object
- .print_version ⇒ Object
Class Method Details
.bump(level = :patch) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/versionify.rb', line 9 def self.bump level = :patch version = read_or_create case level when :major version[0] +=1 version[1] = 0 version[2] = 0 when :minor version[1] += 1 version[0] += (version[1].to_f / 10).to_i version[1] = (version[1].to_f / 10).to_s.split('.')[1].to_i version[2] = 0 when :patch version[2] += 1 end write version end |
.get_version ⇒ Object
29 30 31 |
# File 'lib/versionify.rb', line 29 def self.get_version read_or_create.join '.' end |
.install_rake_tasks ⇒ Object
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 |
# File 'lib/versionify.rb', line 37 def self.install_rake_tasks desc 'print the current source version' task :version do print_version end namespace :version do namespace :bump do desc 'bump the patch' task :patch do bump :patch print_version end desc 'bump the minor' task :minor do bump :minor print_version end desc 'bump the major' task :major do bump :major print_version end end end end |
.print_version ⇒ Object
33 34 35 |
# File 'lib/versionify.rb', line 33 def self.print_version puts "version #{get_version}" end |