ultra_light_wizard 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a7686e94397788f96a568274332a0a96f191ff4
4
- data.tar.gz: 228bd3ecb05c119f4c3201d8ef09bd754f022111
3
+ metadata.gz: 80b4dd5230aa70e805ce0b3f516dc4e882ea0d38
4
+ data.tar.gz: f9db7ab36afbb0fe06db8ad9937a7b04f250bac8
5
5
  SHA512:
6
- metadata.gz: a9eddccc6aec24c7d9fe45515d55ee5cdeecf1914652af1d20c0f946969f763ad49befbc2b569a7bb154523cf639c776cb3dedc02cebea6d4a270a6098a4081b
7
- data.tar.gz: d8b8f082d200b22724ab090b5d1e39b07173b811dfe032da2c567d2f0ccb304f501335c2cb27aae9a9a5b5043d2f49854215835ba05b3a5c5b4486e95277a029
6
+ metadata.gz: f366407e1b4216e618f9c4668eb6fd76a7d4a7c164ed039f152d4bdb4543cb01038a888d4a920206186a8beebb9488ace94af395bd454b367eab90e15cbf1e11
7
+ data.tar.gz: 396ad497eabb8ba6ad460295c20ce903a03e6e287fdd9cb8c7003b5b14788c5175780b8a3f9d692c7256ac5ec500e4592828821774508abd7f7779b00e20ffba
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'jeweler'
4
+ gem 'jeweler', '~> 1.8.8'
5
5
  end
6
6
 
7
7
  group :test do
data/Gemfile.lock CHANGED
@@ -77,5 +77,8 @@ PLATFORMS
77
77
 
78
78
  DEPENDENCIES
79
79
  coveralls
80
- jeweler
80
+ jeweler (~> 1.8.8)
81
81
  rspec
82
+
83
+ BUNDLED WITH
84
+ 1.11.2
data/README.md CHANGED
@@ -61,6 +61,12 @@ end
61
61
 
62
62
  Once the files are generated, you can proceed to place your own code customizations in the wizard step models and views.
63
63
 
64
+ To kick-off wizard, simply trigger the main model controller create action, and it will transition to the wizard step first step edit action.
65
+
66
+ For example, the following will kick-off the project wizard by creating a project and automatically redirecting to first step:
67
+
68
+ ```<%= link_to 'New Project', projects_path, method: :post %>```
69
+
64
70
  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)
65
71
 
66
72
  Principles
@@ -88,7 +94,9 @@ Features
88
94
  + [DONE] View navigation
89
95
  + [DONE] Helper (or Controller SuperModule trait) for ultra light wizard support
90
96
  + [DONE] Route helper methods
97
+ + [DONE] Wizard kick-off helper/view
91
98
  - Forms
99
+ - Scaffolding of main model controller/views/migration
92
100
  - Support for nested resources
93
101
  - Modularize (perhaps extracting sub-generators)
94
102
  + [DONE] Customize name conventions
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -0,0 +1,37 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_file_path %>/application_controller"
3
+
4
+ <% end -%>
5
+ <% module_namespacing do -%>
6
+ class <%= controller_class_name %>Controller < ApplicationController
7
+ before_action :set_<%= singular_table_name %>, only: [:show, :destroy]
8
+
9
+ # GET <%= route_url %>
10
+ def index
11
+ @<%= plural_table_name %> = <%= orm_class %>.all
12
+ end
13
+
14
+ # GET <%= route_url %>/1
15
+ def show
16
+ end
17
+
18
+ # POST <%= route_url %>
19
+ def create
20
+ @<%= singular_table_name %> = <%= orm_class %>.new
21
+ @<%= singular_table_name %>.save(validation: false)
22
+ redirect_to edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(@<%= singular_table_name %>, <%= orm_class %><%= step_alias.camelize.titleize.pluralize %>Helper::<%= step_alias.pluralize.upcase %>.first)
23
+ end
24
+
25
+ # DELETE <%= route_url %>/1
26
+ def destroy
27
+ @<%= singular_table_name %>.destroy
28
+ redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
29
+ end
30
+
31
+ private
32
+ # Use callbacks to share common setup or constraints between actions.
33
+ def set_<%= singular_table_name %>
34
+ @<%= singular_table_name %> = <%= orm_class %>.find(params[:id])
35
+ end
36
+ end
37
+ <% end -%>
@@ -10,25 +10,34 @@ module <%= class_name %><%= step_alias.pluralize.camelize %>Helper
10
10
  <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase}
11
11
  end
12
12
 
13
- def next_<%= step_alias %>
14
- current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
15
- <%= step_alias.pluralize.upcase %>[current_<%= step_alias %>_index+1]
16
- end
17
-
18
13
  def previous_<%= step_alias %>
19
14
  current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
20
15
  previous_<%= step_alias %>_index = current_<%= step_alias %>_index-1
21
16
  previous_<%= step_alias %>_index < 0 ? nil : <%= step_alias.pluralize.upcase %>[previous_<%= step_alias %>_index]
22
17
  end
18
+
19
+ def next_<%= step_alias %>
20
+ current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
21
+ <%= step_alias.pluralize.upcase %>[current_<%= step_alias %>_index+1]
22
+ end
23
+
23
24
  <% %w(path url).each do |route_term| %>
24
- def next_<%= step_alias %>_<%= route_term %>
25
- <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(next_<%= step_alias %>)
25
+ def first_<%= step_alias %>_<%= route_term %>
26
+ <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.first)
26
27
  end
27
28
 
28
29
  def previous_<%= step_alias %>_<%= route_term %>
29
30
  <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(previous_<%= step_alias %>)
30
31
  end
31
32
 
33
+ def next_<%= step_alias %>_<%= route_term %>
34
+ <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(next_<%= step_alias %>)
35
+ end
36
+
37
+ def last_<%= step_alias %>_<%= route_term %>
38
+ <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.last)
39
+ end
40
+
32
41
  def <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias %>)
33
42
  edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_<%= route_term %>(<%= file_path %>_<%= step_alias %>_model, <%= step_alias %>)
34
43
  end
@@ -17,8 +17,29 @@ module UltraLightWizard
17
17
  arguments['steps'].to_s.split(',').map(&:strip)
18
18
  end
19
19
 
20
+ def controller_class_name
21
+ file_path.pluralize.titleize
22
+ end
23
+
24
+ def orm_class
25
+ file_path.camelize.titleize
26
+ end
27
+
28
+ def index_helper
29
+ file_path.pluralize
30
+ end
31
+
32
+ def human_name
33
+ file_path.humanize
34
+ end
35
+
36
+ def plural_table_name
37
+ file_path.pluralize
38
+ end
39
+
20
40
  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"
21
41
  def copy_config
42
+ template "app/controllers/model_controller.rb.erb", "app/controllers/#{file_path.pluralize}_controller.rb"
22
43
  template "app/controllers/wizard_steps_controller.rb.erb", "app/controllers/#{file_path}_#{step_alias.pluralize}_controller.rb"
23
44
  template "app/helpers/wizard_steps_helper.rb.erb", "app/helpers/#{file_path}_#{step_alias.pluralize}_helper.rb"
24
45
  template "app/views/wizard_step_navigation_view.html.erb", "app/views/#{file_path}_#{step_alias.pluralize}/_#{step_alias}_navigation.html.erb"
@@ -2,11 +2,11 @@
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.3 ruby lib
5
+ # stub: ultra_light_wizard 0.0.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "ultra_light_wizard"
9
- s.version = "0.0.3"
9
+ s.version = "0.0.4"
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"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "README.md",
28
28
  "Rakefile",
29
29
  "VERSION",
30
+ "lib/generators/templates/app/controllers/model_controller.rb.erb",
30
31
  "lib/generators/templates/app/controllers/wizard_steps_controller.rb.erb",
31
32
  "lib/generators/templates/app/helpers/wizard_steps_helper.rb.erb",
32
33
  "lib/generators/templates/app/models/wizard_step_model.rb.erb",
@@ -49,12 +50,12 @@ Gem::Specification.new do |s|
49
50
  s.specification_version = 4
50
51
 
51
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_development_dependency(%q<jeweler>, [">= 0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.8"])
53
54
  else
54
- s.add_dependency(%q<jeweler>, [">= 0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
55
56
  end
56
57
  else
57
- s.add_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
58
59
  end
59
60
  end
60
61
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra_light_wizard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: jeweler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
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
- version: '0'
26
+ version: 1.8.8
27
27
  description: Ultra light & maintainble wizards in Rails that honor REST, MVC, and
28
28
  OO with minimal writing of code involved and maximum flexibility
29
29
  email: andy.am@gmail.com
@@ -41,6 +41,7 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - VERSION
44
+ - lib/generators/templates/app/controllers/model_controller.rb.erb
44
45
  - lib/generators/templates/app/controllers/wizard_steps_controller.rb.erb
45
46
  - lib/generators/templates/app/helpers/wizard_steps_helper.rb.erb
46
47
  - lib/generators/templates/app/models/wizard_step_model.rb.erb