Sha256: 6607ed855e6734f2dd3d499b5464d6c5233f60f2fbb9eb81cdcb5c73252b65ba

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

class Jeweler
  module Bumping
    # Bumps the patch version.
    #
    # 1.5.1 -> 1.5.2
    def bump_patch_version()
      patch = self.patch_version.to_i + 1

      write_version(major_version, minor_version, patch)
    end

    # Bumps the minor version.
    #
    # 1.5.1 -> 1.6.0
    def bump_minor_version()
      minor = minor_version.to_i + 1

      write_version(major_version, minor)
    end

    # Bumps the major version.
    #
    # 1.5.1 -> 2.0.0
    def bump_major_version()
      major = major_version.to_i + 1

      write_version(major)
    end

    # Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
    def write_version(major = 0, minor = 0, patch = 0)
      major ||= 0
      minor ||= 0
      patch ||= 0
      
      File.open(version_yaml_path, 'w+') do |f|
        version_hash = {
          'major' => major.to_i,
          'minor' => minor.to_i,
          'patch' => patch.to_i
        }
        YAML.dump(version_hash, f)
      end

      refresh_version
      
      @gemspec.version = version

      puts "Wrote to #{version_yaml_path}: #{version}"

      commit_version
    end

    def commit_version
      if @repo
        @repo.add('VERSION.yml')
        @repo.commit("Version bump to #{version}", 'VERSION.yml')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
technicalpickles-jeweler-0.4.1 lib/jeweler/bumping.rb