wicked 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of wicked might be problematic. Click here for more details.
- data/CHANGELOG.md +3 -0
- data/README.md +21 -0
- data/VERSION +1 -1
- data/lib/wicked/controller/concerns/steps.rb +2 -3
- data/lib/wicked/wizard/translated.rb +1 -0
- data/lib/wicked/wizard.rb +7 -1
- data/test/dummy/app/controllers/dynamic_steps_controller.rb +16 -0
- data/test/dummy/app/views/dynamic_steps/first.html.erb +3 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/integration/dynamic_steps_test.rb +10 -0
- data/wicked.gemspec +4 -1
- metadata +23 -20
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -292,6 +292,27 @@ Now you can change the values in the URL's to whatever you want without changing
|
|
292
292
|
|
293
293
|
Custom crafted wizard urls: just another way Wicked makes your app a little more saintly.
|
294
294
|
|
295
|
+
## Dynamic Step Names
|
296
|
+
|
297
|
+
If you wish to set the order of your steps dynamically you can do this with a `prepend_before_filter` and `self.steps =` like this:
|
298
|
+
|
299
|
+
```
|
300
|
+
include Wicked::Wizard
|
301
|
+
prepend_before_filter :set_steps
|
302
|
+
|
303
|
+
# ...
|
304
|
+
|
305
|
+
private
|
306
|
+
def set_steps
|
307
|
+
if params[:flow] == "twitter"
|
308
|
+
self.steps = [:ask_twitter, :ask_email]
|
309
|
+
elsif params[:flow] == "facebook"
|
310
|
+
self.steps = [:ask_facebook, :ask_email]
|
311
|
+
end
|
312
|
+
end
|
313
|
+
```
|
314
|
+
|
315
|
+
|
295
316
|
## About
|
296
317
|
|
297
318
|
Please poke around the source code, if you see easier ways to get a Rails controller do do what I want, let me know.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -64,7 +64,7 @@ module Wicked::Controller::Concerns::Steps
|
|
64
64
|
alias :steps_list :steps
|
65
65
|
|
66
66
|
def previous_step(current_step = nil)
|
67
|
-
return @previous_step if current_step
|
67
|
+
return @previous_step if current_step.nil?
|
68
68
|
index = steps.index(current_step)
|
69
69
|
step = steps.at(index - 1) if index.present? && index != 0
|
70
70
|
step ||= steps.first
|
@@ -73,8 +73,7 @@ module Wicked::Controller::Concerns::Steps
|
|
73
73
|
|
74
74
|
|
75
75
|
def next_step(current_step = nil)
|
76
|
-
return @next_step if current_step
|
77
|
-
raise "Wicked Wizard steps not set, but expected" if steps.blank?
|
76
|
+
return @next_step if current_step.nil?
|
78
77
|
index = steps.index(current_step)
|
79
78
|
step = steps.at(index + 1) if index.present?
|
80
79
|
step ||= :finish
|
@@ -42,6 +42,7 @@ module Wicked
|
|
42
42
|
#
|
43
43
|
def setup_wizard_translated
|
44
44
|
step_name = setup_step_from(params[:id])
|
45
|
+
check_steps!(step_name)
|
45
46
|
self.steps = wizard_translations.keys # must come before setting previous/next steps
|
46
47
|
@previous_step = previous_step(step_name)
|
47
48
|
@next_step = next_step(step_name)
|
data/lib/wicked/wizard.rb
CHANGED
@@ -34,13 +34,19 @@ module Wicked
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def setup_step_from(the_step)
|
37
|
-
the_step = the_step.try(:to_sym) || steps.first
|
37
|
+
the_step = the_step.try(:to_sym) || steps.try(:first)
|
38
38
|
check_redirect_to_first_last!(the_step)
|
39
39
|
return the_step
|
40
40
|
end
|
41
41
|
|
42
|
+
def check_steps!(the_step)
|
43
|
+
return false if step.nil?
|
44
|
+
raise "Wicked Wizard steps expected but not yet set, if setting via `before_filter` use `prepend_before_filter`" if steps.nil?
|
45
|
+
end
|
46
|
+
|
42
47
|
def setup_wizard
|
43
48
|
@step = setup_step_from(params[:id])
|
49
|
+
check_steps!(@step)
|
44
50
|
@previous_step = previous_step(@step)
|
45
51
|
@next_step = next_step(@step)
|
46
52
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class DynamicStepsController < ApplicationController
|
2
|
+
include Wicked::Wizard
|
3
|
+
prepend_before_filter :set_steps
|
4
|
+
|
5
|
+
def show
|
6
|
+
render_wizard
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
private
|
11
|
+
def set_steps
|
12
|
+
self.steps = if params[:steps]
|
13
|
+
params[:steps].map(&:to_sym)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/dummy/config/routes.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DynamicStepsTest < ActiveSupport::IntegrationCase
|
4
|
+
test 'set dynamic steps from params' do
|
5
|
+
steps = [:first, :second]
|
6
|
+
visit dynamic_steps_path(:steps => steps)
|
7
|
+
assert has_content?(steps.first.inspect)
|
8
|
+
assert has_content?(steps.inspect)
|
9
|
+
end
|
10
|
+
end
|
data/wicked.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wicked"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["schneems"]
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"test/dummy/Rakefile",
|
37
37
|
"test/dummy/app/controllers/application_controller.rb",
|
38
38
|
"test/dummy/app/controllers/bar_controller.rb",
|
39
|
+
"test/dummy/app/controllers/dynamic_steps_controller.rb",
|
39
40
|
"test/dummy/app/controllers/i18n_controller.rb",
|
40
41
|
"test/dummy/app/controllers/jump_controller.rb",
|
41
42
|
"test/dummy/app/controllers/nested/builder_controller.rb",
|
@@ -46,6 +47,7 @@ Gem::Specification.new do |s|
|
|
46
47
|
"test/dummy/app/views/bar/first.html.erb",
|
47
48
|
"test/dummy/app/views/bar/last_step.html.erb",
|
48
49
|
"test/dummy/app/views/bar/second.html.erb",
|
50
|
+
"test/dummy/app/views/dynamic_steps/first.html.erb",
|
49
51
|
"test/dummy/app/views/i18n/first.html.erb",
|
50
52
|
"test/dummy/app/views/i18n/second.html.erb",
|
51
53
|
"test/dummy/app/views/jump/first.html.erb",
|
@@ -88,6 +90,7 @@ Gem::Specification.new do |s|
|
|
88
90
|
"test/dummy/public/javascripts/rails.js",
|
89
91
|
"test/dummy/public/stylesheets/.gitkeep",
|
90
92
|
"test/dummy/script/rails",
|
93
|
+
"test/integration/dynamic_steps_test.rb",
|
91
94
|
"test/integration/helpers_test.rb",
|
92
95
|
"test/integration/i18n_test.rb",
|
93
96
|
"test/integration/jump_test.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-12-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70241592223140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70241592223140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70241592222660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70241592222660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70241592222140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70241592222140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70241592221620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70241592221620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70241592221140 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70241592221140
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: capybara
|
71
|
-
requirement: &
|
71
|
+
requirement: &70241592220640 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.4.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70241592220640
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: launchy
|
82
|
-
requirement: &
|
82
|
+
requirement: &70241592220080 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70241592220080
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: sqlite3
|
93
|
-
requirement: &
|
93
|
+
requirement: &70241592219520 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70241592219520
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: activerecord-jdbcsqlite3-adapter
|
104
|
-
requirement: &
|
104
|
+
requirement: &70241592218960 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70241592218960
|
113
113
|
description: Wicked is a Rails engine for producing easy wizard controllers
|
114
114
|
email: richard.schneeman@gmail.com
|
115
115
|
executables: []
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- test/dummy/Rakefile
|
138
138
|
- test/dummy/app/controllers/application_controller.rb
|
139
139
|
- test/dummy/app/controllers/bar_controller.rb
|
140
|
+
- test/dummy/app/controllers/dynamic_steps_controller.rb
|
140
141
|
- test/dummy/app/controllers/i18n_controller.rb
|
141
142
|
- test/dummy/app/controllers/jump_controller.rb
|
142
143
|
- test/dummy/app/controllers/nested/builder_controller.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- test/dummy/app/views/bar/first.html.erb
|
148
149
|
- test/dummy/app/views/bar/last_step.html.erb
|
149
150
|
- test/dummy/app/views/bar/second.html.erb
|
151
|
+
- test/dummy/app/views/dynamic_steps/first.html.erb
|
150
152
|
- test/dummy/app/views/i18n/first.html.erb
|
151
153
|
- test/dummy/app/views/i18n/second.html.erb
|
152
154
|
- test/dummy/app/views/jump/first.html.erb
|
@@ -189,6 +191,7 @@ files:
|
|
189
191
|
- test/dummy/public/javascripts/rails.js
|
190
192
|
- test/dummy/public/stylesheets/.gitkeep
|
191
193
|
- test/dummy/script/rails
|
194
|
+
- test/integration/dynamic_steps_test.rb
|
192
195
|
- test/integration/helpers_test.rb
|
193
196
|
- test/integration/i18n_test.rb
|
194
197
|
- test/integration/jump_test.rb
|
@@ -214,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
217
|
version: '0'
|
215
218
|
segments:
|
216
219
|
- 0
|
217
|
-
hash:
|
220
|
+
hash: 3202762565792531616
|
218
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
222
|
none: false
|
220
223
|
requirements:
|