48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/generators/mdwa/transform/transform_generator.rb', line 48
def generate_model_controller_helper_views
@entities.each do |entity|
generator_model = entity.generator_model
namespaces = Dir.glob("#{Rails.root}/#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/*").select{|d| File.directory?(d)}.collect {|n| File.basename(n)}
if !namespaces.count.zero?
namespaces.each do |namespace|
namespace_destino = (namespace != 'frontend') ? namespace : ''
templates_deste_namespace = MDWA::DSL::TEMPLATES_PATH + entity.file_name + '/' + namespace + '/'
mdwa_template "#{entity.file_name}/#{namespace}/model.erb", "app/models/#{namespace_destino}/#{generator_model.singular_name}.rb" if File.exists?(templates_deste_namespace + 'model.erb')
mdwa_template "#{entity.file_name}/#{namespace}/helper.erb", "app/helpers/#{namespace_destino}/#{generator_model.plural_name}_helper.rb" if File.exists?(templates_deste_namespace + 'helper.erb')
mdwa_template "#{entity.file_name}/#{namespace}/controller.erb", "app/controllers/#{namespace_destino}/#{generator_model.plural_name}_controller.rb" if File.exists?(templates_deste_namespace + 'controller.erb')
Dir.glob("#{templates_deste_namespace}/views/*").select{|d| !File.directory?(d)}.each do |file|
file_name = File.basename(file)
mdwa_template "#{entity.file_name}/#{namespace}/views/#{file_name}", "app/views/#{namespace_destino}/#{generator_model.plural_name}/#{file_name}"
end
mdwa_template "#{entity.file_name}/#{namespace}/views/menu/menu.html.erb", "app/views/template/mdwa/menubar/_#{generator_model.plural_name}.html.erb"
end
end
end
end
|