Class: ActiveFolder::Metal::Adapters::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/activefolder/metal/adapters/local.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Local

Returns a new instance of Local.



9
10
11
# File 'lib/activefolder/metal/adapters/local.rb', line 9

def initialize(config)
  @config = config
end

Instance Method Details

#glob(path) ⇒ Object



39
40
41
42
43
44
# File 'lib/activefolder/metal/adapters/local.rb', line 39

def glob(path)
  paths = Dir.glob full_path(path)
  paths.map { |p| relative_path(p) }
rescue SystemCallError => e
  raise SystemError.new(e)
end

#mkdir_p(path) ⇒ Object



27
28
29
30
31
# File 'lib/activefolder/metal/adapters/local.rb', line 27

def mkdir_p(path)
  FileUtils.mkdir_p full_path(path)
rescue SystemCallError => e
  raise SystemError.new(e)
end

#read(path) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/activefolder/metal/adapters/local.rb', line 13

def read(path)
  File.read full_path(path)
rescue Errno::ENOENT => e
  raise NotFoundError.new(e)
rescue SystemCallError => e
  raise SystemError.new(e)
end

#rm_r(path) ⇒ Object



33
34
35
36
37
# File 'lib/activefolder/metal/adapters/local.rb', line 33

def rm_r(path)
  FileUtils.rm_r full_path(path)
rescue SystemCallError => e
  raise SystemError.new(e)
end

#write(path, data) ⇒ Object



21
22
23
24
25
# File 'lib/activefolder/metal/adapters/local.rb', line 21

def write(path, data)
  File.write(full_path(path), data)
rescue SystemCallError => e
  raise SystemError.new(e)
end