Sha256: 8f8cbb0f2984b0969da309409e4c41293b6152862906d50cdaefe9dbcdcc85dd

Contents?: true

Size: 801 Bytes

Versions: 4

Compression:

Stored size: 801 Bytes

Contents

module Relinker
  class Application
    attr_reader :options, :dir

    def initialize(dir, options = {})
      @dir = dir
      @options = merge_options(options)
    end

    def run
      discoverer.collect(@dir)
      linker.relink_identicals
    end

    private

    def discoverer
      @_discoverer ||= Discoverer.new(cache_file, @options)
    end

    def linker
      @_linker ||= Linker.new(cache_file, @options)
    end

    def cache_file
      @_cache_file ||= "#{cache_dir}/relinker_cache_#{Time.now.to_i}"
    end

    def cache_dir
      options[:cache_dir]
    end

    def merge_options(options = {})
      options = options.map { |key, val| [key.to_sym, val] }.to_h
      default_options.merge(options)
    end

    def default_options
      { cache_dir: "/tmp" }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
relinker-1.1.0 lib/relinker/application.rb
relinker-1.0.2 lib/relinker/application.rb
relinker-1.0.1 lib/relinker/application.rb
relinker-1.0.0 lib/relinker/application.rb