Class: MVCgen::FileManager
- Inherits:
-
Object
- Object
- MVCgen::FileManager
- Defined in:
- lib/mvcgen/filemanager.rb
Overview
File manager class
Class Method Summary collapse
-
.copy(from, to) ⇒ Object
Copy a system item to another place.
-
.destination_mvc_path(path, name) ⇒ Object
Returns the destination mvc 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 MVC generator.
-
.is_template_valid(template) ⇒ Object
Returns if the template is valid by the MVC 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
38 39 40 41 42 43 |
# File 'lib/mvcgen/filemanager.rb', line 38 def self.copy(from, to) = File.(to) = File.(from) FileUtils.mkdir_p () FileUtils.copy_entry(, , remove_destination = true) end |
.destination_mvc_path(path, name) ⇒ Object
Returns the destination mvc path
32 33 34 35 |
# File 'lib/mvcgen/filemanager.rb', line 32 def self.destination_mvc_path(path, name) = File.(path) return File.join(,name) end |
.files_in_path(path) ⇒ Object
Returns an array with files in a given path
26 27 28 |
# File 'lib/mvcgen/filemanager.rb', line 26 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 MVC generator
13 14 15 |
# File 'lib/mvcgen/filemanager.rb', line 13 def self.is_language_valid(language) return (MVCgen::Generator::LANGUAGES).include? language end |
.is_template_valid(template) ⇒ Object
Returns if the template is valid by the MVC generator
8 9 10 |
# File 'lib/mvcgen/filemanager.rb', line 8 def self.is_template_valid(template) return MVCgen::TemplateManager.templates.include? template end |
.move(from, to) ⇒ Object
Move a system item to another place
46 47 48 49 50 |
# File 'lib/mvcgen/filemanager.rb', line 46 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
19 20 21 22 |
# File 'lib/mvcgen/filemanager.rb', line 19 def self.path_from(template, language) return nil if !is_language_valid(language) || !is_template_valid(template) return File.join(MVCgen::TemplateManager.templates_dir, template, language) end |