Class: FileWrapper
Instance Method Summary collapse
- #basename(path, extension = nil) ⇒ Object
- #compare(from, to) ⇒ Object
- #cp(source, destination, options = {}) ⇒ Object
- #directory?(path) ⇒ Boolean
- #directory_listing(glob) ⇒ Object
- #dirname(path) ⇒ Object
- #exist?(filepath) ⇒ Boolean
- #get_expanded_path(path) ⇒ Object
- #instantiate_file_list(files = []) ⇒ Object
- #mkdir(folder) ⇒ Object
- #open(filepath, flags) ⇒ Object
- #read(filepath) ⇒ Object
- #readlines(filepath) ⇒ Object
- #rm_f(filepath, options = {}) ⇒ Object
- #rm_r(filepath, options = {}) ⇒ Object
- #touch(filepath, options = {}) ⇒ Object
- #write(filepath, contents, flags = 'w') ⇒ Object
Instance Method Details
#basename(path, extension = nil) ⇒ Object
13 14 15 16 |
# File 'lib/ceedling/file_wrapper.rb', line 13 def basename(path, extension=nil) return File.basename(path, extension) if extension return File.basename(path) end |
#compare(from, to) ⇒ Object
47 48 49 |
# File 'lib/ceedling/file_wrapper.rb', line 47 def compare(from, to) return FileUtils.compare_file(from, to) end |
#cp(source, destination, options = {}) ⇒ Object
43 44 45 |
# File 'lib/ceedling/file_wrapper.rb', line 43 def cp(source, destination, ={}) FileUtils.cp(source, destination, **) end |
#directory?(path) ⇒ Boolean
23 24 25 |
# File 'lib/ceedling/file_wrapper.rb', line 23 def directory?(path) return File.directory?(path) end |
#directory_listing(glob) ⇒ Object
31 32 33 |
# File 'lib/ceedling/file_wrapper.rb', line 31 def directory_listing(glob) return Dir.glob(glob, File::FNM_PATHNAME) end |
#dirname(path) ⇒ Object
27 28 29 |
# File 'lib/ceedling/file_wrapper.rb', line 27 def dirname(path) return File.dirname(path) end |
#exist?(filepath) ⇒ Boolean
18 19 20 21 |
# File 'lib/ceedling/file_wrapper.rb', line 18 def exist?(filepath) return true if (filepath == NULL_FILE_PATH) return File.exist?(filepath) end |
#get_expanded_path(path) ⇒ Object
9 10 11 |
# File 'lib/ceedling/file_wrapper.rb', line 9 def (path) return File.(path) end |
#instantiate_file_list(files = []) ⇒ Object
75 76 77 |
# File 'lib/ceedling/file_wrapper.rb', line 75 def instantiate_file_list(files=[]) return FileList.new(files) end |
#mkdir(folder) ⇒ Object
79 80 81 |
# File 'lib/ceedling/file_wrapper.rb', line 79 def mkdir(folder) return FileUtils.mkdir_p(folder) end |
#open(filepath, flags) ⇒ Object
51 52 53 54 55 |
# File 'lib/ceedling/file_wrapper.rb', line 51 def open(filepath, flags) File.open(filepath, flags) do |file| yield(file) end end |
#read(filepath) ⇒ Object
57 58 59 |
# File 'lib/ceedling/file_wrapper.rb', line 57 def read(filepath) return File.read(filepath) end |
#readlines(filepath) ⇒ Object
71 72 73 |
# File 'lib/ceedling/file_wrapper.rb', line 71 def readlines(filepath) return File.readlines(filepath) end |
#rm_f(filepath, options = {}) ⇒ Object
35 36 37 |
# File 'lib/ceedling/file_wrapper.rb', line 35 def rm_f(filepath, ={}) FileUtils.rm_f(filepath, **) end |
#rm_r(filepath, options = {}) ⇒ Object
39 40 41 |
# File 'lib/ceedling/file_wrapper.rb', line 39 def rm_r(filepath, ={}) FileUtils.rm_r(filepath, **={}) end |
#touch(filepath, options = {}) ⇒ Object
61 62 63 |
# File 'lib/ceedling/file_wrapper.rb', line 61 def touch(filepath, ={}) FileUtils.touch(filepath, **) end |
#write(filepath, contents, flags = 'w') ⇒ Object
65 66 67 68 69 |
# File 'lib/ceedling/file_wrapper.rb', line 65 def write(filepath, contents, flags='w') File.open(filepath, flags) do |file| file.write(contents) end end |