Sha256: 53e299575bea974cb0b7c6926035a326c5cc8734fce3cb38093427816111d3fd

Contents?: true

Size: 633 Bytes

Versions: 3

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"
require "refinements/hash"
require "refinements/string"

module Milestoner
  module Configuration
    module Transformers
      # Conditionally updates label based on current directory.
      module Project
        using Refinements::String
        using Refinements::Hash

        Label = lambda do |attributes, key = :project_label, default: Pathname.pwd.basename.to_s|
          attributes.fetch_value(key) { default.titleize }
                    .then { |value| Dry::Monads::Success attributes.merge!(key => value) }
        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/project/label.rb
milestoner-17.10.0 lib/milestoner/configuration/transformers/project/label.rb
milestoner-17.9.0 lib/milestoner/configuration/transformers/project/label.rb