Sha256: dcff4f7fe0fa978e4f5b07f856c2a57c6cec3a9c14d5f73d7523c20615c31e65

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'thor'
require 'thor-scmversion/scm_version'
require 'thor-scmversion/git_version'
require 'thor-scmversion/p4_version'
require 'thor-scmversion/shell_utils'

module ThorSCMVersion
  class Tasks < Thor
    namespace "version"

    desc "bump TYPE", "Bump version number (type is major, minor, patch or auto)"
    def bump(type)
      current_version.bump! type
      begin
        say "Creating and pushing tags", :yellow
        current_version.tag
        say "Writing files: #{version_files.join(', ')}", :yellow
        write_version
        say "Tagged: #{current_version}", :green
      rescue => e
        say "Tagging #{current_version} failed due to error", :red
        say e, :red
        exit 1
      end
    end

    desc "current", "Show current SCM tagged version"
    def current
      write_version
      say current_version.to_s
    end

    private
    def current_version
      @current_version ||= ThorSCMVersion.versioner.from_path
    end

    def write_version
      ver = current_version.to_s
      version_files.each do |ver_file|
        File.open(ver_file, 'w+') do |f| 
          f.write ver
        end
      end
      ver
    end

    eval "def source_root ; Pathname.new File.dirname(__FILE__) ; end"
    def version_files
      [
       source_root.join('VERSION')
      ]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thor-scmversion-0.2.4 lib/thor-scmversion.rb
thor-scmversion-0.2.3 lib/thor-scmversion.rb
thor-scmversion-0.2.2 lib/thor-scmversion.rb
thor-scmversion-0.2.1 lib/thor-scmversion.rb