Class: Ruby::Nginx::System::SafeFile
- Inherits:
-
Object
- Object
- Ruby::Nginx::System::SafeFile
- Defined in:
- lib/ruby/nginx/system/safe_file.rb
Class Method Summary collapse
- .exist?(file_path) ⇒ Boolean
- .mkdir(dir_path) ⇒ Object
- .read(file_path) ⇒ Object
- .rm(file_path) ⇒ Object
- .touch(file_path) ⇒ Object
- .write(file_path, content) ⇒ Object
Class Method Details
.exist?(file_path) ⇒ Boolean
18 19 20 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 18 def exist?(file_path) File.exist?(File.(file_path)) end |
.mkdir(dir_path) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 10 def mkdir(dir_path) safe_path = File.(dir_path) FileUtils.mkdir_p(safe_path) safe_path end |
.read(file_path) ⇒ Object
31 32 33 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 31 def read(file_path) File.read(File.(file_path)) end |
.rm(file_path) ⇒ Object
43 44 45 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 43 def rm(file_path) FileUtils.rm_f(File.(file_path)) end |
.touch(file_path) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 22 def touch(file_path) safe_path = File.(file_path) FileUtils.mkdir_p(File.dirname(safe_path)) FileUtils.touch(safe_path) safe_path end |
.write(file_path, content) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ruby/nginx/system/safe_file.rb', line 35 def write(file_path, content) safe_path = touch(file_path) File.write(safe_path, content) safe_path end |