mdd 3.0.20 → 3.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.
- data/app/helpers/mdwa_helper.rb +1 -1
- data/app/views/mdwa/requirements/index.html.erb +3 -1
- data/app/views/template/mdwa/_autocomplete_multiple_tag.html.erb +1 -1
- data/app/views/template/mdwa/_autocomplete_tag.html.erb +6 -0
- data/lib/generators/mdwa/requirement/templates/requirement.rb +1 -0
- data/lib/generators/mdwa/sandbox/sandbox_generator.rb +21 -11
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/all_pages.js +15 -3
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/clicable_title.js +1 -1
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/pagination.js +1 -1
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/template.css.erb +25 -1
- data/lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml +2 -1
- data/lib/generators/mdwa/sandbox/templates/config/locales/{mdwa_model_specific.en.yml → mdwa.specific.en.yml} +0 -0
- data/lib/generators/mdwa/templates/templates/scaffold/{controller.rb → controller.erb} +0 -0
- data/lib/generators/mdwa/templates/templates/scaffold/{helper.rb → helper.erb} +0 -0
- data/lib/generators/mdwa/templates/templates/scaffold/{model.rb → model.erb} +2 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +3 -3
- data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +2 -2
- data/lib/generators/mdwa/templates/templates/scaffold/views/create.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/destroy.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/edit.html.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/index.html.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/new.html.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/show.html.erb +5 -5
- data/lib/generators/mdwa/templates/templates/scaffold/views/update.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates_generator.rb +5 -5
- data/lib/generators/mdwa/transform/transform_generator.rb +83 -35
- data/lib/generators/mdwa/user_scaffold/templates/migrate.erb +30 -0
- data/lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb +1 -1
- data/lib/mdwa/dsl/entity.rb +8 -19
- data/lib/mdwa/dsl/requirement.rb +5 -1
- data/lib/mdwa/version.rb +1 -1
- data/mdd.gemspec +2 -2
- metadata +11 -11
- data/lib/generators/mdwa/user_scaffold/templates/migrate.rb +0 -16
data/app/helpers/mdwa_helper.rb
CHANGED
@@ -11,7 +11,7 @@ module MdwaHelper
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def encode_results_to_autocomplete(results, field_name)
|
14
|
-
|
14
|
+
results.collect{ |c| "{label: \"#{c.send(field_name).html_safe}\", value: \"#{c.id}\"}" }.join( ',' ).html_safe
|
15
15
|
end
|
16
16
|
|
17
17
|
def file_icon_path( file_name, size = 'medium' )
|
@@ -10,6 +10,7 @@
|
|
10
10
|
<tr>
|
11
11
|
<th>Requirement title</th>
|
12
12
|
<th>Description</th>
|
13
|
+
<th>Non-functional concerns</th>
|
13
14
|
<th>Entities</th>
|
14
15
|
<th>Users</th>
|
15
16
|
</tr>
|
@@ -17,6 +18,7 @@
|
|
17
18
|
<tr>
|
18
19
|
<td><%= requirement.summary %></td>
|
19
20
|
<td><%= requirement.description %></td>
|
21
|
+
<td><%= requirement.non_functional_description %></td>
|
20
22
|
<td><%= requirement.entities.join ', ' %></td>
|
21
23
|
<td><%= requirement.users.join ', ' %></td>
|
22
24
|
</tr>
|
@@ -28,4 +30,4 @@
|
|
28
30
|
|
29
31
|
</div>
|
30
32
|
|
31
|
-
</div>
|
33
|
+
</div>
|
@@ -5,6 +5,7 @@ MDWA::DSL.requirements.register do |r|
|
|
5
5
|
r.summary = '<%= @summary %>'
|
6
6
|
r.alias = '<%= @requirement.alias %>' # alias is the unique requirement name and it's created automatically, you can override it with this argument.
|
7
7
|
r.description = %q{Detailed description of the requirement.}
|
8
|
+
r.non_functional_description = %q{Explain the non-functional concerns involved in this requirement.}
|
8
9
|
|
9
10
|
<%- unless options.no_comments %>
|
10
11
|
#
|
@@ -144,7 +144,27 @@ module Mdwa
|
|
144
144
|
# language files
|
145
145
|
copy_file 'config/locales/devise.en.yml', 'config/locales/devise.en.yml'
|
146
146
|
copy_file 'config/locales/mdwa.en.yml', 'config/locales/mdwa.en.yml'
|
147
|
-
|
147
|
+
create_file 'config/locales/mdwa.specific.en.yml', "en:\n"
|
148
|
+
|
149
|
+
# set production pre-compile directives
|
150
|
+
production = []
|
151
|
+
production << "\n # Precompile directives"
|
152
|
+
production << " #####################"
|
153
|
+
production << " #Javascripts"
|
154
|
+
production << " #####################"
|
155
|
+
production << " assets = []"
|
156
|
+
production << " assets << 'mdwa/login_manifest.js'"
|
157
|
+
production << " assets << 'mdwa/public_manifest.js'"
|
158
|
+
production << " assets << 'mdwa/system_manifest.js'"
|
159
|
+
production << " #####################"
|
160
|
+
production << " #CSS"
|
161
|
+
production << " #####################"
|
162
|
+
production << " assets << 'mdwa/login_manifest.css'"
|
163
|
+
production << " assets << 'mdwa/public_manifest.css'"
|
164
|
+
production << " assets << 'mdwa/system_manifest.js'"
|
165
|
+
production << " config.assets.precompile += assets"
|
166
|
+
production << "\n"
|
167
|
+
inject_into_file 'config/environments/production.rb', production.join("\n"), :after => "config.assets.digest = true\n"
|
148
168
|
end
|
149
169
|
|
150
170
|
def routes
|
@@ -163,16 +183,6 @@ module Mdwa
|
|
163
183
|
|
164
184
|
root :to => 'home#index'
|
165
185
|
end
|
166
|
-
|
167
|
-
# Software visualization
|
168
|
-
namespace :mdwa do
|
169
|
-
controller :requirements do
|
170
|
-
get 'requirements/index' => 'requirements#index', :as => 'requirements'
|
171
|
-
get 'requirements/:alias' => 'requirements#show', :as => 'requirement'
|
172
|
-
end
|
173
|
-
|
174
|
-
root :to => 'requirements#index'
|
175
|
-
end
|
176
186
|
"
|
177
187
|
end
|
178
188
|
end
|
data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/all_pages.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$(function() {
|
2
2
|
|
3
3
|
// all .toggle links must have a rel attribute to identify what element will toggle
|
4
|
-
$('a.toggle').
|
4
|
+
$('a.toggle').on('click', function() {
|
5
5
|
$($(this).attr('rel')).toggle();
|
6
6
|
});
|
7
7
|
|
@@ -12,14 +12,19 @@ $(function() {
|
|
12
12
|
});
|
13
13
|
|
14
14
|
// notices fadeout
|
15
|
-
$('a#system_notice_close, #system_notice').
|
15
|
+
$('a#system_notice_close, #system_notice').on('click', function() {
|
16
16
|
$('#system_notice').remove();
|
17
17
|
});
|
18
18
|
|
19
19
|
// ajax forms cancel button closes modal window
|
20
|
-
$('.mdwa_ajax a.cancel').
|
20
|
+
$('.mdwa_ajax a.cancel').on('click', function() {
|
21
21
|
$.fancybox.close(true);
|
22
22
|
});
|
23
|
+
|
24
|
+
// set focus on modalbox form
|
25
|
+
$(document).bind("ajaxComplete", function() {
|
26
|
+
setFocusOnForm();
|
27
|
+
});
|
23
28
|
|
24
29
|
});
|
25
30
|
|
@@ -50,3 +55,10 @@ function deleteSystemNotice() {
|
|
50
55
|
$('#system_notice').remove();
|
51
56
|
});
|
52
57
|
}
|
58
|
+
|
59
|
+
// focus on the first text input field in the first field on the page
|
60
|
+
function setFocusOnForm() {
|
61
|
+
$(':input:enabled:visible:first', "div.filtros").focus();
|
62
|
+
$(':input:enabled:visible:first', "div.mdwa_new").focus();
|
63
|
+
$(':input:enabled:visible:first', "div.mdwa_edit").focus();
|
64
|
+
}
|
data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/template.css.erb
CHANGED
@@ -269,4 +269,28 @@ a#system_notice_close {
|
|
269
269
|
/* Modalbox */
|
270
270
|
.fancybox-inner {
|
271
271
|
background: #fff;
|
272
|
-
}
|
272
|
+
}
|
273
|
+
|
274
|
+
/* List formatting */
|
275
|
+
th.list_show {
|
276
|
+
width: 5%;
|
277
|
+
}
|
278
|
+
|
279
|
+
th.list_edit {
|
280
|
+
width: 5%;
|
281
|
+
}
|
282
|
+
|
283
|
+
td.list_edit {
|
284
|
+
text-align: center !important;
|
285
|
+
}
|
286
|
+
|
287
|
+
td.list_edit a {
|
288
|
+
background: url("<%= asset_path "mdwa/icons/edit.png" %>") no-repeat;
|
289
|
+
padding-left: 24px;
|
290
|
+
}
|
291
|
+
|
292
|
+
td.list_remove a {
|
293
|
+
background: url("<%= asset_path "mdwa/icons/delete.png" %>") no-repeat;
|
294
|
+
padding-left: 24px;
|
295
|
+
padding-bottom: 1px;
|
296
|
+
}
|
@@ -3,7 +3,7 @@ en:
|
|
3
3
|
email_label: "E-mail:"
|
4
4
|
password_label: "Password:"
|
5
5
|
login_button_label: "Login"
|
6
|
-
login_text_pre_form: "Welcome to
|
6
|
+
login_text_pre_form: "Welcome to a MDWA software. <br />Please login to access this app."
|
7
7
|
|
8
8
|
system:
|
9
9
|
error: "error"
|
@@ -20,6 +20,7 @@ en:
|
|
20
20
|
index_confirm_deletion: "Are you sure?"
|
21
21
|
add_by_ajax: "Add new %{name}"
|
22
22
|
edit_by_ajax: "Edit %{name}"
|
23
|
+
no_file: "No file"
|
23
24
|
|
24
25
|
administrators:
|
25
26
|
edit_title: "Editing account: %{name}"
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
===entity_code===
|
3
|
+
|
3
4
|
class <%= @model.klass %> < <%= !@entity.user? ? 'ActiveRecord::Base' : 'User' %>
|
4
5
|
|
5
6
|
<%- # model attributes -%>
|
6
7
|
<%- unless @model.attributes.count.zero? -%>
|
7
|
-
attr_accessible <%= @model.attributes.collect {|a| ":" + a.name }.join(', ') %>
|
8
|
+
attr_accessible <%= @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.collect {|a| ":" + a.name }.join(', ') %>
|
8
9
|
<%- end -%>
|
9
10
|
<%- # paperclip file uploads -%>
|
10
11
|
<%- unless @model.attributes.select{|attr| attr.type.to_sym == :file}.count.zero? -%>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
===entity_code===
|
2
|
-
<%- @model.attributes.select{|a|
|
2
|
+
<%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
|
3
3
|
<div class="field">
|
4
|
-
<%%= f.label :<%= attr.name %>, t('<%= @model.plural_name %>.
|
4
|
+
<%%= f.label :<%= attr.name %>, t('<%= @model.plural_name %>.edit.<%= attr.name %>') %>
|
5
5
|
<%- if attr.type.to_sym == :file -%>
|
6
6
|
<%% unless @<%= @model.singular_name %>.new_record? %>
|
7
7
|
<span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<%- next if assoc.skip_views? %>
|
16
16
|
<%- if assoc.belongs_to? -%>
|
17
17
|
<div class="field">
|
18
|
-
<%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.
|
18
|
+
<%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>') %>
|
19
19
|
<%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
|
20
20
|
options_for_select( <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').collect{ |c| [c.<%= assoc.reference_field %>, c.id] }, f.object.<%= assoc.model2.singular_name.foreign_key %> ),
|
21
21
|
:prompt => '-- Select --' %>
|
@@ -3,11 +3,11 @@
|
|
3
3
|
<thead>
|
4
4
|
<th class="list_show"><%%= t 'system.index_id' %></th>
|
5
5
|
<th class="list_edit"><%%= t 'system.index_edit' %></th>
|
6
|
-
<%- @model.attributes.select{|a|
|
6
|
+
<%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
|
7
7
|
<th><%%= t '<%= @model.plural_name %>.index_<%= attr.name %>' %></th>
|
8
8
|
<%- end -%>
|
9
9
|
<%- @model.associations.each do |assoc| -%>
|
10
|
-
<th><%%= t '<%= @model.plural_name %>.
|
10
|
+
<th><%%= t '<%= @model.plural_name %>.index.<%= assoc.model2.singular_name %>' %></th>
|
11
11
|
<%- end -%>
|
12
12
|
<th class="list_remove"><%%= t 'system.index_remove' %></th>
|
13
13
|
</thead>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
===entity_code===
|
2
2
|
<%% if @<%= @model.singular_name %>.errors.any? %>
|
3
|
-
$("#mdwa_error").html("<%%=
|
3
|
+
$("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
|
4
4
|
<%% else %>
|
5
5
|
$.fancybox.close(true);
|
6
6
|
$("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
|
@@ -1,3 +1,3 @@
|
|
1
1
|
===entity_code===
|
2
2
|
$("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
|
3
|
-
$('body').append("<%%=
|
3
|
+
$('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
|
@@ -1,7 +1,7 @@
|
|
1
1
|
===entity_code===
|
2
2
|
<div id="<%= @model.plural_name %>_index" class="mdwa_index">
|
3
3
|
<div class="page_header">
|
4
|
-
<h1><%%= t '<%= @model.plural_name %>.
|
4
|
+
<h1><%%= t '<%= @model.plural_name %>.title.index' %></h1>
|
5
5
|
<%- if @entity.ajax -%>
|
6
6
|
<div class="page_header_right_tab">
|
7
7
|
<%%= link_to t('system.add_by_ajax', :name => '<%= @model.singular_name.humanize %>'), new_<%= @model.object_name %>_path, :class => 'lightbox various fancybox.ajax' %>
|
@@ -1,18 +1,18 @@
|
|
1
1
|
===entity_code===
|
2
2
|
<div id="<%= @model.plural_name %>_show" class="mdwa_show">
|
3
3
|
<div class="page_header">
|
4
|
-
<h1><%%= t('<%= @model.plural_name %>.
|
4
|
+
<h1><%%= t('<%= @model.plural_name %>.title.show') %></h1>
|
5
5
|
</div>
|
6
6
|
|
7
7
|
<div class="inside">
|
8
|
-
<%- @model.attributes.
|
8
|
+
<%- @model.attributes.each do |attr| -%>
|
9
9
|
<div class="field">
|
10
|
-
<label><%%= t '<%= @model.plural_name %>.
|
10
|
+
<label><%%= t '<%= @model.plural_name %>.show.<%= attr.name %>' %></label>
|
11
11
|
<%- if attr.type.to_sym == :file -%>
|
12
12
|
<%% unless @<%= @model.singular_name %>.<%= attr.name %>.nil? %>
|
13
13
|
<span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
|
14
14
|
<%% else %>
|
15
|
-
|
15
|
+
<%%= t('system.no_file') %>
|
16
16
|
<%% end %>
|
17
17
|
<%- else -%>
|
18
18
|
<span><%%= @<%= @model.singular_name %>.<%= attr.name %> %></span>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<%- end -%>
|
22
22
|
<%- @model.associations.each do |assoc| -%>
|
23
23
|
<div class="field">
|
24
|
-
<label><%%= t '<%= @model.plural_name %>.
|
24
|
+
<label><%%= t '<%= @model.plural_name %>.show.<%= assoc.model2.singular_name %>' %></label>
|
25
25
|
<span>
|
26
26
|
<%- if assoc.belongs_to? || assoc.nested_one? -%>
|
27
27
|
<%%= @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.<%= assoc.reference_field %> unless @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.nil? %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
===entity_code===
|
2
2
|
<%% if @<%= @model.singular_name %>.errors.any? %>
|
3
|
-
$("#mdwa_error").html("<%%=
|
3
|
+
$("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
|
4
4
|
<%% else %>
|
5
5
|
if( $('#<%= @model.plural_name %>_list').length > 0 ) {
|
6
6
|
$.fancybox.close(true);
|
@@ -49,12 +49,12 @@ module Mdwa
|
|
49
49
|
model = entity.generator_model
|
50
50
|
|
51
51
|
puts '--------------------------------------'
|
52
|
-
puts "-
|
52
|
+
puts "- Templates for: #{entity.name} -"
|
53
53
|
puts '--------------------------------------'
|
54
54
|
|
55
|
-
copy_with_header 'scaffold/controller.
|
56
|
-
copy_with_header 'scaffold/helper.
|
57
|
-
copy_with_header 'scaffold/model.
|
55
|
+
copy_with_header 'scaffold/controller.erb', "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}controller.erb", entity.name
|
56
|
+
copy_with_header 'scaffold/helper.erb', "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}helper.erb", entity.name
|
57
|
+
copy_with_header 'scaffold/model.erb', "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}model.erb", entity.name
|
58
58
|
|
59
59
|
# views
|
60
60
|
copy_with_header 'scaffold/views/_form_fields.html.erb', "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}views/_form_fields.html.erb", entity.name
|
@@ -84,7 +84,7 @@ module Mdwa
|
|
84
84
|
|
85
85
|
model = entity.generator_model
|
86
86
|
|
87
|
-
path_to_controller = "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}controller.
|
87
|
+
path_to_controller = "#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/#{model.space + '/'}controller.erb"
|
88
88
|
controller_string = File.read("#{Rails.root}/#{path_to_controller}")
|
89
89
|
|
90
90
|
# hooks for code generations
|
@@ -49,9 +49,9 @@ module Mdwa
|
|
49
49
|
namespaces = Dir.glob("#{Rails.root}/#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/*").select{|d| File.directory?(d) and File.basename(d) != 'views'}
|
50
50
|
if !namespaces.count.zero?
|
51
51
|
namespaces.each do |namespace|
|
52
|
-
mdwa_template "#{entity.file_name}/#{File.basename namespace}/model.
|
53
|
-
mdwa_template "#{entity.file_name}/#{File.basename namespace}/helper.
|
54
|
-
mdwa_template "#{entity.file_name}/#{File.basename namespace}/controller.
|
52
|
+
mdwa_template "#{entity.file_name}/#{File.basename namespace}/model.erb", "app/models/#{File.basename namespace}/#{generator_model.singular_name}.rb"
|
53
|
+
mdwa_template "#{entity.file_name}/#{File.basename namespace}/helper.erb", "app/helpers/#{File.basename namespace}/#{generator_model.plural_name}_helper.rb"
|
54
|
+
mdwa_template "#{entity.file_name}/#{File.basename namespace}/controller.erb", "app/controllers/#{File.basename namespace}/#{generator_model.plural_name}_controller.rb"
|
55
55
|
Dir.glob("#{namespace}/views/*").each do |file|
|
56
56
|
file_name = File.basename(file)
|
57
57
|
mdwa_template "#{entity.file_name}/#{File.basename namespace}/views/#{file_name}", "app/views/#{File.basename namespace}/#{generator_model.plural_name}/#{file_name}"
|
@@ -79,6 +79,18 @@ module Mdwa
|
|
79
79
|
# clear routes file contents
|
80
80
|
File.truncate(path_to_routes, 0)
|
81
81
|
append_file path_to_routes, "def mdwa_router(router)\n\nend"
|
82
|
+
|
83
|
+
inject_into_file path_to_routes, :after => "def mdwa_router(router)\n" do
|
84
|
+
"\n# Software visualization
|
85
|
+
namespace :mdwa do
|
86
|
+
controller :requirements do
|
87
|
+
get 'requirements/index' => 'requirements#index', :as => 'requirements'
|
88
|
+
get 'requirements/:alias' => 'requirements#show', :as => 'requirement'
|
89
|
+
end
|
90
|
+
|
91
|
+
root :to => 'requirements#index'
|
92
|
+
end"
|
93
|
+
end
|
82
94
|
|
83
95
|
MDWA::DSL.entities.all.each do |entity|
|
84
96
|
generator_model = entity.generator_model
|
@@ -86,11 +98,11 @@ module Mdwa
|
|
86
98
|
# inject scaffold code
|
87
99
|
inject_into_file path_to_routes, :after => "def mdwa_router(router)\n" do
|
88
100
|
route_str = []
|
89
|
-
route_str << "\n
|
90
|
-
route_str << "
|
91
|
-
route_str << "
|
92
|
-
route_str << "
|
93
|
-
route_str << "\
|
101
|
+
route_str << "\n namespace :#{generator_model.space} do" if generator_model.namespace?
|
102
|
+
route_str << " controller :#{generator_model.plural_name} do"
|
103
|
+
route_str << " end"
|
104
|
+
route_str << " resources :#{generator_model.plural_name}"
|
105
|
+
route_str << " end\n" if generator_model.namespace?
|
94
106
|
|
95
107
|
route_str.join "\n"
|
96
108
|
end
|
@@ -108,7 +120,7 @@ module Mdwa
|
|
108
120
|
|
109
121
|
def generate_locales
|
110
122
|
|
111
|
-
locales_file = 'config/locales/
|
123
|
+
locales_file = 'config/locales/mdwa.specific.en.yml'
|
112
124
|
locales_content = File.read(locales_file)
|
113
125
|
# make sure the file exist
|
114
126
|
create_file locales_file unless File.exist?(Rails.root + locales_file)
|
@@ -119,28 +131,40 @@ module Mdwa
|
|
119
131
|
append_file locales_file, :after => "en:\n" do
|
120
132
|
lines = []
|
121
133
|
lines << " #{model.plural_name}:"
|
122
|
-
lines << "
|
123
|
-
lines << "
|
124
|
-
lines << "
|
125
|
-
lines << "
|
126
|
-
lines << "
|
127
|
-
lines << "
|
128
|
-
lines << "
|
134
|
+
lines << " notice:"
|
135
|
+
lines << " create: \"#{model.singular_name.humanize} created.\""
|
136
|
+
lines << " update: \"#{model.singular_name.humanize} updated.\""
|
137
|
+
lines << " destroy: \"#{model.singular_name.humanize} destroyed.\""
|
138
|
+
lines << " title:"
|
139
|
+
lines << " index: \"#{model.plural_name.humanize}\""
|
140
|
+
lines << " show: \"#{model.singular_name.humanize}\""
|
141
|
+
lines << " new: \"New #{model.singular_name.humanize}\""
|
142
|
+
lines << " edit: \"Edit #{model.singular_name.humanize}\""
|
143
|
+
# INDEX
|
144
|
+
lines << " index:"
|
145
|
+
model.attributes.each do |attr|
|
146
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
147
|
+
end
|
148
|
+
model.associations.each do |assoc|
|
149
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
150
|
+
end
|
151
|
+
# EDIT
|
152
|
+
lines << " edit:"
|
129
153
|
model.attributes.each do |attr|
|
130
|
-
lines << "
|
131
|
-
lines << " show_#{attr.name}: \"#{attr.name.humanize}\""
|
132
|
-
lines << " edit_#{attr.name}: \"#{attr.name.humanize}\""
|
154
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
133
155
|
end
|
134
156
|
model.associations.each do |assoc|
|
135
|
-
|
136
|
-
lines << " index_#{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\""
|
137
|
-
lines << " show_#{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\""
|
138
|
-
lines << " edit_#{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\""
|
139
|
-
else
|
140
|
-
lines << " index_#{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\""
|
141
|
-
lines << " show_#{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\""
|
142
|
-
end
|
157
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
143
158
|
end
|
159
|
+
# SHOW
|
160
|
+
lines << " show:"
|
161
|
+
model.attributes.each do |attr|
|
162
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
163
|
+
end
|
164
|
+
model.associations.each do |assoc|
|
165
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
166
|
+
end
|
167
|
+
|
144
168
|
lines << "\n"
|
145
169
|
lines.join("\n")
|
146
170
|
end
|
@@ -206,11 +230,20 @@ module Mdwa
|
|
206
230
|
entity_attribute = entity.attributes[column.name]
|
207
231
|
# model attribute exists, but not in entity -> was erased
|
208
232
|
if entity_attribute.nil?
|
209
|
-
|
233
|
+
# atributo não é derivado de file, pode apagar na moral
|
234
|
+
if !column.name.ends_with?("_file_name") and !column.name.ends_with?("_content_type") and !column.name.ends_with?("_file_size") and !column.name.ends_with?("_updated_at")
|
235
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type}
|
236
|
+
else
|
237
|
+
# se o atributo é derivado de file e não existe o file na entidade, apaga
|
238
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_name") and entity.attributes[column.name.delete("_file_name")].nil?
|
239
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_content_type") and entity.attributes[column.name.delete("_content_type")].nil?
|
240
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_size") and entity.attributes[column.name.delete("_file_size")].nil?
|
241
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_updated_at") and entity.attributes[column.name.delete("_updated_at")].nil?
|
242
|
+
end
|
210
243
|
# attribute exists in model and entity, but changed type
|
211
244
|
elsif entity_attribute.type.to_sym != column.type.to_sym
|
212
245
|
# ignores files, passwords and float, decimal, integer variations
|
213
|
-
next if entity_attribute.type.to_sym == :
|
246
|
+
next if entity_attribute.type.to_sym == :password or ((column.type.to_sym == :integer or column.type.to_sym == :decimal) and entity_attribute.type.to_sym == :float)
|
214
247
|
@changes << {:entity => entity, :type => 'change_column', :column => column.name, :attr_type => entity_attribute.type, :from => column.type}
|
215
248
|
end
|
216
249
|
end
|
@@ -218,7 +251,15 @@ module Mdwa
|
|
218
251
|
# new attributes
|
219
252
|
# no column with that name -> column must be added
|
220
253
|
entity.attributes.each do |key, attr|
|
221
|
-
|
254
|
+
# se a entidade for file e não existir seus atributos no banco de dados, corrige
|
255
|
+
if attr.type.to_sym == :file
|
256
|
+
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_file_name", :attr_type => 'string'} if model_class.columns.select{|c| c.name == "#{attr.name}_file_name"}.count.zero?
|
257
|
+
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_content_type", :attr_type => 'string'} if model_class.columns.select{|c| c.name == "#{attr.name}_content_type"}.count.zero?
|
258
|
+
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_file_size", :attr_type => 'integer'} if model_class.columns.select{|c| c.name == "#{attr.name}_file_size"}.count.zero?
|
259
|
+
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_updated_at", :attr_type => 'datetime'} if model_class.columns.select{|c| c.name == "#{attr.name}_updated_at"}.count.zero?
|
260
|
+
|
261
|
+
# nenhuma coluna com esse nome
|
262
|
+
elsif model_class.columns.select {|c| c.name == attr.name }.count.zero?
|
222
263
|
@changes << {:entity => entity, :type => 'add_column', :column => attr.name, :attr_type => attr.type}
|
223
264
|
end
|
224
265
|
end
|
@@ -279,22 +320,29 @@ module Mdwa
|
|
279
320
|
# create table
|
280
321
|
migration_string << "\n\tdef self.up"
|
281
322
|
migration_string << "\t\tcreate_table :#{generator_model.plural_name} do |t|"
|
282
|
-
generator_model.attributes.each do |attr|
|
283
|
-
|
323
|
+
generator_model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr|
|
324
|
+
if attr.type.to_sym != :file
|
325
|
+
migration_string << "\t\t\tt.#{attr.migration_field} :#{attr.name}"
|
326
|
+
else
|
327
|
+
migration_string << "\t\t\tt.string :#{attr.name}_file_name"
|
328
|
+
migration_string << "\t\t\tt.string :#{attr.name}_content_type"
|
329
|
+
migration_string << "\t\t\tt.integer :#{attr.name}_file_size"
|
330
|
+
migration_string << "\t\t\tt.datetime :#{attr.name}_updated_at"
|
331
|
+
end
|
284
332
|
end
|
285
333
|
generator_model.associations.each do |assoc|
|
286
334
|
if assoc.belongs_to? or assoc.nested_one?
|
287
335
|
migration_string << "\t\t\tt.integer :#{assoc.model2.singular_name.foreign_key}"
|
288
336
|
end
|
289
337
|
end
|
290
|
-
migration_string << "\
|
291
|
-
migration_string << "\t\tend"
|
338
|
+
migration_string << "\n\t\tt.timestamps"
|
339
|
+
migration_string << "\t\tend" # fim do create_table
|
292
340
|
generator_model.associations.each do |assoc|
|
293
341
|
if assoc.belongs_to? or assoc.nested_one?
|
294
342
|
migration_string << "\t\tadd_index :#{assoc.model1.plural_name}, :#{assoc.model2.singular_name.foreign_key}"
|
295
343
|
end
|
296
344
|
end
|
297
|
-
migration_string << "\n\tend"
|
345
|
+
migration_string << "\n\tend" # fim do self.up
|
298
346
|
|
299
347
|
# drop table
|
300
348
|
migration_string << "\n\tdef self.down"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers < ActiveRecord::Migration
|
3
|
+
|
4
|
+
def self.up
|
5
|
+
<%- @model.simple_attributes.each do |attr| -%>
|
6
|
+
<%- if !attr.type.to_sym == :file -%>
|
7
|
+
add_column :users, :<%= attr.name %>, :<%= attr.migration_field %>
|
8
|
+
<%- else -%>
|
9
|
+
add_column :users, :<%= attr.name %>_file_name, :string
|
10
|
+
add_column :users, :<%= attr.name %>_content_type, :string
|
11
|
+
add_column :users, :<%= attr.name %>_file_size, :integer
|
12
|
+
add_column :users, :<%= attr.name %>_updated_at, :datetime
|
13
|
+
<%- end -%>
|
14
|
+
<%- end -%>
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
<%- @model.simple_attributes.each do |attr| -%>
|
19
|
+
<%- if !attr.type.to_sym == :file -%>
|
20
|
+
remove_column :users, :<%= attr.name %>
|
21
|
+
<%- else -%>
|
22
|
+
remove_column :users, :<%= attr.name %>_file_name
|
23
|
+
remove_column :users, :<%= attr.name %>_content_type
|
24
|
+
remove_column :users, :<%= attr.name %>_file_size
|
25
|
+
remove_column :users, :<%= attr.name %>_updated_at
|
26
|
+
<%- end -%>
|
27
|
+
<%- end -%>
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -76,7 +76,7 @@ module Mdwa
|
|
76
76
|
@model.add_attribute attr
|
77
77
|
end
|
78
78
|
end
|
79
|
-
migration_template 'migrate.
|
79
|
+
migration_template 'migrate.erb', "db/migrate/add_#{@model.attributes.collect{|a| a.name}.join('_')}_to_users" unless @model.attributes.empty?
|
80
80
|
|
81
81
|
# include type in db:seed
|
82
82
|
append_file 'db/seeds/site.rb' do
|
data/lib/mdwa/dsl/entity.rb
CHANGED
@@ -87,25 +87,14 @@ module MDWA
|
|
87
87
|
|
88
88
|
#
|
89
89
|
# Declares one attribute of the list using the block given.
|
90
|
-
def attribute(name, type, options = {})
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
self.attributes[attr.name] = attr
|
99
|
-
end
|
100
|
-
else
|
101
|
-
attr = EntityAttribute.new(self)
|
102
|
-
attr.name = name
|
103
|
-
attr.type = type
|
104
|
-
attr.default = options[:default] unless options[:default].blank?
|
105
|
-
attr.style = options[:style] unless options[:style].blank?
|
106
|
-
attr.raise_errors_if_invalid!
|
107
|
-
self.attributes[attr.name] = attr
|
108
|
-
end
|
90
|
+
def attribute(name, type, options = {})
|
91
|
+
attr = EntityAttribute.new(self)
|
92
|
+
attr.name = name
|
93
|
+
attr.type = type
|
94
|
+
attr.default = options[:default] unless options[:default].blank?
|
95
|
+
attr.style = options[:style] unless options[:style].blank?
|
96
|
+
attr.raise_errors_if_invalid!
|
97
|
+
self.attributes[attr.name] = attr
|
109
98
|
end
|
110
99
|
|
111
100
|
#
|
data/lib/mdwa/dsl/requirement.rb
CHANGED
@@ -4,7 +4,7 @@ module MDWA
|
|
4
4
|
|
5
5
|
class Requirement
|
6
6
|
|
7
|
-
attr_accessor :summary, :description, :alias, :users, :entities
|
7
|
+
attr_accessor :summary, :description, :alias, :users, :entities, :non_functional_description
|
8
8
|
|
9
9
|
def initialize(summary = nil)
|
10
10
|
self.summary = summary
|
@@ -17,6 +17,10 @@ module MDWA
|
|
17
17
|
@alias ||= self.summary.to_alias
|
18
18
|
end
|
19
19
|
|
20
|
+
def non_functional?
|
21
|
+
!self.non_functional_description.blank?
|
22
|
+
end
|
23
|
+
|
20
24
|
end
|
21
25
|
|
22
26
|
end # dsl
|
data/lib/mdwa/version.rb
CHANGED
data/mdd.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "mdd"
|
15
15
|
|
16
|
-
s.add_dependency 'rails', '>= 3.
|
17
|
-
s.add_dependency 'jquery-rails', '>= 2.0'
|
16
|
+
s.add_dependency 'rails', '>= 3.2.11'
|
17
|
+
s.add_dependency 'jquery-rails', '>= 2.2.0'
|
18
18
|
s.add_dependency 'devise', '>= 2.1'
|
19
19
|
s.add_dependency 'cancan', '>= 1.6'
|
20
20
|
s.add_dependency 'will_paginate', '>= 3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.2.11
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.2.11
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: jquery-rails
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 2.2.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 2.2.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: devise
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -403,7 +403,7 @@ files:
|
|
403
403
|
- lib/generators/mdwa/sandbox/templates/config/initializers/will_paginate.rb
|
404
404
|
- lib/generators/mdwa/sandbox/templates/config/locales/devise.en.yml
|
405
405
|
- lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml
|
406
|
-
- lib/generators/mdwa/sandbox/templates/config/locales/
|
406
|
+
- lib/generators/mdwa/sandbox/templates/config/locales/mdwa.specific.en.yml
|
407
407
|
- lib/generators/mdwa/sandbox/templates/db/migrate/create_permissions.rb
|
408
408
|
- lib/generators/mdwa/sandbox/templates/db/migrate/create_user_permissions.rb
|
409
409
|
- lib/generators/mdwa/sandbox/templates/db/migrate/devise_create_users.rb
|
@@ -436,9 +436,9 @@ files:
|
|
436
436
|
- lib/generators/mdwa/templates/templates/actions/view.js.erb
|
437
437
|
- lib/generators/mdwa/templates/templates/actions/view.json.erb
|
438
438
|
- lib/generators/mdwa/templates/templates/general/routes.rb
|
439
|
-
- lib/generators/mdwa/templates/templates/scaffold/controller.
|
440
|
-
- lib/generators/mdwa/templates/templates/scaffold/helper.
|
441
|
-
- lib/generators/mdwa/templates/templates/scaffold/model.
|
439
|
+
- lib/generators/mdwa/templates/templates/scaffold/controller.erb
|
440
|
+
- lib/generators/mdwa/templates/templates/scaffold/helper.erb
|
441
|
+
- lib/generators/mdwa/templates/templates/scaffold/model.erb
|
442
442
|
- lib/generators/mdwa/templates/templates/scaffold/views/_form.html.erb
|
443
443
|
- lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb
|
444
444
|
- lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb
|
@@ -458,7 +458,7 @@ files:
|
|
458
458
|
- lib/generators/mdwa/user_scaffold/USAGE
|
459
459
|
- lib/generators/mdwa/user_scaffold/templates/controllers/ajax_controller.rb
|
460
460
|
- lib/generators/mdwa/user_scaffold/templates/controllers/controller.rb
|
461
|
-
- lib/generators/mdwa/user_scaffold/templates/migrate.
|
461
|
+
- lib/generators/mdwa/user_scaffold/templates/migrate.erb
|
462
462
|
- lib/generators/mdwa/user_scaffold/templates/views/update.js.erb
|
463
463
|
- lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb
|
464
464
|
- lib/mdd.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers < ActiveRecord::Migration
|
3
|
-
|
4
|
-
def self.up
|
5
|
-
<%- @model.simple_attributes.each do |attr| -%>
|
6
|
-
add_column :users, :<%= attr.name %>, :<%= attr.migration_field %>
|
7
|
-
<%- end -%>
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
<%- @model.simple_attributes.each do |attr| -%>
|
12
|
-
remove_column :users, :<%= attr.name %>
|
13
|
-
<%- end -%>
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|