Sha256: 0f36539b870f1054839a110d488a455b3392d7ffa5e7e5287d8874ccf66c0ba4

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require "chandler/changelog"
require "chandler/git"
require "chandler/github"
require "chandler/logger"

module Chandler
  class Configuration
    attr_accessor :changelog_path, :git_path, :github_repository, :dry_run,
                  :tag_prefix, :logger, :environment

    def initialize
      @changelog_path = "CHANGELOG.md"
      @git_path = ".git"
      @logger = Chandler::Logger.new
      @dry_run = false
    end

    def dry_run?
      dry_run
    end

    def git
      @git ||= Chandler::Git.new(:path => git_path, :tag_mapper => tag_mapper)
    end

    def github
      @github ||= Chandler::GitHub.new(
        :repository => github_repository,
        :config => self
      )
    end

    def changelog
      @changelog ||= Chandler::Changelog.new(:path => changelog_path)
    end

    def github_repository
      @github_repository || git.origin_remote
    end

    def tag_mapper
      return ->(tag) { tag } if tag_prefix.nil?
      ->(tag) { tag[/^#{Regexp.escape(tag_prefix)}(.*)/, 1] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chandler-0.6.0 lib/chandler/configuration.rb