Class: SSC::DirectoryManager::ApplianceDirectory
- Inherits:
-
Object
- Object
- SSC::DirectoryManager::ApplianceDirectory
- Defined in:
- lib/directory_manager.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(name = '', options = {}) ⇒ ApplianceDirectory
constructor
A new instance of ApplianceDirectory.
- #valid? ⇒ Boolean
Constructor Details
#initialize(name = '', options = {}) ⇒ ApplianceDirectory
Returns a new instance of ApplianceDirectory.
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/directory_manager.rb', line 118 def initialize(name= '', = {}) @name= name @path= File.join(Dir.pwd, name) @files = if Dir.exist?(@path) {:package => PackageFile.new(@path), :repository => RepositoryFile.new(@path), :file_list => FileListFile.new(@path)} else {} end @options= end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
116 117 118 |
# File 'lib/directory_manager.rb', line 116 def files @files end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
115 116 117 |
# File 'lib/directory_manager.rb', line 115 def path @path end |
Class Method Details
.show_file(relative_path) ⇒ Object
148 149 150 151 |
# File 'lib/directory_manager.rb', line 148 def show_file(relative_path) path= File.join(@path, relative_path) File.read(path) end |
Instance Method Details
#create ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/directory_manager.rb', line 131 def create FileUtils.mkdir_p(@name) FileUtils.mkdir_p(File.join(@name, 'files')) @files[:repository] = FileUtils.touch(File.join(@name, 'repositories'))[0] @files[:package] = FileUtils.touch(File.join(@name, 'software'))[0] @files[:file_list] = FileUtils.touch(File.join(@name, 'files/.file_list'))[0] File.open(File.join(@name, '.sscrc'), 'w') do |file| file.write(@options.stringify_keys.to_yaml) end File.join(Dir.pwd, @name) end |
#valid? ⇒ Boolean
143 144 145 |
# File 'lib/directory_manager.rb', line 143 def valid? Dir.exists?(@path) && File.exists?(File.join(@path, '.sscrc')) end |