Sha256: 361a615dbde50356e2957ee77f0d0f1f82063de4444fda03e5ee5e066b743931

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

module AutoTagVersion
  class << self
    def tag!(tag)
      @tag = tag
      create_version_file
      commit_and_create_tag
    end

    private
    attr_reader :tag

    def content
      content = "module #{app}; VERSION = '#{tag}'; end\n"
      content += "# This file is created automatically by auto_tag_version gem\n"
      content += "# Documentation at https://github.com/rafaelbiriba/auto_tag_version"
    end

    def app
      Rails.application.class.parent_name
    end

    def version_file
      File.join("config", "initializers", "app_version.rb")
    end

    def create_version_file
      File.open(version_file, "w") { |f| f.write(content) }
    end

    def commit_and_create_tag
      `git add #{version_file} && git commit -m "Bumping version #{tag}" && git tag #{tag}`
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_tag_version-1.0.0 lib/auto_tag_version/utils.rb