wizardz 1.3.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +14 -15
- data/VERSION +1 -1
- data/lib/wizardz/wizard.rb +5 -1
- data/spec/wizardz/wizard_spec.rb +18 -0
- data/wizardz.gemspec +2 -2
- metadata +6 -6
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= Wizardz
|
2
2
|
|
3
3
|
Multi-Step Creation Wizard
|
4
4
|
|
@@ -7,30 +7,29 @@ models and user-selectable steps ordering based on user input within earlier ste
|
|
7
7
|
|
8
8
|
The Gem is provides a Wizardz::Wizard class which is exposed to the Controller and
|
9
9
|
manages the various steps within the creation process and a Wizardz::Page class
|
10
|
-
with represents the
|
10
|
+
with represents the individual pages within the Wizardz. Both class are designed
|
11
11
|
to be inherited from within the final implementation and expose the following methods:
|
12
12
|
|
13
13
|
Wizardz::Wizard
|
14
14
|
---------------
|
15
15
|
STATES => Constant which contains the HASH of Page Identifier and Page Class pairs
|
16
16
|
def create => Combines the data for the Associated Pages and create the required Objects
|
17
|
+
<page_name> => Ability to Access page objects via method call
|
17
18
|
|
18
19
|
Wizardz::Page
|
19
20
|
---------------
|
20
|
-
IDENTIFER => Identifier lookup which should match to the Page
|
21
|
-
|
22
|
-
|
23
|
-
the view for the page
|
24
|
-
def initialize(data) => Load the required Attributes onto the Page Class
|
25
|
-
(set any default values here)
|
21
|
+
IDENTIFER => Identifier lookup which should match to the Page Identifier from The Wizardz::Wizard:STATES Constant
|
22
|
+
PARTIAL => Contant name of the Partial to be displayed within the view for the page
|
23
|
+
def initialize(data) => Load the required Attributes onto the Page Class (set any default values here)
|
26
24
|
def get_valid_states(states) => Update the list page transistion order after page data update
|
27
|
-
def get_object => Return instance of the underlying object (in memory
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
def get_object => Return instance of the underlying object (in memory only - do not save to table) (only required if page_object and valid NOT overwritten
|
26
|
+
def page_object => return object instance (with valid? call if page has already been visited)
|
27
|
+
def valid? => return true/false if object is valid (default implementation calls valid? on get_object)
|
28
|
+
|
29
|
+
- To Do
|
30
|
+
|
31
|
+
* Add example Implementation to show functionality in practise
|
32
|
+
* Add Controller Methods => Use multiple calls to the Create method (change pages instead of creating object)
|
34
33
|
|
35
34
|
== Note on Patches/Pull Requests
|
36
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/wizardz/wizard.rb
CHANGED
@@ -20,6 +20,11 @@ module Wizardz
|
|
20
20
|
@state = state
|
21
21
|
end
|
22
22
|
|
23
|
+
def method_missing(m, *args, &block)
|
24
|
+
return @pages[m.to_s] if self.states.include?(m.to_sym)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
23
28
|
def first_page?
|
24
29
|
self.states.index(@state) <= 0
|
25
30
|
end
|
@@ -83,6 +88,5 @@ module Wizardz
|
|
83
88
|
def partial
|
84
89
|
@pages[@state].partial
|
85
90
|
end
|
86
|
-
|
87
91
|
end
|
88
92
|
end
|
data/spec/wizardz/wizard_spec.rb
CHANGED
@@ -188,6 +188,24 @@ describe "Wizard" do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
end
|
191
|
+
|
192
|
+
context "access page data via method missing call" do
|
193
|
+
before(:each) do
|
194
|
+
@wiz = ValidStates.new
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'does NOT generate an error with the page exists' do
|
198
|
+
lambda { @wiz.first_state }.should_not raise_error
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'returns the page data when the page exists' do
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'generates an error when the page does not exist' do
|
206
|
+
lambda { @wiz.unknown_state }.should raise_error
|
207
|
+
end
|
208
|
+
end
|
191
209
|
|
192
210
|
# it 'return true for the first_look? value (indicates if page should be validated)' do
|
193
211
|
# wiz = Wizardz::Wizard.new({:unprocessed => [:first_state]})
|
data/wizardz.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wizardz}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Henry"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-26}
|
13
13
|
s.description = %q{Multi-Step wizard that deals with multiple models and changing step options based on previous step input}
|
14
14
|
s.email = %q{dave_henry@lyagushka.co.uk}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizardz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Henry
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-26 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|