class Stow::Local

Attributes

base[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/stow/local.rb, line 4
def initialize(options = {})
  @base = options[:base]
  raise ArgumentError, 'Must supply base dir' unless @base
end

Public Instance Methods

get(path) click to toggle source
# File lib/stow/local.rb, line 18
def get(path)
  file = File.new(self, path)
  return file if ::File.file?(::File.expand_path(file.path, base))
  raise Stow::NotFoundError, "Unknown file '#{path}'"
end
put(file, options = {}) click to toggle source
# File lib/stow/local.rb, line 9
def put(file, options = {})
  path = options[:path]
  raise ArgumentError, 'Must supply path' unless path
  instance = File.new(self, path)
  instance.body = file
  instance.save
  instance
end