Harbor Documentation

Attributes

  • root [RW] (Not documented)
  • options [RW] (Not documented)

Public Class Methods

file_mask()

      # File lib/harbor/file_store/local.rb, line 8
 8:       def self.file_mask
 9:         @@file_mask
10:       end

file_mask=(value)

      # File lib/harbor/file_store/local.rb, line 12
12:       def self.file_mask=(value)
13:         @@file_mask = value
14:       end

new(path, options = {})

      # File lib/harbor/file_store/local.rb, line 16
16:       def initialize(path, options = {})
17:         path = "#{path}/" unless path =~ /.*\/$/
18:         @root = Pathname(path)
19: 
20:         @options = options
21: 
22:         ::FileUtils.mkdir_p(path.to_s)
23:       end

Public Instance Methods

delete(path)

      # File lib/harbor/file_store/local.rb, line 44
44:       def delete(path)
45:         path = strip_leading_slash(path)
46:         ::FileUtils.rm(@root + path)
47:         Harbor::File.rmdir_p((@root + path).parent.to_s)
48:       end

exists?(path)

      # File lib/harbor/file_store/local.rb, line 50
50:       def exists?(path)
51:         path = strip_leading_slash(path)
52:         (@root + path).exist?
53:       end

get(path)

      # File lib/harbor/file_store/local.rb, line 25
25:       def get(path)
26:         path = strip_leading_slash(path)
27:         Harbor::FileStore::File.new(self, path)
28:       end

local?()

      # File lib/harbor/file_store/local.rb, line 66
66:       def local?
67:         true
68:       end

open(path, mode = "r", &block)

      # File lib/harbor/file_store/local.rb, line 55
55:       def open(path, mode = "r", &block)
56:         path = strip_leading_slash(path)
57:         ::FileUtils.mkdir_p((@root + path).parent.to_s) unless (@root + path).parent.exist?
58:         ::File.open(@root + path, mode, &block)
59:       end

put(path, absolute_path)

      # File lib/harbor/file_store/local.rb, line 30
30:       def put(path, absolute_path)
31:         raise ArgumentError.new("Harbor::FileStore::Local#put[absolute_path] should be a path but was an IO") if absolute_path.is_a?(IO)
32:         path = strip_leading_slash(path)
33:         file = Harbor::FileStore::File.new(self, path)
34: 
35:         unless (@root + path).parent.exist?
36:           ::FileUtils.mkdir_p((@root + path).parent.to_s) 
37:         end
38: 
39:         ::FileUtils::cp(absolute_path, file.absolute_path)
40:         ::FileUtils::chmod(Harbor::FileStore::Local.file_mask, file.absolute_path)
41:         file
42:       end

size(path)

      # File lib/harbor/file_store/local.rb, line 61
61:       def size(path)
62:         path = strip_leading_slash(path)
63:         ::File.size(@root + path)
64:       end

Private Instance Methods

__size__()

      # File lib/harbor/file_store/local.rb, line 72
72:       def __size__
73:         `du -sk #{Shellwords.escape(@root.to_s)} | awk '{ print $1; }'`.chomp.to_i * 1024
74:       end

strip_leading_slash(path)

      # File lib/harbor/file_store/local.rb, line 76
76:       def strip_leading_slash(path)
77:         path = path[1..path.size - 1] if path =~ /^\//
78:         path
79:       end