class SSC::DirectoryManager::ApplianceDirectory

Attributes

files[R]
path[R]

Public Class Methods

new(name= '', options = {}) click to toggle source
# File lib/directory_manager.rb, line 118
def initialize(name= '', options = {})
  @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= options
end
show_file(relative_path) click to toggle source
# File lib/directory_manager.rb, line 148
def show_file(relative_path)
  path= File.join(@path, relative_path)
  File.read(path)
end

Public Instance Methods

create() click to toggle source
# 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?() click to toggle source
# File lib/directory_manager.rb, line 143
def valid?
  Dir.exists?(@path) && File.exists?(File.join(@path, '.sscrc'))
end