Sha256: c5199ba761918c0cedf06bf174a3ce645ef4b9e73f9051c211fb055cee287341

Contents?: true

Size: 904 Bytes

Versions: 12

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module Uricp::Strategy
  class LocalLink
    include Uricp::Strategy::Common

    def appropriate?
      return proposal if !compression_required? &&
                         all_local_files? &&
                         !format_change? &&
                         linkable?

      debug "#{self.class.name}: not appropriate"
      false
    end

    def command
      "ln -fT #{from.path} #{to.path};"
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = @proposed_options['to_uri']
      self
    end

    def linkable?
      from_path_dir = File.dirname(from.path)
      to_path_dir = File.dirname(to.path)
      File.directory?(from_path_dir) && File.directory?(to_path_dir) &&
        File.stat(from_path_dir).dev == File.stat(to_path_dir).dev &&
        (!File.exist?(to.path) || File.file?(to.path))
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
uricp-0.0.37 lib/uricp/strategy/local_link.rb
uricp-0.0.36 lib/uricp/strategy/local_link.rb
uricp-0.0.35 lib/uricp/strategy/local_link.rb
uricp-0.0.34 lib/uricp/strategy/local_link.rb
uricp-0.0.32 lib/uricp/strategy/local_link.rb
uricp-0.0.31 lib/uricp/strategy/local_link.rb
uricp-0.0.30 lib/uricp/strategy/local_link.rb
uricp-0.0.29 lib/uricp/strategy/local_link.rb
uricp-0.0.28 lib/uricp/strategy/local_link.rb
uricp-0.0.27 lib/uricp/strategy/local_link.rb
uricp-0.0.26 lib/uricp/strategy/local_link.rb
uricp-0.0.25 lib/uricp/strategy/local_link.rb