wicked 0.3.0 → 0.3.1
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 +3 -1
- data/VERSION +1 -1
- data/lib/wicked/controller/concerns/steps.rb +24 -9
- data/lib/wicked/wizard.rb +13 -4
- data/lib/wicked/wizard/translated.rb +6 -13
- data/wicked.gemspec +3 -3
- metadata +91 -140
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/schneems/wicked.png)](http://travis-ci.org/schneems/wicked)
|
4
4
|
|
5
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/schneems/wicked)
|
6
|
+
|
5
7
|
Use wicked to make your Rails controllers into step-by-step wizards. To see Wicked in action check out the example [Rails app](https://github.com/schneems/wicked_example) or [watch the screencast](http://schneems.com/post/18437886598/wizard-ify-your-rails-controllers-with-wicked).
|
6
8
|
|
7
9
|
## Why
|
@@ -241,7 +243,7 @@ This will allow you to specify translation keys instead of literal step names. L
|
|
241
243
|
|
242
244
|
steps :first, :second
|
243
245
|
|
244
|
-
So the urls would be `/after_signup/first` and `/after_signup/second`. But you want them to show up
|
246
|
+
So the urls would be `/after_signup/first` and `/after_signup/second`. But you want them to show up differently for different locales. For example someone coming form a Spanish speaking locale should see `/after_signup/uno` and `after_signup/dos`.
|
245
247
|
|
246
248
|
To internationalize first you need to create your locales files under `config/locales` such as `config/locales/es.yml` for Spanish. You then need to add a `first` and `second` key under a `wicked` key like this:
|
247
249
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -15,32 +15,32 @@ module Wicked::Controller::Concerns::Steps
|
|
15
15
|
|
16
16
|
# will return true if step passed in is the currently rendered step
|
17
17
|
def current_step?(step_name)
|
18
|
-
return false
|
18
|
+
return false unless current_and_given_step_exists?(step_name)
|
19
19
|
step == step_name
|
20
20
|
end
|
21
21
|
|
22
22
|
# will return true if the step passed in has already been executed by the wizard
|
23
23
|
def past_step?(step_name)
|
24
|
-
return false
|
25
|
-
|
24
|
+
return false unless current_and_given_step_exists?(step_name)
|
25
|
+
current_step_index > step_index_for(step_name)
|
26
26
|
end
|
27
27
|
|
28
28
|
# will return true if the step passed in has already been executed by the wizard
|
29
29
|
def future_step?(step_name)
|
30
|
-
return false
|
31
|
-
|
30
|
+
return false unless current_and_given_step_exists?(step_name)
|
31
|
+
current_step_index < step_index_for(step_name)
|
32
32
|
end
|
33
33
|
|
34
34
|
# will return true if the last step is the step passed in
|
35
35
|
def previous_step?(step_name)
|
36
|
-
return false
|
37
|
-
|
36
|
+
return false unless current_and_given_step_exists?(step_name)
|
37
|
+
(current_step_index - 1) == step_index_for(step_name)
|
38
38
|
end
|
39
39
|
|
40
40
|
# will return true if the next step is the step passed in
|
41
41
|
def next_step?(step_name)
|
42
|
-
return false
|
43
|
-
|
42
|
+
return false unless current_and_given_step_exists?(step_name)
|
43
|
+
(current_step_index + 1) == step_index_for(step_name)
|
44
44
|
end
|
45
45
|
|
46
46
|
module ClassMethods
|
@@ -80,5 +80,20 @@ module Wicked::Controller::Concerns::Steps
|
|
80
80
|
step
|
81
81
|
end
|
82
82
|
|
83
|
+
private
|
84
|
+
|
85
|
+
def step_index_for(step_name)
|
86
|
+
steps.index(step_name)
|
87
|
+
end
|
88
|
+
|
89
|
+
def current_step_index
|
90
|
+
step_index_for(step)
|
91
|
+
end
|
92
|
+
|
93
|
+
def current_and_given_step_exists?(step_name)
|
94
|
+
return false if current_step_index.nil? || steps.index(step_name).nil?
|
95
|
+
return true
|
96
|
+
end
|
97
|
+
|
83
98
|
|
84
99
|
end
|
data/lib/wicked/wizard.rb
CHANGED
@@ -22,11 +22,20 @@ module Wicked
|
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
|
-
def setup_wizard
|
26
|
-
redirect_to wizard_path(steps.first) if params[:id].try(:to_sym) == :wizard_first
|
27
|
-
redirect_to wizard_path(steps.last) if params[:id].try(:to_sym) == :wizard_last
|
28
25
|
|
29
|
-
|
26
|
+
def check_redirect_to_first_last!(step)
|
27
|
+
redirect_to wizard_path(steps.first) if step == :wizard_first
|
28
|
+
redirect_to wizard_path(steps.last) if step == :wizard_last
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup_step_from(the_step)
|
32
|
+
the_step = the_step.try(:to_sym) || steps.first
|
33
|
+
check_redirect_to_first_last!(the_step)
|
34
|
+
return the_step
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_wizard
|
38
|
+
@step = setup_step_from(params[:id])
|
30
39
|
@previous_step = previous_step(@step)
|
31
40
|
@next_step = next_step(@step)
|
32
41
|
end
|
@@ -6,8 +6,7 @@ module Wicked
|
|
6
6
|
included do
|
7
7
|
include Wicked::Wizard
|
8
8
|
skip_before_filter :setup_wizard
|
9
|
-
|
10
|
-
before_filter :setup_wizard_translated
|
9
|
+
before_filter :setup_wizard_translated
|
11
10
|
end
|
12
11
|
|
13
12
|
# creates a hash where keys are translated steps, values are the name of the view file
|
@@ -41,18 +40,12 @@ module Wicked
|
|
41
40
|
#
|
42
41
|
# steps "wicked.first", "wicked.second"
|
43
42
|
#
|
44
|
-
|
45
43
|
def setup_wizard_translated
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@previous_step = previous_step(original_step)
|
54
|
-
@next_step = next_step(original_step)
|
55
|
-
@step = wizard_translations[params[:id]]
|
44
|
+
step_name = setup_step_from(params[:id])
|
45
|
+
self.steps = wizard_translations.keys # must come before setting previous/next steps
|
46
|
+
@previous_step = previous_step(step_name)
|
47
|
+
@next_step = next_step(step_name)
|
48
|
+
@step = wizard_translations[step_name] # translates step name to url
|
56
49
|
end
|
57
50
|
public
|
58
51
|
end
|
data/wicked.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wicked"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["schneems"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-11-12"
|
13
13
|
s.description = "Wicked is a Rails engine for producing easy wizard controllers"
|
14
14
|
s.email = "richard.schneeman@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -100,7 +100,7 @@ Gem::Specification.new do |s|
|
|
100
100
|
s.homepage = "http://github.com/schneems/wicked"
|
101
101
|
s.licenses = ["MIT"]
|
102
102
|
s.require_paths = ["lib"]
|
103
|
-
s.rubygems_version = "1.8.
|
103
|
+
s.rubygems_version = "1.8.10"
|
104
104
|
s.summary = "Use Wicked to turn your controller into a wizard"
|
105
105
|
|
106
106
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,165 +1,122 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- schneems
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-11-12 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &70119200321980 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 9
|
28
|
-
segments:
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
- 7
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 3.0.7
|
33
22
|
type: :runtime
|
34
|
-
name: activesupport
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *70119200321980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70119200321480 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 9
|
44
|
-
segments:
|
45
|
-
- 3
|
46
|
-
- 0
|
47
|
-
- 7
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
48
32
|
version: 3.0.7
|
49
33
|
type: :runtime
|
50
|
-
name: rails
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
34
|
prerelease: false
|
54
|
-
|
35
|
+
version_requirements: *70119200321480
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70119200320960 !ruby/object:Gem::Requirement
|
55
39
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
63
44
|
type: :development
|
64
|
-
name: rake
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
45
|
prerelease: false
|
68
|
-
|
46
|
+
version_requirements: *70119200320960
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jeweler
|
49
|
+
requirement: &70119200320460 !ruby/object:Gem::Requirement
|
69
50
|
none: false
|
70
|
-
requirements:
|
51
|
+
requirements:
|
71
52
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
hash: 7
|
74
|
-
segments:
|
75
|
-
- 1
|
76
|
-
- 6
|
77
|
-
- 4
|
53
|
+
- !ruby/object:Gem::Version
|
78
54
|
version: 1.6.4
|
79
55
|
type: :development
|
80
|
-
name: jeweler
|
81
|
-
version_requirements: *id004
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
56
|
prerelease: false
|
84
|
-
|
57
|
+
version_requirements: *70119200320460
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rcov
|
60
|
+
requirement: &70119200319960 !ruby/object:Gem::Requirement
|
85
61
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
93
66
|
type: :development
|
94
|
-
name: rcov
|
95
|
-
version_requirements: *id005
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
67
|
prerelease: false
|
98
|
-
|
68
|
+
version_requirements: *70119200319960
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: &70119200319440 !ruby/object:Gem::Requirement
|
99
72
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
hash: 15
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
- 4
|
107
|
-
- 0
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
108
76
|
version: 0.4.0
|
109
77
|
type: :development
|
110
|
-
name: capybara
|
111
|
-
version_requirements: *id006
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
78
|
prerelease: false
|
114
|
-
|
79
|
+
version_requirements: *70119200319440
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: launchy
|
82
|
+
requirement: &70119200318900 !ruby/object:Gem::Requirement
|
115
83
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
version: "0"
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
123
88
|
type: :development
|
124
|
-
name: launchy
|
125
|
-
version_requirements: *id007
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
89
|
prerelease: false
|
128
|
-
|
90
|
+
version_requirements: *70119200318900
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: sqlite3
|
93
|
+
requirement: &70119200318400 !ruby/object:Gem::Requirement
|
129
94
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
134
|
-
segments:
|
135
|
-
- 0
|
136
|
-
version: "0"
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
137
99
|
type: :development
|
138
|
-
name: sqlite3
|
139
|
-
version_requirements: *id008
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
100
|
prerelease: false
|
142
|
-
|
101
|
+
version_requirements: *70119200318400
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: activerecord-jdbcsqlite3-adapter
|
104
|
+
requirement: &70119200317880 !ruby/object:Gem::Requirement
|
143
105
|
none: false
|
144
|
-
requirements:
|
145
|
-
- -
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
|
148
|
-
segments:
|
149
|
-
- 0
|
150
|
-
version: "0"
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
151
110
|
type: :development
|
152
|
-
|
153
|
-
version_requirements: *
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70119200317880
|
154
113
|
description: Wicked is a Rails engine for producing easy wizard controllers
|
155
114
|
email: richard.schneeman@gmail.com
|
156
115
|
executables: []
|
157
|
-
|
158
116
|
extensions: []
|
159
|
-
|
160
|
-
extra_rdoc_files:
|
117
|
+
extra_rdoc_files:
|
161
118
|
- README.md
|
162
|
-
files:
|
119
|
+
files:
|
163
120
|
- .rvmrc
|
164
121
|
- .travis.yml
|
165
122
|
- CHANGELOG.md
|
@@ -241,37 +198,31 @@ files:
|
|
241
198
|
- test/wicked_test.rb
|
242
199
|
- wicked.gemspec
|
243
200
|
homepage: http://github.com/schneems/wicked
|
244
|
-
licenses:
|
201
|
+
licenses:
|
245
202
|
- MIT
|
246
203
|
post_install_message:
|
247
204
|
rdoc_options: []
|
248
|
-
|
249
|
-
require_paths:
|
205
|
+
require_paths:
|
250
206
|
- lib
|
251
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
252
208
|
none: false
|
253
|
-
requirements:
|
254
|
-
- -
|
255
|
-
- !ruby/object:Gem::Version
|
256
|
-
|
257
|
-
segments:
|
209
|
+
requirements:
|
210
|
+
- - ! '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
segments:
|
258
214
|
- 0
|
259
|
-
|
260
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
hash: 3821284544051991557
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
217
|
none: false
|
262
|
-
requirements:
|
263
|
-
- -
|
264
|
-
- !ruby/object:Gem::Version
|
265
|
-
|
266
|
-
segments:
|
267
|
-
- 0
|
268
|
-
version: "0"
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
269
222
|
requirements: []
|
270
|
-
|
271
223
|
rubyforge_project:
|
272
|
-
rubygems_version: 1.8.
|
224
|
+
rubygems_version: 1.8.10
|
273
225
|
signing_key:
|
274
226
|
specification_version: 3
|
275
227
|
summary: Use Wicked to turn your controller into a wizard
|
276
228
|
test_files: []
|
277
|
-
|