Class: Gat::Dependence::Folder
- Defined in:
- lib/gat/dependence/folder.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
-
#value(folder_name) ⇒ Object
readonly
Folder dependence value is special, because it can be the root folder or one subfolder at tree so, we dont have a value attribute but method, and this method check by folder_name, which folder do we want.
Attributes inherited from Base
#description, #name, #operation, #type
Instance Method Summary collapse
-
#evalue ⇒ Object
Folders.
-
#initialize(name, config, operation) ⇒ Folder
constructor
A new instance of Folder.
Constructor Details
#initialize(name, config, operation) ⇒ Folder
Returns a new instance of Folder.
12 13 14 15 16 17 18 |
# File 'lib/gat/dependence/folder.rb', line 12 def initialize(name, config, operation) super(name, config, operation) @type = config['type'] || 'normal' @tree = { } @path = config['path'] || '' @mode = config['mode'] || 0700 end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/gat/dependence/folder.rb', line 7 def config @config end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
8 9 10 |
# File 'lib/gat/dependence/folder.rb', line 8 def mode @mode end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/gat/dependence/folder.rb', line 6 def path @path end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
10 11 12 |
# File 'lib/gat/dependence/folder.rb', line 10 def tree @tree end |
#value(folder_name) ⇒ Object (readonly)
Folder dependence value is special, because it can be the root folder or one subfolder at tree so, we dont have a value attribute but method, and this method check by folder_name, which folder do we want
48 49 50 |
# File 'lib/gat/dependence/folder.rb', line 48 def value @value end |
Instance Method Details
#evalue ⇒ Object
Folders
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gat/dependence/folder.rb', line 21 def evalue if self.path.blank? raise GatgetConfigException.new("folder #{ self.name } doesnt have a path attribute at config", 'evalue_folder_dependence') end # mount directory mounted? if self.type == 'mount' # main folder unless File.exists?(self.path) and File.directory?(self.path) FileUtils.mkdir_p(self.path, :mode => self.mode) end # tree if self.config['tree'] and self.config['tree'].any? self.config['tree'].each do |subfolder| absolut_folder = "#{ self.path }/#{ subfolder }" unless File.exists?(absolut_folder) and File.directory?(absolut_folder) FileUtils.mkdir_p(absolut_folder, :mode => self.mode) end self.tree["#{ self.name }_#{ subfolder.gsub(/\//,'_') }"] = absolut_folder end end end |