namespace :version do
  def version_path
    'lib/dm-cutie-ui/version.rb'
  end
  def version_template
    <<-VERSION_TEMPLATE
module DmCutieUI
  VERSION = '%s'.freeze
end
VERSION_TEMPLATE
  end
  
  def update_version(maj,min,rev)
    v = [maj,min,rev].join('.')
    File.open(version_path,'w') do |fp|
      fp.puts(version_template % v)
    end
    puts "New Version: #{v}"
  end
  
  desc "DM CutieUI Version"
  task :show do
    puts DmCutieUI::VERSION
  end
  
  desc "Bump the minor number"
  task :bump_minor do
    maj,min,rev = DmCutieUI::VERSION.split('.')
    min = min.to_i + 1
    rev = 0
    
    update_version(maj,min,rev)
  end
  
  desc "Bump the major number"
  task :bump_major do
    maj,min,rev = DmCutieUI::VERSION.split('.')
    maj = maj.to_i + 1
    min = 0
    rev = 0
    
    update_version(maj,min,rev)
  end
  
  desc "Bump the revision number"
  task :bump_rev do
    maj,min,rev = DmCutieUI::VERSION.split('.')
    rev = rev.to_i + 1
    
    update_version(maj,min,rev)
  end
end

