Class: Vipergen::FileManager
- Inherits:
-
Object
- Object
- Vipergen::FileManager
- Defined in:
- lib/vipergen/filemanager.rb
Overview
File manager class
Class Method Summary collapse
-
.copy(from, to) ⇒ Object
Copy a system item to another place.
-
.destination_viper_path(path, name) ⇒ Object
Returns the destination viper path.
-
.files_in_path(path) ⇒ Object
Returns an array with files in a given path.
-
.is_language_valid(language) ⇒ Object
Returns if the language is valid by the VIPER generator.
-
.is_template_valid(template) ⇒ Object
Returns if the template is valid by the VIPER generator.
-
.move(from, to) ⇒ Object
Move a system item to another place.
-
.path_from(template, language) ⇒ Object
Return the path if valid template and language.
Class Method Details
.copy(from, to) ⇒ Object
Copy a system item to another place
36 37 38 39 40 41 |
# File 'lib/vipergen/filemanager.rb', line 36 def self.copy(from, to) = File.(to) = File.(from) FileUtils.mkdir_p () FileUtils.copy_entry(, ) end |
.destination_viper_path(path, name) ⇒ Object
Returns the destination viper path
30 31 32 33 |
# File 'lib/vipergen/filemanager.rb', line 30 def self.destination_viper_path(path, name) = File.(path) return File.join(,name) end |
.files_in_path(path) ⇒ Object
Returns an array with files in a given path
24 25 26 |
# File 'lib/vipergen/filemanager.rb', line 24 def self.files_in_path(path) return Dir[File.join("#{path}","/**/*")].select {|f| File.file?(f)} end |
.is_language_valid(language) ⇒ Object
Returns if the language is valid by the VIPER generator
11 12 13 |
# File 'lib/vipergen/filemanager.rb', line 11 def self.is_language_valid(language) return (Vipergen::Generator::LANGUAGES).include? language end |
.is_template_valid(template) ⇒ Object
Returns if the template is valid by the VIPER generator
6 7 8 |
# File 'lib/vipergen/filemanager.rb', line 6 def self.is_template_valid(template) return Vipergen::TemplateManager.templates.include? template end |
.move(from, to) ⇒ Object
Move a system item to another place
44 45 46 47 48 |
# File 'lib/vipergen/filemanager.rb', line 44 def self.move(from, to) = File.(to) = File.(from) FileUtils.move(, ) end |
.path_from(template, language) ⇒ Object
Return the path if valid template and language
17 18 19 20 |
# File 'lib/vipergen/filemanager.rb', line 17 def self.path_from(template, language) return nil if !is_language_valid(language) || !is_template_valid(template) return File.join(Vipergen::TemplateManager.templates_dir, template, language) end |