class GemMirror::MirrorDirectory

The MirrorDirectory is used for dealing with files and directories that are mirrored from an external source.

@!attribute [r] path

@return [String]

Attributes

path[R]

Public Class Methods

new(path) click to toggle source

@param [String] path

   # File lib/gem_mirror/mirror_directory.rb
17 def initialize(path)
18   @path = path
19 end

Public Instance Methods

add_directory(name) click to toggle source

Creates a new directory with the given name.

@param [String] name @return [GemMirror::MirrorDirectory]

   # File lib/gem_mirror/mirror_directory.rb
27 def add_directory(name)
28   full_path = File.join(path, name)
29 
30   Dir.mkdir(full_path) unless File.directory?(full_path)
31 
32   self.class.new(full_path)
33 end
add_file(name, content) click to toggle source

Creates a new file with the given name and content.

@param [String] name @param [String] content @return [Gem::MirrorFile]

   # File lib/gem_mirror/mirror_directory.rb
42 def add_file(name, content)
43   full_path = File.join(path, name)
44   file      = MirrorFile.new(full_path)
45 
46   file.write(content)
47 
48   file
49 end
file_exists?(name) click to toggle source

Checks if a given file exists in the current directory.

@param [String] name @return [TrueClass|FalseClass]

   # File lib/gem_mirror/mirror_directory.rb
57 def file_exists?(name)
58   File.file?(File.join(path, name))
59 end