CapicuaGen 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +23 -19
- data/.rspec +2 -2
- data/.travis.yml +4 -4
- data/CODE_OF_CONDUCT.md +48 -48
- data/CapicuaGen.gemspec +60 -57
- data/Gemfile +4 -4
- data/README.md +57 -36
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/exe/{capicuagen.rb → capicuagen} +2 -0
- data/lib/CapicuaGen/Examples/Example/Source/example_feature.rb +2 -2
- data/lib/CapicuaGen/Examples/Example/Template/Gemfile.erb +8 -0
- data/lib/CapicuaGen/Examples/Example/Template/generator.erb +240 -0
- data/lib/CapicuaGen/Examples/Example/Template/instnwnd.erb +9336 -0
- data/lib/CapicuaGen/Tools/message_helper.rb +45 -6
- data/lib/CapicuaGen/Tools/template_helper.rb +86 -86
- data/lib/CapicuaGen/Tools/xml_helper.rb +100 -100
- data/lib/CapicuaGen/generator.rb +157 -32
- data/lib/CapicuaGen/generator_command_line.rb +55 -3
- data/lib/CapicuaGen/template_feature.rb +26 -10
- data/lib/CapicuaGen/version.rb +3 -3
- metadata +22 -8
- data/lib/CapicuaGen/Examples/Example/Template/SplashForm.designer.erb +0 -141
- data/lib/CapicuaGen/Examples/Example/Template/SplashForm.erb +0 -160
- data/lib/CapicuaGen/Examples/Example/Template/SplashForm.resx.erb +0 -535
data/lib/CapicuaGen/generator.rb
CHANGED
@@ -22,6 +22,7 @@ Para más información consultar http://www.gnu.org/licenses/lgpl.html
|
|
22
22
|
require 'active_support/core_ext/object/blank'
|
23
23
|
require_relative 'Mixins/reflection_mixin'
|
24
24
|
require_relative 'generator_command_line'
|
25
|
+
require_relative '../CapicuaGen/Examples/Example/Source/example_feature'
|
25
26
|
|
26
27
|
module CapicuaGen
|
27
28
|
|
@@ -34,7 +35,7 @@ module CapicuaGen
|
|
34
35
|
|
35
36
|
public
|
36
37
|
|
37
|
-
attr_accessor :generation_attributes, :retry_failed, :continue_on_failed, :retries, :
|
38
|
+
attr_accessor :generation_attributes, :retry_failed, :continue_on_failed, :retries, :local_templates
|
38
39
|
attr_accessor :message_helper, :start_time, :end_time, :argv_options
|
39
40
|
|
40
41
|
# Inicializo el objeto
|
@@ -43,29 +44,29 @@ module CapicuaGen
|
|
43
44
|
|
44
45
|
|
45
46
|
# Valores determinados
|
46
|
-
@retry_failed
|
47
|
-
@retries
|
48
|
-
@continue_on_failed
|
49
|
-
@
|
47
|
+
@retry_failed = true unless @retry_failed
|
48
|
+
@retries = 1 unless @retries
|
49
|
+
@continue_on_failed = true unless @continue_on_failed
|
50
|
+
@local_templates = 'Capicua' unless @local_templates
|
50
51
|
|
51
52
|
# Colecciones de caracteristicas que posee el generador
|
52
|
-
@features
|
53
|
+
@features = []
|
53
54
|
|
54
55
|
# Caraceristicas a ejecutar
|
55
|
-
@targets
|
56
|
+
@targets = []
|
56
57
|
|
57
58
|
# Atributos generales de generacion
|
58
|
-
@generation_attributes
|
59
|
+
@generation_attributes = AttributeMixer.new
|
59
60
|
|
60
61
|
# Configuro el gestor de mensajes
|
61
|
-
@message_helper
|
62
|
+
@message_helper = MessageHelper.new
|
62
63
|
|
63
64
|
# Hora de comienzo y final
|
64
|
-
@start_time
|
65
|
-
@end_time
|
65
|
+
@start_time = Time.now
|
66
|
+
@end_time = Time.now
|
66
67
|
|
67
68
|
# Opciones
|
68
|
-
@argv_options
|
69
|
+
@argv_options =OpenStruct.new
|
69
70
|
|
70
71
|
# Aranco configuracion si es necesario
|
71
72
|
yield self if block_given?
|
@@ -167,21 +168,40 @@ module CapicuaGen
|
|
167
168
|
end
|
168
169
|
|
169
170
|
# Genera todos las caracteristicas
|
170
|
-
def generate
|
171
|
+
def generate(values={})
|
171
172
|
|
172
|
-
|
173
|
+
no_arguments=values[:no_arguments]
|
174
|
+
if values[:arguments]
|
175
|
+
arguments=Array(values[:arguments])
|
176
|
+
else
|
177
|
+
arguments=ARGV.clone
|
178
|
+
end
|
179
|
+
|
180
|
+
start_time = Time.now
|
173
181
|
|
174
182
|
# Reviso argumentos
|
175
|
-
argv =ARGV.clone
|
176
|
-
@argv_options =parse_command_line(argv)
|
177
183
|
|
178
|
-
|
184
|
+
unless no_arguments
|
185
|
+
argv =arguments.clone
|
186
|
+
@argv_options =parse_command_line(argv)
|
179
187
|
|
180
|
-
|
181
|
-
|
182
|
-
|
188
|
+
return if @argv_options.exit
|
189
|
+
|
190
|
+
if @argv_options.clean
|
191
|
+
clean
|
192
|
+
end
|
193
|
+
|
194
|
+
if @argv_options.example
|
195
|
+
generate_example
|
196
|
+
return
|
197
|
+
end
|
183
198
|
|
184
|
-
|
199
|
+
generate_list if @argv_options.template_list
|
200
|
+
|
201
|
+
generate_export_template @argv_options if @argv_options.template and not @argv_options.template_list
|
202
|
+
|
203
|
+
return unless @argv_options.generate
|
204
|
+
end
|
185
205
|
|
186
206
|
@targets.each do |t|
|
187
207
|
|
@@ -196,6 +216,13 @@ module CapicuaGen
|
|
196
216
|
targets= [] + @targets
|
197
217
|
retries= @retries + 1
|
198
218
|
|
219
|
+
# Veo si debo hacer algo, si no muestro la ayuda
|
220
|
+
if targets.blank?
|
221
|
+
parse_command_line(["-h"])
|
222
|
+
return
|
223
|
+
end
|
224
|
+
|
225
|
+
|
199
226
|
# Posibles reintentos
|
200
227
|
retries.times do
|
201
228
|
|
@@ -208,34 +235,37 @@ module CapicuaGen
|
|
208
235
|
|
209
236
|
feature= get_feature_by_name(t.feature_name)
|
210
237
|
|
211
|
-
next if @argv_options.ignore_features.include? feature.name
|
238
|
+
next if @argv_options and @argv_options.ignore_features and @argv_options.ignore_features.include? feature.name
|
212
239
|
|
213
240
|
begin
|
214
241
|
feature.generate
|
215
242
|
targets.delete(t)
|
216
243
|
rescue => e
|
217
|
-
|
218
|
-
$stderr.puts e.backtrace
|
244
|
+
message_helper.puts_catched_error e
|
219
245
|
end
|
220
246
|
end
|
221
247
|
|
222
248
|
end
|
223
249
|
|
224
|
-
|
250
|
+
end_time=Time.now
|
225
251
|
|
226
252
|
puts
|
227
|
-
message_helper.puts_end_generate(
|
253
|
+
message_helper.puts_end_generate(start_time, end_time)
|
228
254
|
|
229
255
|
end
|
230
256
|
|
231
257
|
|
232
258
|
# Genera todos las caracteristicas
|
233
|
-
def clean
|
234
|
-
|
235
|
-
@start_time = Time.now
|
259
|
+
def clean(values ={})
|
260
|
+
@start_time = Time.now
|
236
261
|
|
237
262
|
# Reviso argumentos
|
238
|
-
|
263
|
+
if values[:arguments]
|
264
|
+
arguments=Array(values[:arguments])
|
265
|
+
else
|
266
|
+
arguments=ARGV.clone
|
267
|
+
end
|
268
|
+
argv =arguments
|
239
269
|
@argv_options =parse_command_line(argv)
|
240
270
|
|
241
271
|
return if @argv_options.exit
|
@@ -271,8 +301,7 @@ module CapicuaGen
|
|
271
301
|
feature.clean
|
272
302
|
targets.delete(t)
|
273
303
|
rescue => e
|
274
|
-
|
275
|
-
$stderr.puts e.backtrace
|
304
|
+
message_helper.puts_catched_error e
|
276
305
|
end
|
277
306
|
end
|
278
307
|
|
@@ -285,5 +314,101 @@ module CapicuaGen
|
|
285
314
|
|
286
315
|
end
|
287
316
|
|
317
|
+
|
318
|
+
def generate_example()
|
319
|
+
|
320
|
+
arguments= ['generate']
|
321
|
+
|
322
|
+
argv_options =parse_command_line(ARGV)
|
323
|
+
|
324
|
+
|
325
|
+
generator_example = CapicuaGen::Generator.new do |g|
|
326
|
+
|
327
|
+
# Creo las caracteristicas necesarias
|
328
|
+
feature_example = CapicuaGen::ExampleFeature.new(:name => 'feature_example')
|
329
|
+
|
330
|
+
# Agrego las caracteristica en al generador
|
331
|
+
g.add_feature_and_target feature_example
|
332
|
+
|
333
|
+
# Configuro los atributos
|
334
|
+
g.generation_attributes.add :out_dir => argv_options.out
|
335
|
+
|
336
|
+
end
|
337
|
+
|
338
|
+
|
339
|
+
arguments << "--force" if argv_options.force
|
340
|
+
|
341
|
+
generator_example.generate :arguments => arguments
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
def generate_list
|
346
|
+
templates=[]
|
347
|
+
|
348
|
+
dir = File.join(File.dirname(__FILE__), '../../..')
|
349
|
+
|
350
|
+
Dir["#{dir}/**/*"].select { |e| File.file? e and e=~/Template/ }.each do |f|
|
351
|
+
|
352
|
+
feature_template=get_gem_type_feature(f)
|
353
|
+
templates<<feature_template if feature_template
|
354
|
+
|
355
|
+
end
|
356
|
+
|
357
|
+
templates.uniq.each do |feature_template|
|
358
|
+
message_helper.puts_list_template(feature_template[:gem], feature_template[:type], feature_template[:feature]) if feature_template
|
359
|
+
end
|
360
|
+
|
361
|
+
|
362
|
+
end
|
363
|
+
|
364
|
+
def generate_export_template(options)
|
365
|
+
templates=[]
|
366
|
+
|
367
|
+
dir = File.join(File.dirname(__FILE__), '../../..')
|
368
|
+
|
369
|
+
Dir["#{dir}/**/*"].select { |e| File.file? e and e=~/Template/ }.each do |template_file|
|
370
|
+
|
371
|
+
|
372
|
+
feature_template=get_gem_type_feature(template_file)
|
373
|
+
|
374
|
+
next unless feature_template
|
375
|
+
|
376
|
+
next unless feature_template[:gem]=~ /#{options.template_gem}/
|
377
|
+
next unless feature_template[:type]=~ /#{options.template_type}/
|
378
|
+
next unless feature_template[:feature]=~ /#{options.template_feature}/
|
379
|
+
|
380
|
+
|
381
|
+
out_file=File.join(options.template_out, feature_template[:gem], feature_template[:type], feature_template[:feature], File.basename(template_file))
|
382
|
+
|
383
|
+
exists= File.exist?(out_file)
|
384
|
+
|
385
|
+
if not exists or options.force
|
386
|
+
|
387
|
+
# Creo el directorio
|
388
|
+
FileUtils::mkdir_p File.dirname(out_file)
|
389
|
+
FileUtils.cp template_file, out_file
|
390
|
+
|
391
|
+
if exists
|
392
|
+
message_helper.puts_copy_template(feature_template[:gem], feature_template[:type], feature_template[:feature], out_file, :override)
|
393
|
+
else
|
394
|
+
message_helper.puts_copy_template(feature_template[:gem], feature_template[:type], feature_template[:feature], out_file, :new)
|
395
|
+
end
|
396
|
+
|
397
|
+
else
|
398
|
+
message_helper.puts_copy_template(feature_template[:gem], feature_template[:type], feature_template[:feature], out_file, :ignore)
|
399
|
+
end
|
400
|
+
|
401
|
+
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
def get_gem_type_feature(file)
|
406
|
+
if file=~/([^\/*]+)\/([^\/*?]+)\/([^\/*?]+)\/Template\//i
|
407
|
+
return { :gem => $1, :type => $2, :feature => $3 }
|
408
|
+
else
|
409
|
+
return nil
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
288
413
|
end
|
289
414
|
end
|
@@ -50,6 +50,7 @@ Comandos:
|
|
50
50
|
clean : Limpia los archivos generados.
|
51
51
|
cleanAndGenerate : Limpia los archivos generados y luego los vuelve a crear.
|
52
52
|
example : Genera un ejemplo
|
53
|
+
template : Lista o permite reemplazar plantillas por defecto.
|
53
54
|
|
54
55
|
|
55
56
|
Ejecute 'opt.rb COMMAND --help' para obtener mas
|
@@ -85,6 +86,7 @@ HELP
|
|
85
86
|
# List of arguments.
|
86
87
|
opts.on("--ignore featurename1, featurename2, featurename2", Array, "Lista de caracteristicas que sera omitidas") do |ignore_features|
|
87
88
|
options.ignore_features = ignore_features
|
89
|
+
options.ignore_features =[] unless options.ignore_features
|
88
90
|
end
|
89
91
|
|
90
92
|
opts.on("-f", "--force", "Fuerza que se sobreescriban las carateristicas generadas") do
|
@@ -143,14 +145,60 @@ HELP
|
|
143
145
|
|
144
146
|
|
145
147
|
'example' => OptionParser.new do |opts|
|
146
|
-
opts.banner = "Uso:
|
148
|
+
opts.banner = "Uso: example [options]"
|
147
149
|
opts.separator ""
|
148
150
|
opts.separator "Opciones:"
|
149
151
|
opts.separator ""
|
150
152
|
|
153
|
+
|
154
|
+
opts.on("-o", "--out directorio", "Directorio de salida") do |directorio|
|
155
|
+
options.out = directorio
|
156
|
+
end
|
157
|
+
|
158
|
+
opts.on("-f", "--force", "Se sobreescribe el ejemplo") do
|
159
|
+
options.force= true
|
160
|
+
end
|
161
|
+
|
162
|
+
opts.on_tail("-h", "--help", "Muestra este mensaje") do
|
163
|
+
puts opts
|
164
|
+
options.help=true
|
165
|
+
options.exit=true
|
166
|
+
end
|
167
|
+
|
168
|
+
opts.separator ""
|
169
|
+
end,
|
170
|
+
|
171
|
+
|
172
|
+
'template' => OptionParser.new do |opts|
|
173
|
+
opts.banner = "Uso: template [options]"
|
174
|
+
opts.separator ""
|
175
|
+
opts.separator "Opciones:"
|
176
|
+
opts.separator ""
|
177
|
+
|
178
|
+
|
179
|
+
# List of arguments.
|
180
|
+
opts.on("-l", "--list", "Lista los templates instalados") do
|
181
|
+
options.template_list = true
|
182
|
+
end
|
183
|
+
|
184
|
+
# Gema instalada
|
185
|
+
opts.on("-g", "--gem gema", "Gema (instalada) a obtener") do |template_gem|
|
186
|
+
options.template_gem = template_gem
|
187
|
+
end
|
188
|
+
|
189
|
+
# Tipo de caracteristica
|
190
|
+
opts.on("-t", "--type tipo", "Tipos de carecteristica") do |type|
|
191
|
+
options.template_type = type
|
192
|
+
end
|
193
|
+
|
194
|
+
# Tipo de caracteristica
|
195
|
+
opts.on("-f", "--feature caracteristica", "Carecteristica") do |feature|
|
196
|
+
options.template_feature = feature
|
197
|
+
end
|
198
|
+
|
151
199
|
# List of arguments.
|
152
200
|
opts.on("-o", "--out directorio", "") do |directorio|
|
153
|
-
options.
|
201
|
+
options.template_out = directorio
|
154
202
|
end
|
155
203
|
|
156
204
|
opts.on_tail("-h", "--help", "Muestra este mensaje") do
|
@@ -161,7 +209,6 @@ HELP
|
|
161
209
|
|
162
210
|
opts.separator ""
|
163
211
|
end
|
164
|
-
|
165
212
|
}
|
166
213
|
|
167
214
|
|
@@ -191,6 +238,11 @@ HELP
|
|
191
238
|
options.example =true
|
192
239
|
options.out ='.'
|
193
240
|
|
241
|
+
when 'template'
|
242
|
+
options.clean =false
|
243
|
+
options.generate =false
|
244
|
+
options.template =true
|
245
|
+
options.template_out ='capicua'
|
194
246
|
end
|
195
247
|
|
196
248
|
subcommands[command].order! internal_args
|
@@ -147,12 +147,13 @@ module CapicuaGen
|
|
147
147
|
|
148
148
|
def configure_template_directories
|
149
149
|
# Configuro las rutas de los templates
|
150
|
-
|
150
|
+
template_local_dir = get_template_local_dir(get_class_file)
|
151
|
+
self.template_directories << template_local_dir if template_local_dir
|
151
152
|
self.template_directories << File.join(File.dirname(get_class_file), '../template')
|
152
153
|
|
153
154
|
end
|
154
155
|
|
155
|
-
|
156
|
+
# Configura los objetivos de las platillas (despues de establecer el generador)
|
156
157
|
def configure_template_targets
|
157
158
|
|
158
159
|
end
|
@@ -216,18 +217,24 @@ module CapicuaGen
|
|
216
217
|
|
217
218
|
exists= File.exist?(out_file)
|
218
219
|
|
219
|
-
|
220
|
+
# Creo el directorio
|
221
|
+
FileUtils::mkdir_p File.dirname(out_file)
|
220
222
|
|
221
223
|
if exists
|
222
|
-
|
224
|
+
if @generator.argv_options.force
|
225
|
+
FileUtils.cp template_file, out_file
|
226
|
+
message_helper.puts_created_template(File.basename(out_file), out_file, :override)
|
227
|
+
else
|
228
|
+
message_helper.puts_created_template(File.basename(out_file), out_file, :ignore)
|
229
|
+
end
|
223
230
|
else
|
231
|
+
FileUtils.cp template_file, out_file
|
224
232
|
message_helper.puts_created_template(File.basename(out_file), out_file, :new)
|
225
233
|
end
|
226
234
|
|
227
|
-
|
228
235
|
else
|
229
236
|
# Creo la salida
|
230
|
-
return TemplateHelper.generate_template(template_file, current_binding, :out_file => out_file, :feature => self, :force => argv_options.force)
|
237
|
+
return TemplateHelper.generate_template(template_file, current_binding, :out_file => out_file, :feature => self, :force => @generator.argv_options.force)
|
231
238
|
end
|
232
239
|
|
233
240
|
|
@@ -289,10 +296,19 @@ module CapicuaGen
|
|
289
296
|
protected
|
290
297
|
# Directorio local para obtener los templates
|
291
298
|
def get_template_local_dir(file)
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
299
|
+
begin
|
300
|
+
feacture_directory= File.dirname(file).split('/')
|
301
|
+
feacture_name = feacture_directory[feacture_directory.count-2]
|
302
|
+
package_name = feacture_directory[feacture_directory.count-3]
|
303
|
+
gem_name = feacture_directory[feacture_directory.count-4]
|
304
|
+
template_local = File.join(@generator.local_templates, gem_name, package_name, feacture_name)
|
305
|
+
|
306
|
+
return template_local
|
307
|
+
|
308
|
+
rescue
|
309
|
+
#Seguramente no sigue la estructura indicada para templates
|
310
|
+
return nil
|
311
|
+
end
|
296
312
|
end
|
297
313
|
|
298
314
|
|
data/lib/CapicuaGen/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module CapicuaGen
|
2
|
-
VERSION = "0.0
|
3
|
-
end
|
1
|
+
module CapicuaGen
|
2
|
+
VERSION = "0.1.0"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CapicuaGen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Luis Bautista Martín
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,20 @@ dependencies:
|
|
98
98
|
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '2.1'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: colorize
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 0.7.7
|
108
|
+
type: :runtime
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - "~>"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.7.7
|
101
115
|
description: |-
|
102
116
|
CapicuaGen es un software que ayuda a la creación automática de
|
103
117
|
sistemas empresariales a través de la definición y ensamblado de
|
@@ -117,7 +131,7 @@ description: |-
|
|
117
131
|
email:
|
118
132
|
- joseluisbautista@gmail.com
|
119
133
|
executables:
|
120
|
-
- capicuagen
|
134
|
+
- capicuagen
|
121
135
|
extensions: []
|
122
136
|
extra_rdoc_files: []
|
123
137
|
files:
|
@@ -133,11 +147,11 @@ files:
|
|
133
147
|
- Rakefile
|
134
148
|
- bin/console
|
135
149
|
- bin/setup
|
136
|
-
- exe/capicuagen
|
150
|
+
- exe/capicuagen
|
137
151
|
- lib/CapicuaGen/Examples/Example/Source/example_feature.rb
|
138
|
-
- lib/CapicuaGen/Examples/Example/Template/
|
139
|
-
- lib/CapicuaGen/Examples/Example/Template/
|
140
|
-
- lib/CapicuaGen/Examples/Example/Template/
|
152
|
+
- lib/CapicuaGen/Examples/Example/Template/Gemfile.erb
|
153
|
+
- lib/CapicuaGen/Examples/Example/Template/generator.erb
|
154
|
+
- lib/CapicuaGen/Examples/Example/Template/instnwnd.erb
|
141
155
|
- lib/CapicuaGen/Mixins/attributes_mixin.rb
|
142
156
|
- lib/CapicuaGen/Mixins/parameter_mixin.rb
|
143
157
|
- lib/CapicuaGen/Mixins/reflection_mixin.rb
|
@@ -168,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
182
|
requirements:
|
169
183
|
- - ">="
|
170
184
|
- !ruby/object:Gem::Version
|
171
|
-
version:
|
185
|
+
version: 2.0.0
|
172
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
187
|
requirements:
|
174
188
|
- - ">="
|