Sha256: e4570265d12a5bc54a9a89432df2164dfb881de40e860244f5ae5b20fa6b0537

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

module PrLog
  # Extract default configuration from a gem specification
  class Gemspec
    pattr_initialize :specification, :milestone_format

    def github_repository
      unless specification.homepage =~ %r{https?://github.com/}
        raise(NonGithubHomepage,
              'Gemspec does not have GitHub hompage URL.')
      end

      specification.homepage.split('github.com/').last
    end

    def version_milestone
      milestone_format % version_components
    end

    private

    def version_components
      components = specification.version.to_s.split('.')

      [:major, :minor, :patch]
        .each_with_index
        .each_with_object({}) do |(name, index), result|
        result[name] = components[index]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pr_log-0.3.0 lib/pr_log/gemspec.rb
pr_log-0.2.0 lib/pr_log/gemspec.rb