Sha256: e13b583015c2507564e2ce347a4e397d62fca61185628151366652ca92f5eb66

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module VersionInfo 
  class RakeTasks
    include Rake::DSL
    
    def self.install(opts = {})
      #dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1]
      dir = File.dirname(Rake.application.rakefile_location)
      self.new(dir, opts).install
    end
    
    attr_reader :root_path
    attr_reader :target

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

    def install
      namespace :vinfo do

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

        desc "Show current version tag and create version_info.yml if missing"
        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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
version_info-1.1.4 lib/version_info/rake_tasks.rb
version_info-1.1.2 lib/version_info/rake_tasks.rb
version_info-1.1.1 lib/version_info/rake_tasks.rb
version_info-1.1.0 lib/version_info/rake_tasks.rb