Class: CapicuaGen::Gaspar::CSHeaderFooterFeature
- Inherits:
-
TemplateFeature
- Object
- TemplateFeature
- CapicuaGen::Gaspar::CSHeaderFooterFeature
- Includes:
- CapicuaGen, CapicuaGen::Gaspar
- Defined in:
- lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb
Overview
Caracteristica generadora de caceberas y pies de pagina en el codigo fuente generado por otras caracteristicas
Instance Attribute Summary collapse
-
#exclude_regex ⇒ Object
Returns the value of attribute exclude_regex.
-
#include_regex ⇒ Object
Returns the value of attribute include_regex.
Instance Method Summary collapse
-
#check_include(file) ⇒ Object
Revisa si un archivo debe ser incluido.
-
#configure_template_targets ⇒ Object
Configura los objetivos de las platillas (despues de establecer el generador).
-
#generate ⇒ Object
Recorre las plantilla y genera las cabeceras.
-
#initialize(values = {}) ⇒ CSHeaderFooterFeature
constructor
Inicializa la caracteristica.
Methods included from CapicuaGen::Gaspar
#get_about_class_full_name, #get_about_class_name, #get_app_config_file, #get_db_connection_name_method, #get_db_connection_provider_method, #get_db_connection_string_method, #get_entity_by_catalog_name, #get_entity_catalogs_full_name, #get_entity_catalogs_name, #get_entity_data_access_full_name, #get_entity_data_access_name, #get_entity_full_name, #get_entity_interface_full_name, #get_entity_interface_name, #get_entity_name, #get_main_form_class_full_name, #get_main_form_class_name, #get_namespaces, #get_namespaces_text, #get_splash_class_full_name, #get_splash_class_name
Constructor Details
#initialize(values = {}) ⇒ CSHeaderFooterFeature
Inicializa la caracteristica
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 46 def initialize(values= {}) super(values) # Configuro los tipos si estos no han sido configurados previamente self.types= [:code_transformer] if self.types.blank? # Configuro los templates set_template("header", Template.new(:file => 'header.erb')) set_template("footer", Template.new(:file => 'footer.erb')) #Configuro los include y exclude @include_regex= [/\.cs$/i] unless @include_regex @exclude_regex= [/\.Designer\.cs$/i] unless @exclude_regex end |
Instance Attribute Details
#exclude_regex ⇒ Object
Returns the value of attribute exclude_regex.
41 42 43 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 41 def exclude_regex @exclude_regex end |
#include_regex ⇒ Object
Returns the value of attribute include_regex.
41 42 43 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 41 def include_regex @include_regex end |
Instance Method Details
#check_include(file) ⇒ Object
Revisa si un archivo debe ser incluido
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 166 def check_include(file) return false if @include_regex.blank? @include_regex.each do |include| return false unless include.match(file) end return true if @exclude_regex.blank? @exclude_regex.each do |exclude| return false if exclude.match(file) end return true end |
#configure_template_targets ⇒ Object
Configura los objetivos de las platillas (despues de establecer el generador)
64 65 66 67 68 69 70 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 64 def configure_template_targets # Configuro los templates @header_template_target= set_template_target('header', TemplateTarget.new()) = set_template_target('footer', TemplateTarget.new()) end |
#generate ⇒ Object
Recorre las plantilla y genera las cabeceras
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/CapicuaGenGaspar/CodeTransformer/CSHeaderFooter/Source/cs_header_footer_feature.rb', line 73 def generate .(self) .add_indent begin resultado= '' template_target= get_template_target_by_name('proyect') directory_base= self.generation_attributes[:out_dir] # Recorro todas las caracteristicas generator.features().each do |feature| #Obtengo todos los archivos asociados feature.get_relative_out_files(:directory_base => directory_base, :types => :proyect_file).each do |unix_path| # Nombre del archivo file = unix_path.gsub(/\//, '\\') file_name= File.basename file next unless check_include(file) file_content= '' Dir.chdir directory_base do # Cargo el acrhivo file_content= File.read(file) file_content.force_encoding(CharDet.detect(file_content)['encoding']) end # Genero los las licencias modified=false # Limpio file_content para comparciones # Genero cabecera header =generate_template_target(@header_template_target, binding) begin header_check=header.clone header_check.force_encoding(CharDet.detect(file_content)['encoding']) unless header.blank? header_check.blank? header=header_check rescue end if header.blank? or file_content.gsub(/\s*/, '').include?(header.gsub(/\s*/, '')) header ='' else modified=true end # Genero pie = generate_template_target(, binding) begin =.clone .force_encoding(CharDet.detect(file_content)['encoding']) unless .blank? .blank? = rescue end if .blank? or file_content.gsub(/\s*/, '').include?(.gsub(/\s*/, '')) ='' else modified=true end if modified file_out= "#{header}#{file_content}#{footer}" Dir.chdir directory_base do # Guardo el archivo File.write(file, file_out) .puts_created_template("header.erb, footer.erb", file, :override) end else .puts_created_template("header.erb, footer.erb", file, :ignore) end end end ensure .remove_indent puts end end |