class CapicuaGen::Gaspar::CodeMaidCleanerFeature
Característica generadora para limpiar y formatear el código generado a traves de la herramienta CodeMaid (Extesion de Visual Studio)
Constants
- BINARY
Attributes
bin_directories[RW]
target_feature_types[RW]
Public Class Methods
new(values= {})
click to toggle source
Inicializa la característica
Calls superclass method
# File lib/CapicuaGenGaspar/CodeTransformer/CodeMaidCleaner/Source/code_maid_cleaner_feature.rb, line 54 def initialize(values= {}) super(values) # Configuro los tipos si estos no han sido configurados previamente self.types = [:transformer] if self.types.blank? @target_feature_types= [:soluction] if @target_feature_types.blank? @bin_directories = [] if self.bin_directories.blank? @bin_directories << File.join(File.dirname(__FILE__), '../bin') end
Public Instance Methods
find_binary()
click to toggle source
# File lib/CapicuaGenGaspar/CodeTransformer/CodeMaidCleaner/Source/code_maid_cleaner_feature.rb, line 151 def find_binary bin_directories.each do |bin| current_path= File.join(bin, BINARY) return current_path if File.exist?(current_path) end end
generate()
click to toggle source
Genera las cabeceras y pie de páginas
Calls superclass method
# File lib/CapicuaGenGaspar/CodeTransformer/CodeMaidCleaner/Source/code_maid_cleaner_feature.rb, line 72 def generate super() message_helper.add_indent begin directory_base= self.generation_attributes[:out_dir] binary_file = find_binary parameters = ' /mo' files = [] # Recorro todas las características generator.features.each do |feature| return unless feature.respond_to?('get_relative_out_files') #Obtengo todos los archivos asociados feature.get_relative_out_files(:directory_base => directory_base).each do |unix_path| file= unix_path.gsub(/\//, '\\') Dir.chdir directory_base do file= File.absolute_path(file) end extension= File.extname(file).downcase case extension when '.sln' parameters<<" /s \"#{file}\"" when '.csproj' parameters<<" /p \"#{file}\"" if @target_feature_types.include?(:proyect) else Dir.chdir directory_base do #Compruebo si debe ser includo stat=File::Stat.new(unix_path) if (stat.mtime > self.generator.start_time) file= File.basename(unix_path) files<<file end end end end end Dir.chdir directory_base do #Guardo el archivo de directorio file= Tempfile.new('files') begin file.write(files.join($/)) file.close file_path= file.path.gsub /\//, '\\' parameters<<" /f #{file_path}" #Ejecuto el programa IO.popen("\"#{binary_file}\" #{parameters}").each do |line| message_helper.puts_code_clean(line.chomp) end ensure file.close file.unlink # deletes the temp file end end ensure message_helper.remove_indent puts end end