ultra_light_wizard 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +0 -0
- data/.ruby-version +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +40 -35
- data/Rakefile +0 -0
- data/VERSION +1 -1
- data/lib/generators/templates/app/controllers/model_controller.rb.erb +0 -0
- data/lib/generators/templates/app/controllers/wizard_steps_controller.rb.erb +0 -0
- data/lib/generators/templates/app/models/wizard_step_model.rb.erb +0 -0
- data/lib/generators/templates/app/views/wizard_step_view.html.erb +2 -1
- data/lib/generators/ultra_light_wizard/{wizard_generator.rb → scaffold_generator.rb} +22 -3
- data/lib/ultra_light_wizard.rb +0 -0
- data/ruby187.Gemfile +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/ultra_light_wizard/ultra_light_wizard_spec.rb +0 -0
- data/ultra_light_wizard.gemspec +5 -5
- data/ultra_light_wizard.jpg +0 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8aa77dc46a2504759cd6e587b87259a3c939541
|
4
|
+
data.tar.gz: db43b213bf6684703c6e5e05a4b2bd51709a7585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f97a1b85a1532534b8cf9e05027cb4724d1261ebd107dc36d8c198f4397ce8e9e78f408e315a988b24a3491fec19c40d74b2f8bb8cde3026449195ebaca3351
|
7
|
+
data.tar.gz: a12fdbf28e420f159677fa1604b5c2627863faed215c6069a2812d2c583ab9183964e9d8d84002d3d6d8192b0ba2c3b79ddc1dd6ab817d00e8fbfc600fdc462e
|
data/.ruby-gemset
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Ultra Light Wizard
|
2
|
-
|
1
|
+
Ultra Light Wizard v0.1.0 (beta)
|
2
|
+
================================
|
3
3
|
|
4
4
|
No time to manage a wizard state machine, session variables, or complicated controllers? Use Ultra Light Wizard!! A RESTful session-less validation-friendly simple wizard approach in Rails.
|
5
5
|
|
@@ -8,18 +8,32 @@ No time to manage a wizard state machine, session variables, or complicated cont
|
|
8
8
|
This RailsConf 2014 talk video explains it all:
|
9
9
|
https://www.youtube.com/watch?v=muyfoiKHMMA
|
10
10
|
|
11
|
+
Principles
|
12
|
+
==========
|
13
|
+
|
14
|
+
- REST: wizard steps are represented as REST nested resources under the model resource being built
|
15
|
+
- MVC: respects MVC separation of concerns
|
16
|
+
- OO: honors OO principles of low coupling and high cohesion
|
17
|
+
- Design Patterns: wizard is simply a model Builder
|
18
|
+
- DDD: supports domain concepts directly with customizable vocabulary
|
19
|
+
- Non-Functional Requirements:
|
20
|
+
- Productivity: minimum effort for adding wizards and wizard steps
|
21
|
+
- Maintainability: minimum code to maintain while adhering to other principles
|
22
|
+
- Performance: stateless design means scalability
|
23
|
+
- Security: stateless design is compatible with Rails security measures
|
24
|
+
|
11
25
|
Instructions
|
12
26
|
============
|
13
27
|
|
14
28
|
Simply use the following command in place of the Rails scaffold generator, and it will scaffold both standard resource and wizard components
|
15
29
|
|
16
|
-
```rails generate ultra_light_wizard:
|
30
|
+
```rails generate ultra_light_wizard:scaffold (resource) steps:(step1),(step2),(step3),... attributes:(attribute1:db_type1),(attribute2:db_type2),...```
|
17
31
|
|
18
32
|
This will generate wizard step routes, controller, models, and views
|
19
33
|
|
20
34
|
Example:
|
21
35
|
|
22
|
-
```rails generate ultra_light_wizard:
|
36
|
+
```rails generate ultra_light_wizard:scaffold Project steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date```
|
23
37
|
|
24
38
|
Output:
|
25
39
|
|
@@ -58,7 +72,7 @@ generate scaffold
|
|
58
72
|
invoke scss
|
59
73
|
identical app/assets/stylesheets/scaffolds.scss
|
60
74
|
conflict app/controllers/projects_controller.rb
|
61
|
-
Overwrite
|
75
|
+
Overwrite ~/code/rails_example/app/controllers/projects_controller.rb? (enter "h" for help) [Ynaqdh] a
|
62
76
|
force app/controllers/projects_controller.rb
|
63
77
|
create app/controllers/project_steps_controller.rb
|
64
78
|
create app/helpers/project_steps_helper.rb
|
@@ -78,13 +92,21 @@ resources :project_steps, only: [:edit, :update]
|
|
78
92
|
end
|
79
93
|
```
|
80
94
|
|
95
|
+
Once the files are generated, you can proceed to place your own code customizations in the wizard step models and views.
|
96
|
+
|
97
|
+
To kick-off wizard, simply trigger the main model controller create action, and it will transition to the wizard step first step edit action.
|
98
|
+
|
99
|
+
For example, the following will kick-off the project wizard by creating a project and automatically redirecting to first step:
|
100
|
+
|
101
|
+
```<%= link_to 'New Project', projects_path, method: :post %>```
|
102
|
+
|
81
103
|
It will ask you at one point to overwrite projects_controller generated in included scaffold. Type y or a to have it continue.
|
82
104
|
|
83
105
|
If you'd like to customize the term "step", you can add a step_alias:(alias) option as in the following:
|
84
106
|
|
85
107
|
Example:
|
86
108
|
|
87
|
-
```rails generate ultra_light_wizard:
|
109
|
+
```rails generate ultra_light_wizard:scaffold Project steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date step_alias:part```
|
88
110
|
|
89
111
|
Output:
|
90
112
|
|
@@ -123,7 +145,7 @@ generate scaffold
|
|
123
145
|
invoke scss
|
124
146
|
identical app/assets/stylesheets/scaffolds.scss
|
125
147
|
conflict app/controllers/projects_controller.rb
|
126
|
-
Overwrite
|
148
|
+
Overwrite ~/code/rails_example/app/controllers/projects_controller.rb? (enter "h" for help) [Ynaqdh] a
|
127
149
|
force app/controllers/projects_controller.rb
|
128
150
|
create app/controllers/project_parts_controller.rb
|
129
151
|
create app/helpers/project_parts_helper.rb
|
@@ -143,50 +165,33 @@ resources :project_parts, only: [:edit, :update]
|
|
143
165
|
end
|
144
166
|
```
|
145
167
|
|
146
|
-
Once the files are generated, you can proceed to place your own code customizations in the wizard step models and views.
|
147
|
-
|
148
|
-
To kick-off wizard, simply trigger the main model controller create action, and it will transition to the wizard step first step edit action.
|
149
|
-
|
150
|
-
For example, the following will kick-off the project wizard by creating a project and automatically redirecting to first step:
|
151
|
-
|
152
|
-
```<%= link_to 'New Project', projects_path, method: :post %>```
|
153
|
-
|
154
168
|
To learn more about the Ultra Light Wizard philosophy and function, please read this [Code Painter](http://www.codepainter.ca) blog post: [Ultra Light & Maintainable Wizard in Rails] (http://www.codepainter.ca/2013/10/ultra-light-maintainable-wizards-in.html)
|
155
169
|
|
156
|
-
Principles
|
157
|
-
==========
|
158
|
-
|
159
|
-
- REST: wizard steps are represented as REST nested resources under the model resource being built
|
160
|
-
- MVC: respects MVC separation of concerns
|
161
|
-
- OO: honors OO principles of low coupling and high cohesion
|
162
|
-
- Design Patterns: wizard is simply a model Builder
|
163
|
-
- DDD: supports domain concepts directly with customizable vocabulary
|
164
|
-
- Non-Functional Requirements:
|
165
|
-
- Productivity: minimum effort for adding wizards and wizard steps
|
166
|
-
- Maintainability: minimum code to maintain while adhering to other principles
|
167
|
-
- Performance: stateless design means scalability
|
168
|
-
- Security: stateless design is compatible with Rails security measures
|
169
|
-
|
170
170
|
Features
|
171
171
|
========
|
172
172
|
|
173
|
-
- Wizard
|
173
|
+
- Ultra Light Wizard scaffold generator
|
174
|
+
+ [DONE] Scaffolding of main model controller/views/migration
|
174
175
|
+ [DONE] Routes
|
175
176
|
+ [DONE] Controller steps
|
176
177
|
+ [DONE] Model parts
|
177
178
|
+ [DONE] View parts
|
178
179
|
+ [DONE] View navigation
|
179
|
-
+ [DONE] Helper
|
180
|
+
+ [DONE] Helper for ultra light wizard support
|
180
181
|
+ [DONE] Route helper methods
|
181
182
|
+ [DONE] Wizard kick-off helper/view
|
182
183
|
+ [DONE] Forms
|
183
|
-
- Form fields
|
184
|
-
+ [DONE] Scaffolding of main model controller/views/migration
|
185
184
|
+ [DONE] Support for attributes
|
185
|
+
+ [DONE] Form fields
|
186
|
+
+ [DONE] Custom name conventions
|
187
|
+
- Write automated tests
|
186
188
|
- Support for nested resources
|
187
189
|
- Modularize (perhaps extracting sub-generators)
|
188
|
-
|
189
|
-
|
190
|
+
|
191
|
+
Enhancements
|
192
|
+
============
|
193
|
+
|
194
|
+
If you are interested in having enhancements implemented, please report via a GitHub issue, describing the problem, providing use case examples, and suggesting solutions to implement. I'd be happy to implement as part of paid work if needed ASAP using the [CodeMentor platform](https://www.codementor.io/andymaleh).
|
190
195
|
|
191
196
|
License
|
192
197
|
=======
|
data/Rakefile
CHANGED
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<h1><%= file_path.humanize %> wizard</h1>
|
2
2
|
<h2><%= step_alias.titleize %>: <%= @wizard_step.humanize %></h2>
|
3
3
|
<%%= form_for <%= file_path %>_<%= step_alias %>_model, :url => current_<%= step_alias %>_path, :as => :<%= file_path %> do |f| %>
|
4
|
-
<%%#
|
4
|
+
<%%# TODO limit to fields of this particular step %>
|
5
|
+
<%= form_content(true) %>
|
5
6
|
<%%= render '<%= step_alias %>_navigation', f: f %>
|
6
7
|
<%% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module UltraLightWizard
|
2
2
|
module Generators
|
3
|
-
class
|
3
|
+
class ScaffoldGenerator < Rails::Generators::NamedBase
|
4
4
|
source_root File.expand_path("../../templates", __FILE__)
|
5
5
|
def arguments
|
6
6
|
args.inject({}) do |output, arg|
|
@@ -43,7 +43,7 @@ module UltraLightWizard
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def scaffold_attributes
|
46
|
-
model_attributes.
|
46
|
+
model_attributes.gsub(',', ' ')
|
47
47
|
end
|
48
48
|
|
49
49
|
def controller_attribute_names
|
@@ -58,9 +58,28 @@ module UltraLightWizard
|
|
58
58
|
file_path.pluralize
|
59
59
|
end
|
60
60
|
|
61
|
+
def arg_options
|
62
|
+
options.select {|key, value| value}.map {|key, value| "--#{key}"}.join(' ')
|
63
|
+
end
|
64
|
+
|
65
|
+
def form_content(execute=false)
|
66
|
+
if execute #prevents thor from executing too early
|
67
|
+
@form_content ||= lambda {
|
68
|
+
# TODO support formats other than html.erb like html.haml (autodetect)
|
69
|
+
scaffold_form_lines = File.new(Rails.root.join('app', 'views', plural_table_name, '_form.html.erb')).readlines
|
70
|
+
form_start_index = scaffold_form_lines.find_index {|line| line.include?('form')}
|
71
|
+
form_end_index = scaffold_form_lines.length - 1 - scaffold_form_lines.reverse.find_index {|line| line.include?('actions')}
|
72
|
+
form_content_start_index = form_start_index + 1
|
73
|
+
form_content_end_index = form_end_index - 1
|
74
|
+
extracted_form_lines = scaffold_form_lines[form_content_start_index..form_content_end_index]
|
75
|
+
extracted_form_lines.join
|
76
|
+
}.()
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
61
80
|
desc "Creates a configuration file for a specific application context (e.g. admin). Takes context path as argument (e.g. admin or internal/wiki) to create config/features/[context_path].yml"
|
62
81
|
def copy_config
|
63
|
-
generate "scaffold", "#{file_path} #{scaffold_attributes}"
|
82
|
+
generate "scaffold", "#{file_path} #{scaffold_attributes} #{arg_options}"
|
64
83
|
template "app/controllers/model_controller.rb.erb", "app/controllers/#{file_path.pluralize}_controller.rb"
|
65
84
|
template "app/controllers/wizard_steps_controller.rb.erb", "app/controllers/#{file_path}_#{step_alias.pluralize}_controller.rb"
|
66
85
|
template "app/helpers/wizard_steps_helper.rb.erb", "app/helpers/#{file_path}_#{step_alias.pluralize}_helper.rb"
|
data/lib/ultra_light_wizard.rb
CHANGED
File without changes
|
data/ruby187.Gemfile
CHANGED
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
File without changes
|
data/ultra_light_wizard.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ultra_light_wizard 0.0
|
5
|
+
# stub: ultra_light_wizard 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ultra_light_wizard"
|
9
|
-
s.version = "0.0
|
9
|
+
s.version = "0.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Andy Maleh"]
|
14
|
-
s.date = "2016-02-
|
14
|
+
s.date = "2016-02-14"
|
15
15
|
s.description = "Ultra light & maintainble wizards in Rails that honor REST, MVC, and OO with minimal writing of code involved and maximum flexibility"
|
16
16
|
s.email = "andy.am@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/generators/templates/app/models/wizard_step_model.rb.erb",
|
34
34
|
"lib/generators/templates/app/views/wizard_step_navigation_view.html.erb",
|
35
35
|
"lib/generators/templates/app/views/wizard_step_view.html.erb",
|
36
|
-
"lib/generators/ultra_light_wizard/
|
36
|
+
"lib/generators/ultra_light_wizard/scaffold_generator.rb",
|
37
37
|
"lib/ultra_light_wizard.rb",
|
38
38
|
"ruby187.Gemfile",
|
39
39
|
"spec/spec_helper.rb",
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
]
|
44
44
|
s.homepage = "http://github.com/AndyObtiva/ultra_light_wizard"
|
45
45
|
s.licenses = ["MIT"]
|
46
|
-
s.rubygems_version = "2.4.
|
46
|
+
s.rubygems_version = "2.4.5.1"
|
47
47
|
s.summary = "Ultra Light & Maintainable Wizards In Rails"
|
48
48
|
|
49
49
|
if s.respond_to? :specification_version then
|
data/ultra_light_wizard.jpg
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultra_light_wizard
|
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
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.8.8
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.8.8
|
27
27
|
description: Ultra light & maintainble wizards in Rails that honor REST, MVC, and
|
@@ -33,8 +33,8 @@ extra_rdoc_files:
|
|
33
33
|
- LICENSE.txt
|
34
34
|
- README.md
|
35
35
|
files:
|
36
|
-
- .ruby-gemset
|
37
|
-
- .ruby-version
|
36
|
+
- ".ruby-gemset"
|
37
|
+
- ".ruby-version"
|
38
38
|
- Gemfile
|
39
39
|
- Gemfile.lock
|
40
40
|
- LICENSE.txt
|
@@ -47,7 +47,7 @@ files:
|
|
47
47
|
- lib/generators/templates/app/models/wizard_step_model.rb.erb
|
48
48
|
- lib/generators/templates/app/views/wizard_step_navigation_view.html.erb
|
49
49
|
- lib/generators/templates/app/views/wizard_step_view.html.erb
|
50
|
-
- lib/generators/ultra_light_wizard/
|
50
|
+
- lib/generators/ultra_light_wizard/scaffold_generator.rb
|
51
51
|
- lib/ultra_light_wizard.rb
|
52
52
|
- ruby187.Gemfile
|
53
53
|
- spec/spec_helper.rb
|
@@ -64,17 +64,17 @@ require_paths:
|
|
64
64
|
- lib
|
65
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.4.
|
77
|
+
rubygems_version: 2.4.5.1
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Ultra Light & Maintainable Wizards In Rails
|