Sha256: 3c36280d76e85fe9555de629dccb31a95ddb9ba67412e7a166b183280bde836a

Contents?: true

Size: 1.45 KB

Versions: 25

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'platformos_check/version'

module PlatformosCheck
  class Releaser
    ROOT = File.expand_path('../..', __dir__)
    LIB = File.join(ROOT, 'lib')

    class VersionError < StandardError; end

    def release(version)
      raise VersionError, "Missing version argument." if version.nil?
      raise VersionError, "Version should be a string." unless version.is_a?(String)
      raise VersionError, "Version should be a valid semver version." unless /^\d+\.\d+.\d+$/.match?(version)

      update_docs(version)
      update_version(version)
    end

    def update_version(version)
      version_file_path = File.join(LIB, 'platformos_check/version.rb')
      version_file = File.read(version_file_path)
      updated_version_file = version_file.gsub(PlatformosCheck::VERSION, version)

      return if updated_version_file == version_file

      puts "Updating version to #{version} in #{version_file_path}."
      File.write(version_file_path, updated_version_file)
    end

    def update_docs(version)
      Dir[ROOT + '/docs/checks/*.md'].each do |filename|
        doc_content = File.read(filename)
        updated_doc_content = doc_content.gsub('PLATFORMOS_CHECK_VERSION', version)
        next if updated_doc_content == doc_content

        puts "Replacing `PLATFORMOS_CHECK_VERSION` with #{version} in #{Pathname.new(filename).relative_path_from(ROOT)}"
        File.write(filename, updated_doc_content)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/releaser.rb
platformos-check-0.4.13 lib/platformos_check/releaser.rb
platformos-check-0.4.12 lib/platformos_check/releaser.rb
platformos-check-0.4.11 lib/platformos_check/releaser.rb
platformos-check-0.4.10 lib/platformos_check/releaser.rb
platformos-check-0.4.9 lib/platformos_check/releaser.rb
platformos-check-0.4.8 lib/platformos_check/releaser.rb
platformos-check-0.4.7 lib/platformos_check/releaser.rb
platformos-check-0.4.6 lib/platformos_check/releaser.rb
platformos-check-0.4.5 lib/platformos_check/releaser.rb
platformos-check-0.4.4 lib/platformos_check/releaser.rb
platformos-check-0.4.3 lib/platformos_check/releaser.rb
platformos-check-0.4.2 lib/platformos_check/releaser.rb
platformos-check-0.4.1 lib/platformos_check/releaser.rb
platformos-check-0.4.0 lib/platformos_check/releaser.rb
platformos-check-0.3.3 lib/platformos_check/releaser.rb
platformos-check-0.3.1 lib/platformos_check/releaser.rb
platformos-check-0.3.0 lib/platformos_check/releaser.rb
platformos-check-0.2.2 lib/platformos_check/releaser.rb
platformos-check-0.2.1 lib/platformos_check/releaser.rb