class Milestoner::Configuration::Transformers::Gems::URI

Conditionally updates project URI based on specification home page URL.

Attributes

key[R]
path[R]

Public Class Methods

new(key = :project_uri, path: " click to toggle source
Calls superclass method
# File lib/milestoner/configuration/transformers/gems/uri.rb, line 15
def initialize(key = :project_uri, path: "#{Pathname.pwd.basename}.gemspec", **)
  @key = key
  @path = path
  super(**)
end

Public Instance Methods

call(attributes) click to toggle source
# File lib/milestoner/configuration/transformers/gems/uri.rb, line 21
def call attributes
  process attributes
  Success attributes
rescue KeyError => error
  Failure step: :transform,
          payload: "Unable to transform #{key.inspect}, missing specifier: " \
                   "\"#{error.message[/<.+>/]}\"."
end

Private Instance Methods

process(attributes) click to toggle source
# File lib/milestoner/configuration/transformers/gems/uri.rb, line 34
def process attributes
  attributes.fetch(key) { spec_loader.call(path).homepage_url }
            .then { |value| value.match?(/%<.+>s/) ? format(value, attributes) : value }
            .then { |value| attributes.merge! key => value unless value.empty? }
end