Sha256: e105d706a3468e9e7bb55be891e012e208fc6a679ea6fa7e6d2ff9b0ee90ad17
Contents?: true
Size: 1.21 KB
Versions: 7
Compression:
Stored size: 1.21 KB
Contents
module Gemirro ## # The MirrorDirectory is used for dealing with files and directories that are # mirrored from an external source. # # @!attribute [r] path # @return [String] # class MirrorDirectory attr_reader :path ## # @param [String] path # def initialize(path) @path = path end ## # Creates directory or directories with the given path. # # @param [String] dir_path # @return [Gemirro::MirrorDirectory] # def add_directory(dir_path) full_path = File.join(@path, dir_path) FileUtils.mkdir_p(full_path) unless File.directory?(full_path) self.class.new(full_path) end ## # Creates a new file with the given name and content. # # @param [String] name # @param [String] content # @return [Gem::MirrorFile] # def add_file(name, content) full_path = File.join(@path, name) file = MirrorFile.new(full_path) file.write(content) file end ## # Checks if a given file exists in the current directory. # # @param [String] name # @return [TrueClass|FalseClass] # def file_exists?(name) File.file?(File.join(@path, name)) end end end
Version data entries
7 entries across 7 versions & 1 rubygems