Sha256: 79945e361617218db1d0c6675540637bc7f1277fee1f9c326a44f1bbd7c73513

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"

module Milestoner
  module Configuration
    module Transformers
      module Gems
        # Conditionally updates project label based on specification label.
        class Label
          include Import[:spec_loader]
          include Dry::Monads[:result]

          def initialize(key = :project_label, path: "#{Pathname.pwd.basename}.gemspec", **)
            @key = key
            @path = path
            super(**)
          end

          def call attributes
            attributes.fetch(key) { spec_loader.call(path).label }
                      .then { |value| value unless value == "Undefined" }
                      .then { |value| Success attributes.merge!(key => value) }
          end

          private

          attr_reader :key, :path
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/configuration/transformers/gems/label.rb
milestoner-17.10.0 lib/milestoner/configuration/transformers/gems/label.rb
milestoner-17.9.0 lib/milestoner/configuration/transformers/gems/label.rb