class Vipergen::FileManager
File manager class
Public Class Methods
copy(from, to)
click to toggle source
Copy a system item to another place
# File lib/vipergen/filemanager.rb, line 36 def self.copy(from, to) to_expand_path = File.expand_path(to) from_expand_path = File.expand_path(from) FileUtils.mkdir_p (to_expand_path) FileUtils.copy_entry(from_expand_path, to_expand_path) end
destination_viper_path(path, name)
click to toggle source
Returns the destination viper path @return Destination root path
# File lib/vipergen/filemanager.rb, line 30 def self.destination_viper_path(path, name) expand_path = File.expand_path(path) return File.join(expand_path,name) end
files_in_path(path)
click to toggle source
Returns an array with files in a given path @return Array with the files in a given path
# 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)
click to toggle source
Returns if the language is valid by the VIPER generator
# File lib/vipergen/filemanager.rb, line 11 def self.is_language_valid(language) return (Vipergen::Generator::LANGUAGES).include? language end
is_template_valid(template)
click to toggle source
Returns if the template is valid by the VIPER generator
# File lib/vipergen/filemanager.rb, line 6 def self.is_template_valid(template) return Vipergen::TemplateManager.templates.include? template end
move(from, to)
click to toggle source
Move a system item to another place
# File lib/vipergen/filemanager.rb, line 44 def self.move(from, to) to_expand_path = File.expand_path(to) from_expand_path = File.expand_path(from) FileUtils.move(from_expand_path, to_expand_path) end
path_from(template, language)
click to toggle source
Return the path if valid template and language @return String with valid path
# 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