Class: CapicuaGen::Gaspar::CSProyectFeature

Inherits:
TemplateFeature
  • Object
show all
Includes:
CapicuaGen, CapicuaGen::Gaspar
Defined in:
lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb

Overview

Caracteristica generadora para proyectos Windows de CS.

Instance Method Summary collapse

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 = {}) ⇒ CSProyectFeature

Inicializa la caracteristica



41
42
43
44
# File 'lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb', line 41

def initialize(values= {})
  super(values)

end

Instance Method Details

#configure_attributesObject

Configura los atributos personalizados de la caracteristica (antes de establecer el generador)



53
54
55
# File 'lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb', line 53

def configure_attributes()
  self.generation_attributes[:out_dir]= "#{self.generation_attributes[:out_dir]}/#{self.generation_attributes[:namespace]}" unless self.generation_attributes.has_in_self?(:out)
end

#get_proyect_filesObject

Obtiene los archivos que se incluiran en este proyeto



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
# File 'lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb', line 58

def get_proyect_files()
  resultado= ''

  template_target= get_template_target_by_name('proyect')

  directory_base= File.dirname(File.join(self.generation_attributes[:out_dir], template_target.out_file))

  # Recorro todas las caracteristicas
  generator.features().each do |f|
    #Obtengo todos los archivos asociados
    f.get_relative_out_files(:directory_base => directory_base, :types => :proyect_file).each do |unix_path|

      p        = unix_path.gsub /\//, '\\'
      extension= File.extname(p).downcase
      file_type= :proyect_file
      Dir.chdir directory_base do
        file_type= get_type(p)
      end


      case extension
        when '.cs'

          case file_type
            when :proyect_file
              if p=~ /(?:.+\\)?(.+)\.Designer.cs/i
                resultado << "      <Compile Include= \"#{p}\" >" << $/
                resultado << "        <DependentUpon>#{$1}.cs</DependentUpon>" << $/
                resultado << "      </Compile>" << $/
              elsif p=~ /(?:.+\\)?(.+)\.svc\.cs/i
                resultado << "      <Compile Include= \"#{p}\" >" << $/
                resultado << "        <DependentUpon>#{$1}.svc</DependentUpon>" << $/
                resultado << "      </Compile>" << $/
              else
                resultado << "      <Compile Include= \"#{p}\" />" << $/
              end
            when :form_proyect_file
              resultado << "      <Compile Include= \"#{p}\" >" << $/
              resultado << "        <SubType>Form</SubType>" << $/
              resultado << "      </Compile>" << $/
          end

        when '.resx'
          if p=~ /(?:.+\\)?(.+)\.resx/i
            resultado << "      <EmbeddedResource Include= \"#{p}\" >" << $/
            resultado << "        <DependentUpon>#{$1}.cs</DependentUpon>" << $/
            resultado << "      </EmbeddedResource>" << $/
          end
        when '.config', '.svc'
          resultado << "      <Content Include= \"#{p}\" />" << $/
        else
          resultado << "      <Compile Include= \"#{p}\" />" << $/
      end
    end
  end

  return resultado
end

#get_type(file) ⇒ Object

Devuelve el tipo de archivo de un elemento.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb', line 118

def get_type(file)

  return :proyect_file unless file=~/.cs$/

  # Compruebo si es un archivo de Windows
  designed= file.sub(/\.cs$/, ".designer.cs")

  return :proyect_file if file==designed
  return :proyect_file if not File.exist?(designed)

  text= File.open(designed).read

  if text=~/:\s*(Form|System.Windows.Form)/
    return :form_proyect_file
  else
    return :proyect_file
  end

end

#reset_attributesObject

Resetea los atributos personalizados de la caracteristica (antes de establecer el generador)



47
48
49
50
# File 'lib/CapicuaGenGaspar/Proyect/CSProyect/Source/cs_proyect_feature.rb', line 47

def reset_attributes
  self.generation_attributes[:out_dir]  = nil
  self.generation_attributes[:namespace]= nil
end