Sha256: 93392f2f50701255f2c7415c34322a4592f4d28a25a25ea4d19fc96b9f9b3a85

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

# frozen_string_literal: true

module Flexdot
  class Console
    Status = Struct.new(:home_file, :result, :backuped)

    def initialize(dotfiles_dir)
      @dotfiles_dir = dotfiles_dir
    end

    def log(home_file)
      status = Status.new(home_file)
      yield(status)
      puts message_for(status)
    end

    private

    attr_reader :dotfiles_dir

    def message_for(status)
      [].tap { |msg|
        msg << "[#{status.result}]"
        msg << status.home_file.relative_path_from(dotfiles_dir)
        msg << '(backup)' if status.backuped
      }.join(' ')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flexdot-3.1.0 lib/flexdot/console.rb
flexdot-3.0.0 lib/flexdot/console.rb
flexdot-2.0.0 lib/flexdot/console.rb