Sha256: 759d58ddeb21507b1a0bbac98ddf7e781adfd53a6318bd9fa9c2d69adc54fb4e

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'minarai/actions/base'

module Minarai
  module Actions
    class Link < Base
      attribute :destination, required: true, type: String
      attribute :source, required: true, type: String

      def call
        abort_with_runtime_error unless runnable?
        super
      end

      def run
        link
      end

      private

      def link
        run_specific_command(:link_file_to, destination, source)
      end

      def complete?
        existed_file?
      end

      def readable_source?
        !source.nil? && ::File.readable?(source)
      end

      def runnable?
        readable_source?
      end

      def abort_with_runtime_error
        Minarai::Logger.errorr(runtime_error) and abort
      end

      def runtime_error
        Minarai::Errors::AttributeValidationError.new('source', 'is not readable file', name)
      end

      def existed_file?
        check_specific_command(:check_file_is_linked_to, destination, source)
      end

      def name
        super || "create symlink #{repository} to #{destination}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minarai-0.0.3 lib/minarai/actions/link.rb
minarai-0.0.2 lib/minarai/actions/link.rb
minarai-0.0.1 lib/minarai/actions/link.rb