Sha256: f1b61f3233c240ec43ef4d72f2830fe86c13cc35262eed7eedc508529868712a

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 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", **)
            super(**)
            @key = key
            @path = path
          end

          def call attributes
            attributes.fetch key do
              value = spec_loader.call(path).label
              attributes.merge! key => value unless value == "Undefined"
            end

            Success attributes
          end

          private

          attr_reader :key, :path
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
milestoner-18.12.0 lib/milestoner/configuration/transformers/gems/label.rb