├── .gitignore
├── CHANGELOG.rdoc
├── LICENSE
├── README.rdoc
├── Rakefile
├── app
├── controllers
│ ├── application_controller.rb
│ ├── avatar_session_controller.rb
│ ├── callbacks2_controller.rb
│ ├── callbacks3_controller.rb
│ ├── callbacks_controller.rb
│ ├── callbacks_module.rb
│ ├── data_modes2_controller.rb
│ ├── data_modes_controller.rb
│ ├── generated_controller.rb
│ ├── image_submit_controller.rb
│ ├── macro_controller.rb
│ ├── main_controller.rb
│ ├── sandbox_controller.rb
│ ├── scaffold_test_controller.rb
│ └── session_controller.rb
├── helpers
│ ├── application_helper.rb
│ ├── avatar_session_helper.rb
│ ├── callbacks_helper.rb
│ ├── data_modes_helper.rb
│ ├── generated_helper.rb
│ ├── image_submit_helper.rb
│ ├── sandbox_helper.rb
│ ├── scaffold_test_helper.rb
│ └── session_helper.rb
├── models
│ ├── four_step_user.rb
│ ├── user.rb
│ └── user_avatar.rb
└── views
│ ├── avatar_session
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── callbacks
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── data_modes
│ ├── _finish.html.erb
│ ├── _init.html.erb
│ ├── _second.html.erb
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── data_modes2
│ ├── _finish.html.erb
│ ├── _init.html.erb
│ ├── _second.html.erb
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── generated
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── image_submit
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── layouts
│ ├── application.html.erb
│ ├── avatar_session.html.erb
│ ├── callbacks.html.erb
│ ├── data_modes.html.erb
│ ├── generated.html.erb
│ ├── image_submit.html.erb
│ ├── sandbox.html.erb
│ ├── scaffold_test.html.erb
│ └── session.html.erb
│ ├── macro
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ ├── main
│ ├── canceled.html.erb
│ ├── finished.html.erb
│ ├── index.html.erb
│ └── referrer_page.html.erb
│ ├── sandbox
│ ├── finish.html.erb
│ ├── init.html.erb
│ ├── second.html.erb
│ └── third.html.erb
│ ├── scaffold_test
│ ├── finish.html.erb
│ ├── init.html.erb
│ └── second.html.erb
│ └── session
│ ├── finish.html.erb
│ ├── init.html.erb
│ ├── second.html.erb
│ └── third.html.erb
├── config
├── boot.rb
├── database.yml
├── environment.rb
├── environments
│ ├── development.rb
│ ├── production.rb
│ └── test.rb
├── initializers
│ ├── backtrace_silencers.rb
│ ├── inflections.rb
│ ├── mime_types.rb
│ ├── new_rails_defaults.rb
│ └── session_store.rb
├── locales
│ └── en.yml
└── routes.rb
├── db
├── migrate
│ ├── 20090718171255_create_sessions.rb
│ └── 20090718172749_create_users.rb
└── schema.rb
├── init.rb
├── lib
├── generators
│ ├── wizardly_app
│ │ ├── USAGE
│ │ ├── templates
│ │ │ └── wizardly.rake
│ │ └── wizardly_app_generator.rb
│ ├── wizardly_controller
│ │ ├── USAGE
│ │ ├── templates
│ │ │ ├── controller.rb.erb
│ │ │ └── helper.rb.erb
│ │ └── wizardly_controller_generator.rb
│ └── wizardly_scaffold
│ │ ├── USAGE
│ │ ├── templates
│ │ ├── form.html.erb
│ │ ├── form.html.haml.erb
│ │ ├── helper.rb.erb
│ │ ├── images
│ │ │ ├── back.png
│ │ │ ├── cancel.png
│ │ │ ├── finish.png
│ │ │ ├── next.png
│ │ │ └── skip.png
│ │ ├── layout.html.erb
│ │ ├── layout.html.haml.erb
│ │ └── style.css
│ │ └── wizardly_scaffold_generator.rb
├── jeffp-wizardly.rb
├── validation_group.rb
├── wizardly.rb
└── wizardly
│ ├── action_controller.rb
│ ├── wizard.rb
│ └── wizard
│ ├── button.rb
│ ├── configuration.rb
│ ├── configuration
│ └── methods.rb
│ ├── dsl.rb
│ ├── page.rb
│ ├── text_helpers.rb
│ └── utils.rb
├── public
├── .gitignore
├── 404.html
├── 422.html
├── 500.html
├── favicon.ico
├── images
│ ├── avatar.png
│ ├── rails.png
│ └── wizardly
│ │ ├── back.png
│ │ ├── cancel.png
│ │ ├── finish.png
│ │ ├── next.png
│ │ └── skip.png
├── javascripts
│ ├── application.js
│ ├── controls.js
│ ├── dragdrop.js
│ ├── effects.js
│ └── prototype.js
├── robots.txt
└── stylesheets
│ └── scaffold.css
├── rails_generators
├── wizardly_app
│ ├── USAGE
│ ├── templates
│ │ └── wizardly.rake
│ └── wizardly_app_generator.rb
├── wizardly_controller
│ ├── USAGE
│ ├── templates
│ │ ├── controller.rb.erb
│ │ └── helper.rb.erb
│ └── wizardly_controller_generator.rb
└── wizardly_scaffold
│ ├── USAGE
│ ├── templates
│ ├── form.html.erb
│ ├── form.html.haml.erb
│ ├── helper.rb.erb
│ ├── images
│ │ ├── back.png
│ │ ├── cancel.png
│ │ ├── finish.png
│ │ ├── next.png
│ │ └── skip.png
│ ├── layout.html.erb
│ ├── layout.html.haml.erb
│ └── style.css
│ └── wizardly_scaffold_generator.rb
├── script
├── about
├── autospec
├── console
├── dbconsole
├── destroy
├── generate
├── performance
│ ├── benchmarker
│ └── profiler
├── plugin
├── runner
├── server
├── spec
└── spec_server
├── spec
├── controllers
│ ├── callbacks2_spec.rb
│ ├── callbacks3_spec.rb
│ └── callbacks_spec.rb
├── fixtures
│ └── users.yml
├── integrations
│ ├── avatar_spec.rb
│ ├── avatar_step_helpers.rb
│ ├── data_modes2_spec.rb
│ ├── data_modes_spec.rb
│ ├── four_step_helpers.rb
│ ├── generated_spec.rb
│ ├── macro_spec.rb
│ ├── matchers.rb
│ ├── sandbox_spec.rb
│ ├── scaffold_test_spec.rb
│ ├── session_spec.rb
│ ├── shared_examples.rb
│ └── step_helpers.rb
├── models
│ └── user_specd.rb
├── rcov.opts
├── spec.opts
└── spec_helper.rb
├── test
├── fixtures
│ └── users.yml
├── functional
│ ├── callbacks_controller_test.rb
│ └── image_submit_controller_test.rb
├── performance
│ └── browsing_test.rb
├── test_helper.rb
└── unit
│ ├── helpers
│ ├── callbacks_helper_test.rb
│ └── image_submit_helper_test.rb
│ └── user_test.rb
└── wizardly.gemspec
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | **/*.log
3 | **/*.sqlite3
4 | **/*.sqlite
5 | **/Thumbs.db
6 | pkg
7 | rdoc
8 | coverage
9 | doc
10 | log
11 | nbproject
12 | tmp
13 | vendor
14 | lib/tasks/*
15 | TODO.rdoc
16 |
--------------------------------------------------------------------------------
/CHANGELOG.rdoc:
--------------------------------------------------------------------------------
1 | == master
2 |
3 | == 0.0.1 / 2009-07-28
4 |
5 | * Created wizard implementation for submit_tag buttons
6 | * Created WizardConfig, WizardPage and WizardButton
7 | * Added wizard functions to validation_group (by alex kira)
8 | * Created validation_group gem
9 | * Added Implementation, Macro, Generated Controllers
10 | * Refactored spec integration tests for the three controllers
11 | * Created Wizardized_controller generator
12 |
13 | == 0.0.2 / 2009-07-29
14 |
15 | * script/generate wizardly_scaffold controller_name
16 |
17 | == 0.0.3 / 2009-07-30
18 |
19 | * added render_wizard_page for respond_to handling
20 | * added wizard button and page callbacks
21 | * tests for callbacks
22 |
23 | == 0.0.3 / 2009-08-01
24 |
25 | * refactored into library
26 | * integrated validation_groups until later
27 | * renamed to act_wizardly_for
28 |
29 | == 0.1.0 /2009-08-02
30 |
31 | * README.rdoc initial version
32 | * gem version 0.1.0
33 |
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2009 Jeff Patmon
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | $:.unshift('lib')
2 | # Add your own tasks in files placed in lib/tasks ending in .rake, for example
3 | # lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require(File.join(File.dirname(__FILE__), 'config', 'boot'))
6 |
7 | require 'rake'
8 | require 'rake/testtask'
9 | require 'rake/rdoctask'
10 | require 'rake/gempackagetask'
11 |
12 | require 'tasks/rails'
13 | require 'fileutils'
14 |
15 | spec = Gem::Specification.new do |s|
16 | s.name = 'wizardly'
17 | s.version = '0.1.8.9'
18 | s.platform = Gem::Platform::RUBY
19 | s.description = 'Create wizards from any model in three steps'
20 | s.summary = 'Produces controllers and wizard scaffolding for models with validation_groups'
21 |
22 | #move all files in lib/generators -> rails_generators
23 | FileUtils.rm_rf "rails_generators"
24 | FileUtils.mkdir "rails_generators"
25 | FileUtils.cp_r "lib/generators/.", "rails_generators"
26 | exclude_files = FileList['**/*.log'] + FileList['lib/generators/**/*'] + FileList['lib/tasks/**/*']
27 | s.files = FileList['{lib,rails_generators}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE README.rdoc) - exclude_files
28 | s.require_path = 'lib'
29 | s.has_rdoc = true
30 | #s.test_files = Dir['spec/*_spec.rb']
31 |
32 | s.author = 'Jeff Patmon'
33 | s.email = 'jpatmon@yahoo.com'
34 | s.homepage = 'http://github.com/jeffp/wizardly/tree/master'
35 | end
36 |
37 | require 'spec/version'
38 | require 'spec/rake/spectask'
39 |
40 | namespace :spec do
41 | desc "Run all specs"
42 | task :all=>[:macro, :gen, :scaffold, :callback, :callback2, :callback3, :persist, :sandbox, :session]
43 | desc "Test the AvatarController"
44 | Spec::Rake::SpecTask.new(:avatar) do |t|
45 | t.spec_files = FileList['spec/integrations/avatar_spec.rb']
46 | t.libs << 'lib' << 'spec' << 'spec/integrations'
47 | t.spec_opts = ['--options', 'spec/spec.opts']
48 | t.rcov = false
49 | end
50 | desc "Test the MacroController"
51 | Spec::Rake::SpecTask.new(:macro) do |t|
52 | t.spec_files = FileList['spec/integrations/macro_spec.rb']
53 | t.libs << 'lib' << 'spec' << 'spec/integrations'
54 | t.spec_opts = ['--options', 'spec/spec.opts']
55 | t.rcov = false
56 | end
57 | desc "Test the DataModes2Controller"
58 | Spec::Rake::SpecTask.new(:persist2) do |t|
59 | t.spec_files = FileList['spec/integrations/data_modes2_spec.rb']
60 | t.libs << 'lib' << 'spec' << 'spec/integrations'
61 | t.spec_opts = ['--options', 'spec/spec.opts']
62 | t.rcov = false
63 | end
64 | desc "Test the DataModesController"
65 | Spec::Rake::SpecTask.new(:persist) do |t|
66 | t.spec_files = FileList['spec/integrations/data_modes_spec.rb']
67 | t.libs << 'lib' << 'spec' << 'spec/integrations'
68 | t.spec_opts = ['--options', 'spec/spec.opts']
69 | t.rcov = false
70 | end
71 | desc "Test the SandboxController"
72 | Spec::Rake::SpecTask.new(:sandbox) do |t|
73 | t.spec_files = FileList['spec/integrations/sandbox_spec.rb']
74 | t.libs << 'lib' << 'spec' << 'spec/integrations'
75 | t.spec_opts = ['--options', 'spec/spec.opts']
76 | t.rcov = false
77 | end
78 | desc "Test the SessionController"
79 | Spec::Rake::SpecTask.new(:session) do |t|
80 | t.spec_files = FileList['spec/integrations/session_spec.rb']
81 | t.libs << 'lib' << 'spec' << 'spec/integrations'
82 | t.spec_opts = ['--options', 'spec/spec.opts']
83 | t.rcov = false
84 | end
85 | desc "Test the GeneratedController"
86 | Spec::Rake::SpecTask.new(:gen=>[:generate_controller]) do |t|
87 | t.spec_files = FileList['spec/integrations/generated_spec.rb']
88 | t.libs << 'lib' << 'spec' << 'spec/integrations'
89 | t.spec_opts = ['--options', 'spec/spec.opts']
90 | t.rcov = false
91 | end
92 | desc "Generate GeneratedController for spec test"
93 | task :generate_controller=>[:environment] do
94 | require 'rails_generator'
95 | require 'rails_generator/scripts/generate'
96 | gen_argv = []
97 | gen_argv << "wizardly_controller" << "generated" << "user" << "/main/finished" << "/main/canceled" << "--force"
98 | Rails::Generator::Scripts::Generate.new.run(gen_argv)
99 | end
100 | desc "Test the ScaffoldTestController"
101 | Spec::Rake::SpecTask.new(:scaffold) do |t|
102 | t.spec_files = FileList['spec/integrations/scaffold_test_spec.rb']
103 | t.libs << 'lib' << 'spec' << 'spec/integrations'
104 | t.spec_opts = ['--options', 'spec/spec.opts']
105 | t.rcov = false
106 | end
107 | desc "Test the CallbacksController"
108 | Spec::Rake::SpecTask.new(:callback) do |t|
109 | t.spec_files = FileList['spec/controllers/callbacks_spec.rb']
110 | t.libs << 'lib' << 'spec' << 'spec/integrations'
111 | t.spec_opts = ['--options', 'spec/spec.opts']
112 | t.rcov = false
113 | end
114 | desc "Test the Callbacks2Controller"
115 | Spec::Rake::SpecTask.new(:callback2) do |t|
116 | t.spec_files = FileList['spec/controllers/callbacks2_spec.rb']
117 | t.libs << 'lib' << 'spec' << 'spec/integrations'
118 | t.spec_opts = ['--options', 'spec/spec.opts']
119 | t.rcov = false
120 | end
121 | desc "Test the Callbacks3Controller"
122 | Spec::Rake::SpecTask.new(:callback3) do |t|
123 | t.spec_files = FileList['spec/controllers/callbacks3_spec.rb']
124 | t.libs << 'lib' << 'spec' << 'spec/integrations'
125 | t.spec_opts = ['--options', 'spec/spec.opts']
126 | t.rcov = false
127 | end
128 | end
129 |
130 |
131 | desc "Generate documentation for the #{spec.name} plugin."
132 | Rake::RDocTask.new(:rdoc) do |rdoc|
133 | rdoc.rdoc_dir = 'rdoc'
134 | rdoc.title = spec.name
135 | # #rdoc.template = '../rdoc_template.rb'
136 | rdoc.options << '--line-numbers' << '--inline-source'
137 | rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/wizardly.rb', 'lib/wizardly/**/*.rb')
138 | end
139 |
140 | desc 'Generate a gemspec file.'
141 | task :gemspec do
142 | File.open("#{spec.name}.gemspec", 'w') do |f|
143 | f.write spec.to_ruby
144 | end
145 | end
146 |
147 | Rake::GemPackageTask.new(spec) do |p|
148 | FileUtils.rm_rf "rails_generators"
149 | FileUtils.mkdir "rails_generators"
150 | FileUtils.cp_r "lib/generators/.", "rails_generators"
151 | p.gem_spec = spec
152 | p.need_tar = RUBY_PLATFORM =~ /mswin/ ? false : true
153 | p.need_zip = true
154 | end
155 |
156 | Dir['tasks/**/*.rake'].each {|rake| load rake}
157 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | # Filters added to this controller apply to all controllers in the application.
2 | # Likewise, all the methods added will be available for all controllers.
3 |
4 | class ApplicationController < ActionController::Base
5 | helper :all # include all helpers, all the time
6 | protect_from_forgery # See ActionController::RequestForgeryProtection for details
7 |
8 | # Scrub sensitive parameters from your log
9 | # filter_parameter_logging :password
10 | end
11 |
--------------------------------------------------------------------------------
/app/controllers/avatar_session_controller.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 | class AvatarSessionController < ApplicationController
3 | #tests paperclip
4 | act_wizardly_for :user_avatar, :form_data=>:session, :persist_model=>:per_page,
5 | :completed=>{:controller=>:main, :action=>:finished},
6 | :canceled=>{:controller=>:main, :action=>:canceled}
7 |
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/app/controllers/callbacks2_controller.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 | class Callbacks2Controller < ApplicationController
3 |
4 | act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation],
5 | :completed=>{:controller=>:main, :action=>:finished},
6 | :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled}
7 |
8 | #NOTE: these only for testing - the preferred method of defining callbacks is
9 | # using the callback macros -- see Callbacks3Controller and the Readme.rdoc ;)
10 | def _on_post_second_form
11 | redirect_to '/main/index#on_post_second_form'
12 | end
13 | def _on_get_init_form
14 | redirect_to '/main/index#on_get_init_form'
15 | end
16 | def _on_invalid_init_form
17 | redirect_to '/main/index#on_invalid_init_form'
18 | end
19 | def _on_init_form_back
20 | redirect_to '/main/index#on_init_form_back'
21 | end
22 | def _on_init_form_cancel
23 | redirect_to '/main/index#on_init_form_cancel'
24 | end
25 | def _on_init_form_next
26 | redirect_to '/main/index#on_init_form_next'
27 | end
28 | def _on_init_form_skip
29 | redirect_to '/main/index#on_init_form_skip'
30 | end
31 | def _on_finish_form_finish
32 | redirect_to '/main/index#on_finish_form_finish'
33 | end
34 | hide_action :_on_post_second_form
35 | hide_action :_on_get_init_form
36 | hide_action :_on_invalid_init_form
37 | hide_action :_on_init_form_back
38 | hide_action :_on_init_form_cancel
39 | hide_action :_on_init_form_next
40 | hide_action :_on_init_form_skip
41 | hide_action :_on_finish_form_finish
42 |
43 | end
44 |
--------------------------------------------------------------------------------
/app/controllers/callbacks3_controller.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 | class Callbacks3Controller < ApplicationController
3 |
4 | act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation],
5 | :completed=>{:controller=>:main, :action=>:finished},
6 | :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled}
7 |
8 | on_post(:second) do
9 | redirect_to '/main/index#on_post_second_form'
10 | end
11 | on_post(:init) do
12 | @on_post_init_form = true
13 | end
14 | on_get(:all) do
15 | redirect_to '/main/index#on_get_all'
16 | end
17 | on_errors(:init) do
18 | redirect_to '/main/index#on_invalid_init_form'
19 | end
20 | on_back(:init, :finish) do
21 | redirect_to '/main/index#on_init_and_finish_form_back'
22 | end
23 | on_cancel(:init, :finish) do
24 | redirect_to '/main/index#on_init_and_finish_form_cancel'
25 | end
26 | on_next(:init) do
27 | redirect_to '/main/index#on_init_form_next'
28 | end
29 | on_skip(:init, :finish) do
30 | redirect_to '/main/index#on_init_and_finish_form_skip'
31 | end
32 | on_finish(:finish) do
33 | redirect_to '/main/index#on_finish_form_finish'
34 | end
35 |
36 | end
37 |
--------------------------------------------------------------------------------
/app/controllers/callbacks_controller.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 | class CallbacksController < ApplicationController
3 | require 'callbacks_module'
4 |
5 | act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation],
6 | :completed=>{:controller=>:main, :action=>:finished},
7 | :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled}
8 |
9 |
10 | def flag(val)
11 | instance_variable_set("@#{val}", true)
12 | #puts "--<<#{val}>>--"
13 | end
14 |
15 | def self.flag_callback(name)
16 | self.class_eval "def #{name}; flag :#{name}; end "
17 | end
18 | def self.chain_callback(name)
19 | self.class_eval <<-ERT
20 | alias_method :#{name}_orig, :#{name}
21 | def #{name}; flag :#{name}; #{name}_orig; end
22 | ERT
23 | end
24 | Callbacks::action_callbacks.each {|cb| flag_callback cb }
25 | # def on_invalid_finish_form
26 | # flag :on_finish_page_errors
27 | # @user[:password] = ''
28 | # @user[:password_confirmation] = ''
29 | # end
30 | Callbacks::wizard_callbacks.each {|cb| chain_callback cb}
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/app/controllers/callbacks_module.rb:
--------------------------------------------------------------------------------
1 | module Callbacks
2 |
3 | # on_errors(:second) do
4 | # end
5 | # on_get(:second) do
6 | # end
7 | # on_post(:second) do
8 | # end
9 | # on_next(:second) do
10 | # end
11 | # on_cancel(:second) do
12 | # end
13 | # on_render do
14 | # end
15 | # on_cancel(:all) do
16 | # end
17 |
18 | def self.action_callbacks
19 | [
20 | :_on_get_init_form,
21 | :_on_post_init_form,
22 | :_on_invalid_init_form,
23 | :_on_init_form_next,
24 | :_on_init_form_finish,
25 | :_on_init_form_back,
26 | :_on_init_form_skip,
27 | :_on_init_form_cancel,
28 |
29 | :_on_get_second_porm,
30 | :_on_post_init_form,
31 | :_on_invalid_init_form,
32 | :_on_second_form_back,
33 | :_on_second_form_next,
34 | :_on_second_form_skip,
35 | :_on_second_form_finish,
36 | :_on_second_form_cancel,
37 |
38 | :_on_get_finish_form,
39 | :_on_post_finish_form,
40 | :_on_invalid_finish_form,
41 | :_on_finish_form_back,
42 | :_on_finish_form_skip,
43 | :_on_finish_form_finish,
44 | :_on_finish_form_next,
45 | :_on_finish_form_cancel,
46 |
47 | :wizard_render_form
48 | ]
49 | end
50 |
51 | def self.wizard_callbacks
52 | [
53 | :_on_wizard_cancel,
54 | :_on_wizard_skip,
55 | :_on_wizard_back,
56 | :_on_wizard_finish
57 | ]
58 | end
59 |
60 | end
--------------------------------------------------------------------------------
/app/controllers/data_modes2_controller.rb:
--------------------------------------------------------------------------------
1 | class DataModes2Controller < ApplicationController
2 |
3 | act_wizardly_for :user, :persist_model=>:per_page, :form_data=>:sandbox,
4 | :completed=>{:controller=>:main, :action=>:finished},
5 | :canceled=>{:controller=>:main, :action=>:canceled}
6 |
7 | end
8 |
--------------------------------------------------------------------------------
/app/controllers/data_modes_controller.rb:
--------------------------------------------------------------------------------
1 | class DataModesController < ApplicationController
2 |
3 | act_wizardly_for :user, :persist_model=>:per_page, :form_data=>:session,
4 | :completed=>{:controller=>:main, :action=>:finished},
5 | :canceled=>{:controller=>:main, :action=>:canceled}
6 |
7 | end
8 |
--------------------------------------------------------------------------------
/app/controllers/image_submit_controller.rb:
--------------------------------------------------------------------------------
1 | class ImageSubmitController < ApplicationController
2 | wizard_for_model :user, :redirect=>'/main/index', :skip=>true
3 | end
4 |
--------------------------------------------------------------------------------
/app/controllers/macro_controller.rb:
--------------------------------------------------------------------------------
1 | class MacroController < ApplicationController
2 |
3 | act_wizardly_for :user, :form_data=>:sandbox,
4 | :completed=>{:controller=>:main, :action=>:finished},
5 | :canceled=>{:controller=>:main, :action=>:canceled}
6 |
7 | end
8 |
--------------------------------------------------------------------------------
/app/controllers/main_controller.rb:
--------------------------------------------------------------------------------
1 | class MainController < ApplicationController
2 | def index
3 | @links = {
4 | :macro=>'/macro',
5 | :avatar_session=>'/avatar_session',
6 | :generated=>'/generated',
7 | :scaffold_test=>'/scaffold_test',
8 | :callbacks=>'/callbacks',
9 | :session=>'/session',
10 | :session_init=>'/session/init',
11 | :session_second=>'/session/second',
12 | :session_third=>'/session/third',
13 | :session_finish=>'/session/finish',
14 | :sandbox=>'/sandbox',
15 | :sandbox_init=>'/sandbox/init',
16 | :sandbox_second=>'/sandbox/second',
17 | :sandbox_third=>'/sandbox/third',
18 | :sandbox_finish=>'/sandbox/finish',
19 | :image_submit=>'/image_submit'
20 | }
21 | end
22 |
23 | def finished
24 | @referring_controller = referring_controller
25 | end
26 |
27 | def canceled
28 | @referring_controller = referring_controller
29 | end
30 |
31 | def referrer_page
32 | end
33 |
34 | private
35 | def referring_controller
36 | referer = request.env['HTTP_REFERER']
37 | ActionController::Routing::Routes.recognize_path(URI.parse(referer).path)[:controller]
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/app/controllers/sandbox_controller.rb:
--------------------------------------------------------------------------------
1 | class SandboxController < ApplicationController
2 | act_wizardly_for :four_step_user, :redirect=>'/main/index', :form_data=>:sandbox, :skip=>true
3 |
4 | end
--------------------------------------------------------------------------------
/app/controllers/scaffold_test_controller.rb:
--------------------------------------------------------------------------------
1 | class ScaffoldTestController < ApplicationController #< WizardForModelController
2 |
3 | wizard_for_model :user, :skip=>true, :form_data=>:sandbox, :mask_passwords=>[:password, :password_confirmation],
4 | :completed=>{:controller=>:main, :action=>:finished},
5 | :canceled=>{:controller=>:main, :action=>:canceled}
6 |
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/app/controllers/session_controller.rb:
--------------------------------------------------------------------------------
1 | class SessionController < ApplicationController
2 | act_wizardly_for :four_step_user, :redirect=>'/main/index', :form_data=>:session, :skip=>true
3 |
4 | end
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | # Methods added to this helper will be available to all templates in the application.
2 | module ApplicationHelper
3 | end
4 |
--------------------------------------------------------------------------------
/app/helpers/avatar_session_helper.rb:
--------------------------------------------------------------------------------
1 | module AvatarSessionHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | step_id = "#{controller_name}_#{@step}".to_sym
6 | unless @@wizardly_submit[step_id]
7 | buttons = @wizard.pages[@step].buttons
8 | @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
9 | io << submit_tag(button.name, :name=>button.id.to_s)
10 | end.string
11 | end
12 | @@wizardly_submit[step_id]
13 | end
14 |
15 | def wizardly_image_submit(asset_dir = nil, opts = {})
16 | @@wizardly_image_submit ||={}
17 | step_id = "#{controller_name}_#{@step}".to_sym
18 | unless @@wizardly_image_submit[step_id]
19 | asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
20 | buttons = @wizard.pages[@step].buttons
21 | @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
22 | opts[:value] = button.name
23 | opts[:name] = button.id.to_s
24 | io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
25 | end.string
26 | end
27 | @@wizardly_image_submit[step_id]
28 | end
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/app/helpers/callbacks_helper.rb:
--------------------------------------------------------------------------------
1 | module CallbacksHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/app/helpers/data_modes_helper.rb:
--------------------------------------------------------------------------------
1 | module DataModesHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/app/helpers/generated_helper.rb:
--------------------------------------------------------------------------------
1 | module GeneratedHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/app/helpers/image_submit_helper.rb:
--------------------------------------------------------------------------------
1 | module ImageSubmitHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | step_id = "#{controller_name}_#{@step}".to_sym
6 | unless @@wizardly_submit[step_id]
7 | buttons = @wizard.pages[@step].buttons
8 | @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
9 | io << submit_tag(button.name)
10 | end.string
11 | end
12 | @@wizardly_submit[step_id]
13 | end
14 |
15 | def wizardly_image_submit(asset_dir = nil, opts = {})
16 | @@wizardly_image_submit ||={}
17 | step_id = "#{controller_name}_#{@step}".to_sym
18 | unless @@wizardly_image_submit[step_id]
19 | asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
20 | buttons = @wizard.pages[@step].buttons
21 | opts[:name] = 'commit'
22 | @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
23 | opts[:value] = button.name
24 | io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
25 | end.string
26 | end
27 | @@wizardly_image_submit[step_id]
28 | end
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/app/helpers/sandbox_helper.rb:
--------------------------------------------------------------------------------
1 | module SandboxHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/app/helpers/scaffold_test_helper.rb:
--------------------------------------------------------------------------------
1 | module ScaffoldTestHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | step_id = "#{controller_name}_#{@step}".to_sym
6 | unless @@wizardly_submit[step_id]
7 | buttons = @wizard.pages[@step].buttons
8 | @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
9 | io << submit_tag(button.name, :name=>button.id.to_s)
10 | end.string
11 | end
12 | @@wizardly_submit[step_id]
13 | end
14 |
15 | def wizardly_image_submit(asset_dir = nil, opts = {})
16 | @@wizardly_image_submit ||={}
17 | step_id = "#{controller_name}_#{@step}".to_sym
18 | unless @@wizardly_image_submit[step_id]
19 | asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
20 | buttons = @wizard.pages[@step].buttons
21 | @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
22 | opts[:value] = button.name
23 | opts[:name] = button.id.to_s
24 | io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
25 | end.string
26 | end
27 | @@wizardly_image_submit[step_id]
28 | end
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/app/helpers/session_helper.rb:
--------------------------------------------------------------------------------
1 | module SessionHelper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/app/models/four_step_user.rb:
--------------------------------------------------------------------------------
1 | require 'validation_group'
2 | class FourStepUser < User
3 |
4 | validation_group :init, :fields=>[:first_name, :last_name]
5 | validation_group :second, :fields=>[:age, :gender]
6 | validation_group :third, :fields=>[:programmer, :status]
7 | validation_group :finish, :fields=>[:username, :password, :password_confirmation]
8 |
9 |
10 | end
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | #require 'validation_group'
2 | class User < ActiveRecord::Base
3 | =begin
4 | t.string :first_name
5 | t.string :last_name
6 | t.string :username
7 | t.string :password
8 | t.integer :age
9 | t.string :gender
10 | t.boolean :programmer
11 | t.string :status
12 | =end
13 |
14 | validates_confirmation_of :password
15 | validates_presence_of :first_name, :last_name, :username, :password, :age, :gender, :status
16 | #validates_numercality_of :age
17 | #validates_uniqueness_of :username
18 |
19 | validation_group :init, :fields=>[:first_name, :last_name]
20 | validation_group :second, :fields=>[:age, :gender, :programmer, :status]
21 | validation_group :finish, :fields=>[:username, :password, :password_confirmation]
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/app/models/user_avatar.rb:
--------------------------------------------------------------------------------
1 | class UserAvatar < User
2 |
3 | has_attached_file :avatar
4 | validates_attachment_presence :avatar
5 |
6 | validation_group :init, :fields=>[:first_name, :last_name]
7 | validation_group :second, :fields=>[:age, :gender, :programmer, :status, :avatar]
8 | validation_group :finish, :fields=>[:username, :password, :password_confirmation]
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/app/views/avatar_session/finish.html.erb:
--------------------------------------------------------------------------------
1 |
Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user_avatar, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/avatar_session/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user_avatar, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/avatar_session/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user_avatar, :url=>{:action=>:second}, :html=>{:multipart=>true} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 |
31 | <%= f.label :avatar %>
32 | <%= f.file_field :avatar %>
33 |
34 |
35 | <%= wizardly_submit %>
36 |
37 | <% end %>
38 |
39 |
42 |
--------------------------------------------------------------------------------
/app/views/callbacks/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/callbacks/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/callbacks/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/data_modes/_finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/data_modes/_init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/data_modes/_second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/data_modes/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/data_modes/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/data_modes/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/data_modes2/_finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/data_modes2/_init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/data_modes2/_second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/data_modes2/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/data_modes2/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/data_modes2/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/generated/finish.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
username: <%= f.text_field :username %> <%= error_message_on :user, :username, {:prepend_text=>'*'} %>
4 |
password: <%= f.password_field :password %> <%= error_message_on :user, :password, {:prepend_text=>'*'} %>
5 |
password confirmation: <%= f.password_field :password_confirmation %> <%= error_message_on :user, :password_confirmation, {:prepend_text=>'*'} %>
6 |
<%= wizardly_submit %>
7 | <% end -%>
8 |
9 |
--------------------------------------------------------------------------------
/app/views/generated/init.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
first name: <%= f.text_field :first_name %> <%= error_message_on :user, :first_name, {:prepend_text=>'*'} %>
4 |
last name: <%= f.text_field :last_name %> <%= error_message_on :user, :last_name, {:prepend_text=>'*'} %>
5 |
<%= wizardly_submit %>
6 | <% end -%>
7 |
8 |
--------------------------------------------------------------------------------
/app/views/generated/second.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
age: <%= f.text_field :age %> <%= error_message_on :user, :age, {:prepend_text=>'*'} %>
4 |
gender: <%= f.text_field :gender %> <%= error_message_on :user, :gender, {:prepend_text=>'*'} %>
5 |
programmer: <%= f.check_box :programmer %> <%= error_message_on :user, :programmer, {:prepend_text=>'*'} %>
6 |
status: <%= f.text_field :status %> <%=error_message_on :user, :status, {:prepend_text=>'*'} %>
7 |
<%= wizardly_submit %>
8 | <% end -%>
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/views/image_submit/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_image_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/image_submit/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_image_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/image_submit/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_image_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%=@step%> page
4 |
5 |
6 |
7 | <%= yield :layout %>
8 |
9 |
--------------------------------------------------------------------------------
/app/views/layouts/avatar_session.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | AvatarSessionController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/callbacks.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | CallbacksController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/data_modes.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | DataModesController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/generated.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | GeneratedController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/image_submit.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | ImageSubmitController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/sandbox.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | SandboxController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/scaffold_test.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | ScaffoldTestController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/layouts/session.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | SessionController: <%= controller.action_name %>
8 | <%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/views/macro/finish.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
username: <%= f.text_field :username %> <%= error_message_on :user, :username, {:prepend_text=>'*'} %>
4 |
password: <%= f.password_field :password %> <%= error_message_on :user, :password, {:prepend_text=>'*'} %>
5 |
password confirmation: <%= f.password_field :password_confirmation %> <%= error_message_on :user, :password_confirmation, {:prepend_text=>'*'} %>
6 |
<%= submit_tag 'finish' %> <%= submit_tag 'back' %> <%=submit_tag 'cancel' %>
7 | <% end -%>
8 |
9 |
--------------------------------------------------------------------------------
/app/views/macro/init.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
first name: <%= f.text_field :first_name %> <%= error_message_on :user, :first_name, {:prepend_text=>'*'} %>
4 |
last name: <%= f.text_field :last_name %> <%= error_message_on :user, :last_name, {:prepend_text=>'*'} %>
5 |
<%= submit_tag 'next' %> <%= submit_tag 'skip' %> <%= submit_tag 'cancel' %>
6 | <% end -%>
7 |
8 |
--------------------------------------------------------------------------------
/app/views/macro/second.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% form_for :user do |f| -%>
3 |
age: <%= f.text_field :age %> <%= error_message_on :user, :age, {:prepend_text=>'*'} %>
4 |
gender: <%= f.text_field :gender %> <%= error_message_on :user, :gender, {:prepend_text=>'*'} %>
5 |
programmer: <%= f.check_box :programmer %> <%= error_message_on :user, :programmer, {:prepend_text=>'*'} %>
6 |
status: <%= f.text_field :status %> <%=error_message_on :user, :status, {:prepend_text=>'*'} %>
7 |
<%= submit_tag 'next' %> <%= submit_tag 'back' %> <%= submit_tag 'skip' %> <%= submit_tag 'finish' %> <%= submit_tag 'cancel' %>
8 | <% end -%>
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/views/main/canceled.html.erb:
--------------------------------------------------------------------------------
1 | Referer: <%="#{@referring_controller.to_s.camelize}Controller" %>
2 |
3 | <%=link_to 'signup', :controller=>@referring_controller %>
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/views/main/finished.html.erb:
--------------------------------------------------------------------------------
1 | Referer: <%="#{@referring_controller.to_s.camelize}Controller" %>
2 |
3 | <%=link_to 'signup', :controller=>@referring_controller %>
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/views/main/index.html.erb:
--------------------------------------------------------------------------------
1 | <% @links.each do |k,v| %>
2 | <%=link_to k.to_s, v %>
3 | <% end %>
--------------------------------------------------------------------------------
/app/views/main/referrer_page.html.erb:
--------------------------------------------------------------------------------
1 | Referer: <%="#{@referring_controller.to_s.camelize}Controller" %>
2 |
3 | <%=link_to 'signup', :controller=>@referring_controller %>
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/views/sandbox/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/sandbox/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/sandbox/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/sandbox/third.html.erb:
--------------------------------------------------------------------------------
1 | Third
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:third} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :programmer %>
12 | <%= f.check_box :programmer %>
13 |
14 |
15 |
16 | <%= f.label :status %>
17 | <%= f.text_field :status %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/scaffold_test/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/scaffold_test/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/scaffold_test/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 |
21 | <%= f.label :programmer %>
22 | <%= f.check_box :programmer %>
23 |
24 |
25 |
26 | <%= f.label :status %>
27 | <%= f.text_field :status %>
28 |
29 |
30 | <%= wizardly_submit %>
31 |
32 | <% end %>
33 |
34 |
37 |
--------------------------------------------------------------------------------
/app/views/session/finish.html.erb:
--------------------------------------------------------------------------------
1 | Finish
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:finish} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :username %>
12 | <%= f.text_field :username %>
13 |
14 |
15 |
16 | <%= f.label :password %>
17 | <%= f.password_field :password %>
18 |
19 |
20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation %>
23 |
24 |
25 | <%= wizardly_submit %>
26 |
27 | <% end %>
28 |
29 |
32 |
--------------------------------------------------------------------------------
/app/views/session/init.html.erb:
--------------------------------------------------------------------------------
1 | Init
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:init} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :first_name %>
12 | <%= f.text_field :first_name %>
13 |
14 |
15 |
16 | <%= f.label :last_name %>
17 | <%= f.text_field :last_name %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/session/second.html.erb:
--------------------------------------------------------------------------------
1 | Second
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:second} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :age %>
12 | <%= f.text_field :age %>
13 |
14 |
15 |
16 | <%= f.label :gender %>
17 | <%= f.text_field :gender %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/app/views/session/third.html.erb:
--------------------------------------------------------------------------------
1 | Third
2 |
3 |
4 | <%= "#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <% form_for :four_step_user, :url=>{:action=>:third} do |f| %>
7 | <%= f.error_messages %>
8 |
9 |
10 |
11 | <%= f.label :programmer %>
12 | <%= f.check_box :programmer %>
13 |
14 |
15 |
16 | <%= f.label :status %>
17 | <%= f.text_field :status %>
18 |
19 |
20 | <%= wizardly_submit %>
21 |
22 | <% end %>
23 |
24 |
27 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | # Don't change this file!
2 | # Configure your app in config/environment.rb and config/environments/*.rb
3 |
4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5 |
6 | module Rails
7 | class << self
8 | def boot!
9 | unless booted?
10 | preinitialize
11 | pick_boot.run
12 | end
13 | end
14 |
15 | def booted?
16 | defined? Rails::Initializer
17 | end
18 |
19 | def pick_boot
20 | (vendor_rails? ? VendorBoot : GemBoot).new
21 | end
22 |
23 | def vendor_rails?
24 | File.exist?("#{RAILS_ROOT}/vendor/rails")
25 | end
26 |
27 | def preinitialize
28 | load(preinitializer_path) if File.exist?(preinitializer_path)
29 | end
30 |
31 | def preinitializer_path
32 | "#{RAILS_ROOT}/config/preinitializer.rb"
33 | end
34 | end
35 |
36 | class Boot
37 | def run
38 | load_initializer
39 | Rails::Initializer.run(:set_load_path)
40 | end
41 | end
42 |
43 | class VendorBoot < Boot
44 | def load_initializer
45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46 | Rails::Initializer.run(:install_gem_spec_stubs)
47 | Rails::GemDependency.add_frozen_gem_path
48 | end
49 | end
50 |
51 | class GemBoot < Boot
52 | def load_initializer
53 | self.class.load_rubygems
54 | load_rails_gem
55 | require 'initializer'
56 | end
57 |
58 | def load_rails_gem
59 | if version = self.class.gem_version
60 | gem 'rails', version
61 | else
62 | gem 'rails'
63 | end
64 | rescue Gem::LoadError => load_error
65 | $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66 | exit 1
67 | end
68 |
69 | class << self
70 | def rubygems_version
71 | Gem::RubyGemsVersion rescue nil
72 | end
73 |
74 | def gem_version
75 | if defined? RAILS_GEM_VERSION
76 | RAILS_GEM_VERSION
77 | elsif ENV.include?('RAILS_GEM_VERSION')
78 | ENV['RAILS_GEM_VERSION']
79 | else
80 | parse_gem_version(read_environment_rb)
81 | end
82 | end
83 |
84 | def load_rubygems
85 | require 'rubygems'
86 | min_version = '1.3.1'
87 | unless rubygems_version >= min_version
88 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89 | exit 1
90 | end
91 |
92 | rescue LoadError
93 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94 | exit 1
95 | end
96 |
97 | def parse_gem_version(text)
98 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99 | end
100 |
101 | private
102 | def read_environment_rb
103 | File.read("#{RAILS_ROOT}/config/environment.rb")
104 | end
105 | end
106 | end
107 | end
108 |
109 | # All that for this:
110 | Rails.boot!
111 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3-ruby (not necessary on OS X Leopard)
3 | development:
4 | adapter: sqlite3
5 | database: db/development.sqlite3
6 | pool: 5
7 | timeout: 5000
8 |
9 | # Warning: The database defined as "test" will be erased and
10 | # re-generated from your development database when you run "rake".
11 | # Do not set this db to the same as development or production.
12 | test:
13 | adapter: sqlite3
14 | database: db/test.sqlite3
15 | pool: 5
16 | timeout: 5000
17 |
18 | production:
19 | adapter: sqlite3
20 | database: db/production.sqlite3
21 | pool: 5
22 | timeout: 5000
23 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file
2 |
3 | # Specifies gem version of Rails to use when vendor/rails is not present
4 | RAILS_GEM_VERSION = '>=2.2.1' unless defined? RAILS_GEM_VERSION
5 |
6 | # Bootstrap the Rails environment, frameworks, and default configuration
7 | require File.join(File.dirname(__FILE__), 'boot')
8 |
9 | Rails::Initializer.run do |config|
10 | # Settings in config/environments/* take precedence over those specified here.
11 | # Application configuration should go into files in config/initializers
12 | # -- all .rb files in that directory are automatically loaded.
13 |
14 | # Add additional load paths for your own custom dirs
15 | # config.load_paths += %W( #{RAILS_ROOT}/extras )
16 |
17 | # Specify gems that this application depends on and have them installed with rake gems:install
18 | # config.gem "bj"
19 | # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20 | # config.gem "sqlite3-ruby", :lib => "sqlite3"
21 | # config.gem "aws-s3", :lib => "aws/s3"
22 | #config.gem "#{Rails::GemDependency.new("enumerated_attribute").installed? ? "" : "jeffp-"}enumerated_attribute"
23 | config.gem "thoughtbot-paperclip", :lib=>"paperclip", :source=>"http://gems.github.com"
24 |
25 | # Only load the plugins named here, in the order given (default is alphabetical).
26 | # :all can be used as a placeholder for all plugins not explicitly named
27 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
28 |
29 | # Skip frameworks you're not going to use. To use Rails without a database,
30 | # you must remove the Active Record framework.
31 | # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
32 |
33 | # Activate observers that should always be running
34 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
35 | config.action_controller.session_store = :active_record_store
36 |
37 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
38 | # Run "rake -D time" for a list of tasks for finding time zone names.
39 | config.time_zone = 'UTC'
40 |
41 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
42 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
43 | # config.i18n.default_locale = :de
44 | end
45 |
46 | require 'wizardly'
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | # Settings specified here will take precedence over those in config/environment.rb
2 |
3 | # In the development environment your application's code is reloaded on
4 | # every request. This slows down response time but is perfect for development
5 | # since you don't have to restart the webserver when you make code changes.
6 | config.cache_classes = false
7 |
8 | # Log error messages when you accidentally call methods on nil.
9 | config.whiny_nils = true
10 |
11 | # Show full error reports and disable caching
12 | config.action_controller.consider_all_requests_local = true
13 | config.action_view.debug_rjs = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | # Settings specified here will take precedence over those in config/environment.rb
2 |
3 | # The production environment is meant for finished, "live" apps.
4 | # Code is not reloaded between requests
5 | config.cache_classes = true
6 |
7 | # Full error reports are disabled and caching is turned on
8 | config.action_controller.consider_all_requests_local = false
9 | config.action_controller.perform_caching = true
10 | config.action_view.cache_template_loading = true
11 |
12 | # See everything in the log (default is :info)
13 | # config.log_level = :debug
14 |
15 | # Use a different logger for distributed setups
16 | # config.logger = SyslogLogger.new
17 |
18 | # Use a different cache store in production
19 | # config.cache_store = :mem_cache_store
20 |
21 | # Enable serving of images, stylesheets, and javascripts from an asset server
22 | # config.action_controller.asset_host = "http://assets.example.com"
23 |
24 | # Disable delivery errors, bad email addresses will be ignored
25 | # config.action_mailer.raise_delivery_errors = false
26 |
27 | # Enable threaded mode
28 | # config.threadsafe!
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | # Settings specified here will take precedence over those in config/environment.rb
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 | config.cache_classes = true
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.action_controller.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 | config.action_view.cache_template_loading = true
16 |
17 | # Disable request forgery protection in test environment
18 | config.action_controller.allow_forgery_protection = false
19 |
20 | # Tell Action Mailer not to deliver emails to the real world.
21 | # The :test delivery method accumulates sent emails in the
22 | # ActionMailer::Base.deliveries array.
23 | config.action_mailer.delivery_method = :test
24 |
25 | # Use SQL instead of Active Record's schema dumper when creating the test database.
26 | # This is necessary if your schema can't be completely dumped by the schema dumper,
27 | # like if you have constraints or database-specific column types
28 | # config.active_record.schema_format = :sql
29 |
30 | config.gem "webrat", :version=>">=0.4.3"
31 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/initializers/new_rails_defaults.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # These settings change the behavior of Rails 2 apps and will be defaults
4 | # for Rails 3. You can remove this initializer when Rails 3 is released.
5 |
6 | if defined?(ActiveRecord)
7 | # Include Active Record class name as root for JSON serialized output.
8 | ActiveRecord::Base.include_root_in_json = true
9 |
10 | # Store the full class name (including module namespace) in STI type column.
11 | ActiveRecord::Base.store_full_sti_class = true
12 | end
13 |
14 | # Use ISO 8601 format for JSON serialized times and dates.
15 | ActiveSupport.use_standard_json_time_format = true
16 |
17 | # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
18 | # if you're including raw json in an HTML page.
19 | ActiveSupport.escape_html_entities_in_json = false
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying cookie session data integrity.
4 | # If you change this key, all old sessions will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | ActionController::Base.session = {
8 | :key => '_wizard_session',
9 | :secret => 'bbd1b39720a747639fea9e3b40b5db4d67cabdedab097746587fdd9d390c1ce2108d812fd23054eb9ac0c6d4bbb07357a532cd8cf0e847cac5cc319ab1364175'
10 | }
11 |
12 | # Use the database for sessions instead of the cookie-based default,
13 | # which shouldn't be used to store highly confidential information
14 | # (create the session table with "rake db:sessions:create")
15 | # ActionController::Base.session_store = :active_record_store
16 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | ActionController::Routing::Routes.draw do |map|
2 | # The priority is based upon order of creation: first created -> highest priority.
3 | map.root :controller=>'main'
4 |
5 | # Sample of regular route:
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 | # Keep in mind you can assign values other than :controller and :action
8 |
9 | # Sample of named route:
10 | # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
11 | # This route can be invoked with purchase_url(:id => product.id)
12 |
13 | # Sample resource route (maps HTTP verbs to controller actions automatically):
14 | # map.resources :products
15 |
16 | # Sample resource route with options:
17 | # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
18 |
19 | # Sample resource route with sub-resources:
20 | # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
21 |
22 | # Sample resource route with more complex sub-resources
23 | # map.resources :products do |products|
24 | # products.resources :comments
25 | # products.resources :sales, :collection => { :recent => :get }
26 | # end
27 |
28 | # Sample resource route within a namespace:
29 | # map.namespace :admin do |admin|
30 | # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
31 | # admin.resources :products
32 | # end
33 |
34 | # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
35 | # map.root :controller => "welcome"
36 |
37 | # See how all your routes lay out with "rake routes"
38 |
39 | # Install the default routes as the lowest priority.
40 | # Note: These default routes make all actions in every controller accessible via GET requests. You should
41 | # consider removing the them or commenting them out if you're using named routes and resources.
42 | map.connect ':controller/:action/:id'
43 | map.connect ':controller/:action/:id.:format'
44 | end
45 |
--------------------------------------------------------------------------------
/db/migrate/20090718171255_create_sessions.rb:
--------------------------------------------------------------------------------
1 | class CreateSessions < ActiveRecord::Migration
2 | def self.up
3 | create_table :sessions do |t|
4 | t.string :session_id, :null => false
5 | t.text :data
6 | t.timestamps
7 | end
8 |
9 | add_index :sessions, :session_id
10 | add_index :sessions, :updated_at
11 | end
12 |
13 | def self.down
14 | drop_table :sessions
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20090718172749_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration
2 | def self.up
3 | create_table :users do |t|
4 | t.string :first_name
5 | t.string :last_name
6 | t.string :username
7 | t.string :password
8 | t.integer :age
9 | t.string :gender
10 | t.boolean :programmer
11 | t.string :status
12 |
13 | t.string :avatar_file_name
14 | t.string :avatar_content_type
15 | t.integer :avatar_file_size
16 |
17 | t.timestamps
18 | end
19 | end
20 |
21 | def self.down
22 | drop_table :users
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead of editing this file,
2 | # please use the migrations feature of Active Record to incrementally modify your database, and
3 | # then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 | # to create the application database on another system, you should be using db:schema:load, not running
7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 | # you'll amass, the slower it'll run and the greater likelihood for issues).
9 | #
10 | # It's strongly recommended to check this file into your version control system.
11 |
12 | ActiveRecord::Schema.define(:version => 20090718172749) do
13 |
14 | create_table "sessions", :force => true do |t|
15 | t.string "session_id", :null => false
16 | t.text "data"
17 | t.datetime "created_at"
18 | t.datetime "updated_at"
19 | end
20 |
21 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
22 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
23 |
24 | create_table "users", :force => true do |t|
25 | t.string "first_name"
26 | t.string "last_name"
27 | t.string "username"
28 | t.string "password"
29 | t.integer "age"
30 | t.string "gender"
31 | t.boolean "programmer"
32 | t.string "status"
33 | t.string "avatar_file_name"
34 | t.string "avatar_content_type"
35 | t.integer "avatar_file_size"
36 | t.datetime "created_at"
37 | t.datetime "updated_at"
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/init.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_app/USAGE:
--------------------------------------------------------------------------------
1 | Prepares a rails application to use wizardly gem
2 |
3 | Moves the wizardly.rake file in to lib/tasks directory
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_app/templates/wizardly.rake:
--------------------------------------------------------------------------------
1 |
2 | namespace :wizardly do
3 | desc "Display wizard configuration details"
4 | task :config => :environment do
5 | name = ENV['name']
6 | return print_usage unless name
7 | begin
8 | name = name.strip.camelize
9 | name += 'Controller' unless name.match('Controller$')
10 | controller = name.constantize
11 | begin
12 | c = controller.wizard_config
13 | begin
14 | puts
15 | puts c.print_config
16 | rescue Exception=>e
17 | puts "Problem printing configuration."
18 | puts "#{e.class.name} -- #{e.message}"
19 | puts
20 | end
21 | rescue Exception=>e
22 | puts "{#{name}} is not a 'wizardly' controller.\nMake sure 'wizard_for_model' is defined in the controller class."
23 | puts "#{e.class.name} -- #{e.message}"
24 | puts
25 | end
26 | rescue Exception=>e
27 | puts "{#{name}} does not reference a controller class."
28 | puts "#{e.class.name} -- #{e.message}"
29 | puts
30 | end
31 | end
32 |
33 | def print_usage
34 | puts "Usage: rake wizardly:config name={controller_name}"
35 | puts
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_app/wizardly_app_generator.rb:
--------------------------------------------------------------------------------
1 | #require 'wizardly'
2 |
3 | class WizardlyAppGenerator < Rails::Generator::Base
4 |
5 | def initialize(runtime_args, runtime_options = {})
6 | super
7 | end
8 |
9 | def manifest
10 | record do |m|
11 | m.directory "lib/tasks"
12 |
13 | m.file "wizardly.rake", "lib/tasks/wizardly.rake"
14 |
15 | end
16 | end
17 |
18 | def controller_class_name
19 | "#{controller_name.camelize}Controller"
20 | end
21 | def model_class_name
22 | "#{model_name.camelize}"
23 | end
24 | def action_methods
25 | @wizard_config.print_page_action_methods
26 | end
27 | def callback_methods
28 | @wizard_config.print_callbacks
29 | end
30 | def helper_methods
31 | @wizard_config.print_helpers
32 | end
33 |
34 | protected
35 | # Override with your own usage banner.
36 | def banner
37 | "Usage: #{$0} wizardly_app"
38 | end
39 |
40 |
41 | end
42 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_controller/USAGE:
--------------------------------------------------------------------------------
1 | Generates a wizard controller with all the code displayed
2 |
3 |
4 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_controller/templates/controller.rb.erb:
--------------------------------------------------------------------------------
1 | #
2 | # <%= controller_class_name %> class generated by wizardly_controller
3 | #
4 |
5 | class <%= controller_class_name %> < ApplicationController
6 | before_filter :guard_entry
7 |
8 | <%= action_methods %>
9 |
10 | <%= callback_methods %>
11 |
12 | <%= helper_methods %>
13 |
14 | <%= callback_macro_methods %>
15 |
16 | public
17 | def wizard_config; self.class.wizard_config; end
18 | hide_action :wizard_config
19 |
20 | private
21 |
22 | def self.wizard_config; @wizard_config; end
23 | @wizard_config = Wizardly::Wizard::Configuration.create(:<%=controller_name %>, :<%=model_name %>, :allow_skip=>true) do
24 | <%= "when_completed_redirect_to #{Wizardly::Wizard::Utils.formatted_redirect(completed_redirect)}" if completed_redirect %>
25 | <%= "when_canceled_redirect_to #{Wizardly::Wizard::Utils.formatted_redirect(canceled_redirect)}" if canceled_redirect %>
26 |
27 | # other things you can configure
28 | # change_button(:next).to('Next One')
29 | # change_button(:back).to('Previous')
30 | # create_button('Help')
31 | # set_page(:init).buttons_to :next_one, :previous, :cancel, :help #this removes skip
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_controller/templates/helper.rb.erb:
--------------------------------------------------------------------------------
1 | module <%=controller_name.camelize %>Helper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_controller/wizardly_controller_generator.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 |
3 | class WizardlyControllerGenerator < Rails::Generator::Base
4 | attr_reader :controller_name, :model_name, :completed_redirect, :canceled_redirect
5 |
6 | def initialize(runtime_args, runtime_options = {})
7 | super
8 | @controller_name = @args[0].sub(/^:/,'')
9 | @model_name = @args[1].sub(/^:/, '').underscore
10 | @completed_redirect = @args[2]
11 | @canceled_redirect = @args[3]
12 | opts = {}
13 | opts[:completed] = @completed_redirect if @completed_redirect
14 | opts[:canceled] = @canceled_redirect if @canceled_redirect
15 |
16 | @wizard_config = Wizardly::Wizard::Configuration.new(@controller_name, opts)
17 | @wizard_config.inspect_model!(@model_name.to_sym)
18 | end
19 |
20 | def manifest
21 | record do |m|
22 | m.directory "app/controllers"
23 |
24 | m.template "controller.rb.erb", "app/controllers/#{controller_name}_controller.rb"
25 |
26 | m.template "helper.rb.erb", "app/helpers/#{controller_name}_helper.rb"
27 |
28 | end
29 | end
30 |
31 | def controller_class_name
32 | "#{controller_name.camelize}Controller"
33 | end
34 | def model_class_name
35 | "#{model_name.camelize}"
36 | end
37 | def action_methods
38 | @wizard_config.print_page_action_methods
39 | end
40 | def callback_methods
41 | @wizard_config.print_callbacks
42 | end
43 | def helper_methods
44 | @wizard_config.print_helpers
45 | end
46 | def callback_macro_methods
47 | @wizard_config.print_callback_macros
48 | end
49 |
50 | protected
51 | # Override with your own usage banner.
52 | def banner
53 | "Usage: #{$0} wizardly_controller controller_name model_name [completed_redirect canceled_redirect]"
54 | end
55 |
56 |
57 | end
58 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/USAGE:
--------------------------------------------------------------------------------
1 | Generates a wizard scaffold from a wizard controller using wizard_for_model (or wizard_for)
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/form.html.erb:
--------------------------------------------------------------------------------
1 | <%= page.title %>
2 |
3 | <%= "#{page.description}
" if !page.description.blank? %>
4 | <%%= "
#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <%% form_for :<%= model_name %>, :url=>{:action=>:<%= page.name %>} do |f| %>
7 | <%%= f.error_messages %>
8 |
9 | <% for field in page.fields -%>
10 | <% first_field_id ||= "#{model_name}_#{field.name}" %>
11 |
12 | <%%= f.label :<%= field.name %> %>
13 | <%%= f.<%= field.field_type %> :<%= field.name %> %>
14 |
15 | <% end -%>
16 |
17 | <%%= <%= submit_tag %> %>
18 |
19 | <%% end %>
20 |
21 |
24 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/form.html.haml.erb:
--------------------------------------------------------------------------------
1 | %h1 <%= page.title %>
2 |
3 | <% unless page.description.blank? %>
4 | %p <%= page.description %>
5 | <% end %>
6 | - if flash[:notice]
7 | %p{:style=>'color: green'}= flash[:notice]
8 |
9 | - form_for :<%= model_name %>, :url=>{:action=>:<%= page.name %>} do |f|
10 | = f.error_messages
11 |
12 | <% for field in page.fields %>
13 | <% first_field_id ||= "#{model_name}_#{field.name}" %>
14 | %p
15 | = f.label :<%= field.name %>
16 | %br
17 | = f.<%= field.field_type %> :<%= field.name %>
18 | <% end %>
19 | %p= <%= submit_tag %>
20 |
21 | %script{:type=>'text/javascript'}
22 | document.getElementById('<%=first_field_id %>').focus()
23 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/helper.rb.erb:
--------------------------------------------------------------------------------
1 | module <%=controller_name.camelize %>Helper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | step_id = "#{controller_name}_#{@step}".to_sym
6 | unless @@wizardly_submit[step_id]
7 | buttons = @wizard.pages[@step].buttons
8 | @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
9 | io << submit_tag(button.name, :name=>button.id.to_s)
10 | end.string
11 | end
12 | @@wizardly_submit[step_id]
13 | end
14 |
15 | def wizardly_image_submit(asset_dir = nil, opts = {})
16 | @@wizardly_image_submit ||={}
17 | step_id = "#{controller_name}_#{@step}".to_sym
18 | unless @@wizardly_image_submit[step_id]
19 | asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
20 | buttons = @wizard.pages[@step].buttons
21 | @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
22 | opts[:value] = button.name
23 | opts[:name] = button.id.to_s
24 | io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
25 | end.string
26 | end
27 | @@wizardly_image_submit[step_id]
28 | end
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/images/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/templates/images/back.png
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/images/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/templates/images/cancel.png
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/images/finish.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/templates/images/finish.png
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/images/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/templates/images/next.png
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/images/skip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/templates/images/skip.png
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/layout.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | <%= controller_class_name %>: <%%= controller.action_name %>
8 | <%%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/layout.html.haml.erb:
--------------------------------------------------------------------------------
1 | !!! XML
2 | !!!
3 | %html{ :'xml:lang' => "en", :lang => "en" }
4 | %head
5 | %title= "<%=controller_class_name %>: " + controller.action_name
6 | %meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset-utf-8" }
7 | %link{ :rel => "shortcut icon", :href => "/favicon.ico" }
8 | = stylesheet_link_tag "scaffold", :media => "screen"
9 | %body
10 | = yield
11 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/templates/style.css:
--------------------------------------------------------------------------------
1 | body { background-color: #fff; color: #333; }
2 |
3 | body, p, ol, ul, td {
4 | font-family: verdana, arial, helvetica, sans-serif;
5 | font-size: 13px;
6 | line-height: 18px;
7 | }
8 |
9 | pre {
10 | background-color: #eee;
11 | padding: 10px;
12 | font-size: 11px;
13 | }
14 |
15 | a { color: #000; }
16 | a:visited { color: #666; }
17 | a:hover { color: #fff; background-color:#000; }
18 |
19 | .fieldWithErrors {
20 | padding: 2px;
21 | background-color: red;
22 | display: table;
23 | }
24 |
25 | #errorExplanation {
26 | width: 400px;
27 | border: 2px solid red;
28 | padding: 7px;
29 | padding-bottom: 12px;
30 | margin-bottom: 20px;
31 | background-color: #f0f0f0;
32 | }
33 |
34 | #errorExplanation h2 {
35 | text-align: left;
36 | font-weight: bold;
37 | padding: 5px 5px 5px 15px;
38 | font-size: 12px;
39 | margin: -7px;
40 | background-color: #c00;
41 | color: #fff;
42 | }
43 |
44 | #errorExplanation p {
45 | color: #333;
46 | margin-bottom: 0;
47 | padding: 5px;
48 | }
49 |
50 | #errorExplanation ul li {
51 | font-size: 12px;
52 | list-style: square;
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/lib/generators/wizardly_scaffold/wizardly_scaffold_generator.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 |
3 | class WizardlyScaffoldGenerator < Rails::Generator::Base
4 | attr_reader :wizard_config, :pages, :submit_tag
5 | attr_reader :controller_name,
6 | :controller_class_path,
7 | :controller_file_path,
8 | :controller_class_nesting,
9 | :controller_class_nesting_depth,
10 | :controller_class_name,
11 | :controller_underscore_name
12 | attr_reader :model_name, :view_file_ext
13 |
14 | alias_method :controller_file_name, :controller_underscore_name
15 |
16 | def add_options!(opt)
17 | opt.on('--haml', 'Generate scaffold for haml wizard') { |v| options[:output] = :haml }
18 | opt.on('--ajax', 'Generate scaffold for ajax wizard') { |v| options[:output] = :ajax }
19 | opt.on('--underscore', 'Append an underscore to front of each file') { |v| options[:underscore] = true }
20 | opt.on('--image_submit', 'Use image submit tags in forms') {|v| options[:image_submit] = true }
21 | end
22 |
23 |
24 | def initialize(runtime_args, runtime_options = {})
25 | super
26 | name = @args[0].sub(/^:/, '').underscore.sub(/_controller$/, '').camelize + 'Controller'
27 |
28 | base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(name)
29 | @controller_class_name_without_nesting = base_name.camelize
30 | @controller_underscore_name = base_name.underscore
31 | @controller_name = @controller_underscore_name.sub(/_controller$/, '')
32 | if @controller_class_nesting.empty?
33 | @controller_class_name = @controller_class_name_without_nesting
34 | else
35 | @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
36 | end
37 |
38 | begin
39 | @controller_class = @controller_class_name.constantize
40 | rescue Exception => e
41 | raise Wizardly::WizardlyScaffoldError, "No controller #{@controller_class_name} found: " + e.message, caller
42 | end
43 | begin
44 | @wizard_config = @controller_class.wizard_config
45 | rescue Exception => e
46 | raise Wizardly::WizardlyScaffoldError, "#{@controller_class_name} must contain a valid 'act_wizardly_for' or 'wizard_for_model' macro: " + e.message, caller
47 | end
48 |
49 | @pages = @wizard_config.pages
50 | @model_name = @wizard_config.model
51 | @submit_tag = options[:image_submit] ? "wizardly_image_submit" : "wizardly_submit"
52 |
53 | #based on options, default is --html, others --ajax, --haml
54 | @view_file_ext = ["html.erb", "html.erb"]
55 | @view_file_ext = ["html.haml.erb", "html.haml"] if options[:output] == :haml
56 | #ajax
57 | end
58 |
59 | def manifest
60 | record do |m|
61 | # Helper, views, test and stylesheets directories.
62 | m.directory(File.join('app/helpers', controller_class_path))
63 | m.directory(File.join('app/views', controller_class_path, controller_name))
64 | m.directory(File.join('app/views/layouts', controller_class_path))
65 | m.directory('public/images/wizardly') if options[:image_submit]
66 | #m.directory(File.join('test/functional', controller_class_path))
67 | #m.directory(File.join('public/stylesheets', class_path))
68 |
69 | underscore = options[:underscore] ? '_' : ''
70 | pages.each do |id, page|
71 | m.template(
72 | "form.#{view_file_ext.first}",
73 | File.join('app/views', controller_class_path, controller_name, "#{underscore}#{id}.#{view_file_ext.last}"),
74 | :assigns=>{:id=>id, :page=>page}
75 | )
76 | end
77 |
78 | if options[:image_submit]
79 | %w(next skip back cancel finish).each do |fn|
80 | m.file("images/#{fn}.png", "public/images/wizardly/#{fn}.png")
81 | end
82 | end
83 |
84 | m.template("helper.rb.erb", File.join('app/helpers', controller_class_path, "#{controller_name}_helper.rb"))
85 |
86 | # Layout and stylesheet.
87 | m.template("layout.#{view_file_ext.first}", File.join('app/views/layouts', controller_class_path, "#{controller_name}.#{view_file_ext.last}"))
88 | m.template('style.css', 'public/stylesheets/scaffold.css')
89 |
90 | #m.dependency 'model', [name] + @args, :collision => :skip
91 | end
92 | end
93 |
94 | protected
95 | def banner
96 | "Usage: #{$0} wizardly_scaffold controller_name --ajax --haml"
97 | end
98 |
99 | def extract_modules(name)
100 | modules = name.include?('/') ? name.split('/') : name.split('::')
101 | name = modules.pop
102 | path = modules.map { |m| m.underscore }
103 | file_path = (path + [name.underscore]).join('/')
104 | nesting = modules.map { |m| m.camelize }.join('::')
105 | [name, path, file_path, nesting, modules.size]
106 | end
107 |
108 |
109 | end
110 |
--------------------------------------------------------------------------------
/lib/jeffp-wizardly.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
--------------------------------------------------------------------------------
/lib/validation_group.rb:
--------------------------------------------------------------------------------
1 | module ValidationGroup
2 | module ActiveRecord
3 | module ActsMethods # extends ActiveRecord::Base
4 | def self.extended(base)
5 | # Add class accessor which is shared between all models and stores
6 | # validation groups defined for each model
7 | base.class_eval do
8 | cattr_accessor :validation_group_classes
9 | self.validation_group_classes = {}
10 |
11 | def self.validation_group_order; @validation_group_order; end
12 | def self.validation_groups(all_classes = false)
13 | return (self.validation_group_classes[self] || {}) unless all_classes
14 | klasses = ValidationGroup::Util.current_and_ancestors(self).reverse
15 | returning Hash.new do |hash|
16 | klasses.each do |klass|
17 | hash.merge! self.validation_group_classes[klass]
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
24 | def validation_group(name, options={})
25 | self_groups = (self.validation_group_classes[self] ||= {})
26 | self_groups[name.to_sym] = case options[:fields]
27 | when Array then options[:fields]
28 | when Symbol, String then [options[:fields].to_sym]
29 | else []
30 | end
31 | # jeffp: capture the declaration order for this class only (no
32 | # superclasses)
33 | (@validation_group_order ||= []) << name.to_sym
34 |
35 | unless included_modules.include?(InstanceMethods)
36 | # jeffp: added reader for current_validation_fields
37 | attr_reader :current_validation_group, :current_validation_fields
38 | include InstanceMethods
39 | # jeffp: add valid?(group = nil), see definition below
40 | alias_method_chain :valid?, :validation_group
41 | end
42 | end
43 | end
44 |
45 | module InstanceMethods # included in every model which calls validation_group
46 | #needs testing
47 | # def reset_fields_for_validation_group(group)
48 | # group_classes = self.class.validation_group_classes
49 | # found = ValidationGroup::Util.current_and_ancestors(self.class).find do |klass|
50 | # group_classes[klass] && group_classes[klass].include?(group)
51 | # end
52 | # if found
53 | # group_classes[found][group].each do |field|
54 | # self[field] = nil
55 | # end
56 | # end
57 | # end
58 | def enable_validation_group(group)
59 | # Check if given validation group is defined for current class or one of
60 | # its ancestors
61 | group_classes = self.class.validation_group_classes
62 | found = ValidationGroup::Util.current_and_ancestors(self.class).
63 | find do |klass|
64 | group_classes[klass] && group_classes[klass].include?(group)
65 | end
66 | if found
67 | @current_validation_group = group
68 | # jeffp: capture current fields for performance optimization
69 | @current_validation_fields = group_classes[found][group]
70 | else
71 | raise ArgumentError, "No validation group of name :#{group}"
72 | end
73 | end
74 |
75 | def disable_validation_group
76 | @current_validation_group = nil
77 | # jeffp: delete fields
78 | @current_validation_fields = nil
79 | end
80 |
81 | def reject_non_validation_group_errors
82 | return unless validation_group_enabled?
83 | self.errors.remove_on(@current_validation_fields)
84 | end
85 |
86 | # jeffp: optimizer for someone writing custom :validate method -- no need
87 | # to validate fields outside the current validation group note: could also
88 | # use in validation modules to improve performance
89 | def should_validate?(attribute)
90 | !self.validation_group_enabled? || (@current_validation_fields && @current_validation_fields.include?(attribute.to_sym))
91 | end
92 |
93 | def validation_group_enabled?
94 | respond_to?(:current_validation_group) && !current_validation_group.nil?
95 | end
96 |
97 | # eliminates need to use :enable_validation_group before :valid? call --
98 | # nice
99 | def valid_with_validation_group?(group=nil)
100 | self.enable_validation_group(group) if group
101 | valid_without_validation_group?
102 | end
103 | end
104 |
105 | module Errors # included in ActiveRecord::Errors
106 | def add_with_validation_group(attribute,
107 | msg = @@default_error_messages[:invalid], *args,
108 | &block)
109 | # jeffp: setting @current_validation_fields and use of should_validate? optimizes code
110 | add_error = @base.respond_to?(:should_validate?) ? @base.should_validate?(attribute.to_sym) : true
111 | add_without_validation_group(attribute, msg, *args, &block) if add_error
112 | end
113 |
114 | def remove_on(attributes)
115 | return unless attributes
116 | attributes = [attributes] unless attributes.is_a?(Array)
117 | @errors.reject!{|k,v| !attributes.include?(k.to_sym)}
118 | end
119 |
120 | def self.included(base) #:nodoc:
121 | base.class_eval do
122 | alias_method_chain :add, :validation_group
123 | end
124 | end
125 | end
126 | end
127 |
128 | module Util
129 | # Return array consisting of current and its superclasses down to and
130 | # including base_class.
131 | def self.current_and_ancestors(current)
132 | returning [] do |klasses|
133 | klasses << current
134 | root = current.base_class
135 | until current == root
136 | current = current.superclass
137 | klasses << current
138 | end
139 | end
140 | end
141 | end
142 | end
143 |
144 | # jeffp: moved from init.rb for gemification purposes --
145 | # require 'validation_group' loads everything now, init.rb requires 'validation_group' only
146 | ActiveRecord::Base.send(:extend, ValidationGroup::ActiveRecord::ActsMethods)
147 | ActiveRecord::Errors.send :include, ValidationGroup::ActiveRecord::Errors
148 |
--------------------------------------------------------------------------------
/lib/wizardly.rb:
--------------------------------------------------------------------------------
1 | require 'validation_group'
2 | require 'wizardly/action_controller'
3 |
4 | module Wizardly
5 | module ActionController
6 | module MacroMethods
7 | def wizard_for_model(model, opts={}, &block)
8 | include Wizardly::ActionController
9 | #check for validation group gem
10 | configure_wizard_for_model(model, opts, &block)
11 | end
12 | alias_method :act_wizardly_for, :wizard_for_model
13 | end
14 | end
15 | end
16 |
17 | begin
18 | ActiveRecord::Base.class_eval do
19 | class << self
20 | alias_method :wizardly_page, :validation_group
21 | end
22 | end
23 | rescue
24 | end
25 |
26 | ActionController::Base.send(:extend, Wizardly::ActionController::MacroMethods)
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/lib/wizardly/action_controller.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly/wizard'
2 |
3 | module Wizardly
4 | module ActionController
5 | def self.included(base)
6 | base.extend(ClassMethods)
7 |
8 | base.class_eval do
9 | before_filter :guard_entry
10 | class << self
11 | attr_reader :wizard_config #note: reader for @wizard_config on the class (not the instance)
12 | end
13 | hide_action :reset_wizard_session_vars, :wizard_config, :methodize_button_name
14 | end
15 | end
16 |
17 | module ClassMethods
18 | private
19 | def configure_wizard_for_model(model, opts={}, &block)
20 |
21 | # controller_name = self.name.sub(/Controller$/, '').underscore.to_sym
22 | @wizard_config = Wizardly::Wizard::Configuration.create(controller_name, model, opts, &block)
23 | # define methods
24 | self.class_eval @wizard_config.print_page_action_methods
25 | self.class_eval @wizard_config.print_callbacks
26 | self.class_eval @wizard_config.print_helpers
27 | self.class_eval @wizard_config.print_callback_macros
28 | end
29 | end
30 |
31 | # instance methods for controller
32 | public
33 | def wizard_config; self.class.wizard_config; end
34 |
35 | end
36 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly/wizard/configuration'
2 |
3 | module Wizardly
4 | class WizardlyError < StandardError; end
5 | class ModelNotFoundError < WizardlyError; end
6 | class ValidationGroupError < WizardlyError; end
7 | class CallbackError < WizardlyError; end
8 | class MissingCallbackError < WizardlyError; end
9 | class WizardConfigurationError < WizardlyError; end
10 | class RedirectNotDefinedError < WizardlyError; end
11 |
12 | class WizardlyGeneratorError < WizardlyError; end
13 | class WizardlyScaffoldError < WizardlyGeneratorError; end
14 | class WizardlyControllerGeneratorError < WizardlyGeneratorError; end
15 |
16 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard/button.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly/wizard/text_helpers'
2 |
3 | module Wizardly
4 | module Wizard
5 | class Button
6 | include TextHelpers
7 | attr_reader :name
8 | attr_reader :id
9 |
10 | def initialize(id, name=nil)
11 | @id = id
12 | @name = name || symbol_to_button_name(id)
13 | @user_defined = false
14 | end
15 |
16 | def user_defined?; @user_defined; end
17 |
18 | #used in the dsl
19 | def name_to(name, opts={})
20 | case name
21 | when String then @name = name.strip.squeeze(' ')
22 | when Symbol then @name = symbol_to_button_name(name)
23 | end
24 | @id = opts[:id] if (opts[:id] && opts[:id].is_a?(Symbol))
25 | end
26 | end
27 |
28 | class UserDefinedButton < Button
29 | def initialize(id, name=nil)
30 | super
31 | @user_defined = true
32 | end
33 | end
34 | end
35 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard/configuration.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly/wizard/utils'
2 | require 'wizardly/wizard/dsl'
3 | require 'wizardly/wizard/button'
4 | require 'wizardly/wizard/page'
5 | require 'wizardly/wizard/configuration/methods'
6 |
7 | module Wizardly
8 | module Wizard
9 | class Configuration
10 | include TextHelpers
11 | attr_reader :pages, :completed_redirect, :canceled_redirect, :controller_path, :controller_class_name, :controller_name, :page_order
12 |
13 | #enum_attr :persistance, %w(sandbox session database)
14 |
15 | def initialize(controller, opts) #completed_redirect = nil, canceled_redirect = nil)
16 | @controller_class_name = controller.to_s.camelcase
17 | @controller_class_name += 'Controller' unless @controller_class_name =~ /Controller$/
18 | @controller_path = @controller_class_name.sub(/Controller$/,'').underscore
19 | @controller_name = @controller_class_name.demodulize.sub(/Controller$/,'').underscore
20 | @completed_redirect = opts[:completed] || opts[:when_completed] || opts[:redirect] #format_redirect(completed_redirect)
21 | @canceled_redirect = opts[:canceled] || opts[:when_canceled] || opts[:redirect]
22 | @include_skip_button = opts[:skip] || opts[:allow_skip] || opts[:allow_skipping] || false
23 | @include_cancel_button = opts.key?(:cancel) ? opts[:cancel] : true
24 | @guard_entry = opts.key?(:guard) ? opts[:guard] : true
25 | @password_fields = opts[:mask_fields] || opts[:mask_passwords] || [:password, :password_confirmation]
26 | @persist_model = opts[:persist_model] || :per_page
27 | @form_data = opts[:form_data] || :session
28 | raise(ArgumentError, ":persist_model option must be one of :once or :per_page", caller) unless [:once, :per_page].include?(@persist_model)
29 | raise(ArgumentError, ":form_data option must be one of :sandbox or :session", caller) unless [:sandbox, :session].include?(@form_data)
30 | @page_order = []
31 | @pages = {}
32 | @buttons = nil
33 | @default_buttons = Hash[*[:next, :back, :cancel, :finish, :skip].collect {|default| [default, Button.new(default)] }.flatten]
34 | end
35 |
36 | def guard?; @guard_entry; end
37 | def persist_model_per_page?; @persist_model == :per_page; end
38 | def form_data_keep_in_session?; @form_data == :session; end
39 | def model; @wizard_model_sym; end
40 | def model_instance_variable; "@#{@wizard_model_sym.to_s}"; end
41 | def model_class_name; @wizard_model_class_name; end
42 | def model_const; @wizard_model_const; end
43 |
44 | def first_page?(name); @page_order.first == name; end
45 | def last_page?(name); @page_order.last == name; end
46 | def next_page(name)
47 | index = @page_order.index(name)
48 | index += 1 unless self.last_page?(name)
49 | @page_order[index]
50 | end
51 | def previous_page(name)
52 | index = @page_order.index(name)
53 | index -= 1 unless self.first_page?(name)
54 | @page_order[index]
55 | end
56 | def button_for_function(name); @default_buttons[name]; end
57 | def buttons
58 | return @buttons if @buttons
59 | # reduce buttons
60 | @buttons = Hash[*@default_buttons.collect{|k,v|[v.id, v]}.flatten]
61 | end
62 |
63 | def self.create(controller_name, model_name, opts={}, &block)
64 | # controller_name = controller_name.to_s.underscore.sub(/_controller$/, '').to_sym
65 | model_name = model_name.to_s.underscore.to_sym
66 | config = Wizardly::Wizard::Configuration.new(controller_name, opts)
67 | config.inspect_model!(model_name)
68 | Wizardly::Wizard::DSL.new(config).instance_eval(&block) if block_given?
69 | config
70 | end
71 |
72 |
73 | def inspect_model!(model)
74 | # first examine the model symbol, transform and see if the constant
75 | # exists
76 | begin
77 | @wizard_model_sym = model.to_sym
78 | @wizard_model_class_name = model.to_s.camelize
79 | @wizard_model_const = @wizard_model_class_name.constantize
80 | rescue Exception=>e
81 | raise ModelNotFoundError, "Cannot convert :#{@wizard_model_sym} to model constant for #{@wizard_model_class_name}: " + e.message, caller
82 | end
83 |
84 | begin
85 | @page_order = @wizard_model_const.validation_group_order
86 | rescue Exception => e
87 | raise ValidationGroupError, "Unable to read validation groups from #{@wizard_model_class_name}: " + e.message, caller
88 | end
89 | raise(ValidationGroupError, "No validation groups defined for model #{@wizard_model_class_name}", caller) unless (@page_order && !@page_order.empty?)
90 |
91 | begin
92 | groups = @wizard_model_const.validation_groups
93 | enum_attrs = @wizard_model_const.respond_to?(:enumerated_attributes) ? @wizard_model_const.enumerated_attributes.collect {|k,v| k } : []
94 | model_inst = @wizard_model_const.new
95 | last_index = @page_order.size-1
96 | @page_order.each_with_index do |p, index|
97 | fields = groups[p].map do |f|
98 | column = model_inst.column_for_attribute(f)
99 | type = case
100 | when enum_attrs.include?(f) then :enum
101 | when (@password_fields && @password_fields.include?(f)) then :password
102 | else
103 | column ? column.type : :string
104 | end
105 | PageField.new(f, type)
106 | end
107 | page = Page.new(self, p, fields)
108 |
109 | # default button settings based on order, can be altered by
110 | # set_page(@id).buttons_to []
111 | buttons = []
112 | buttons << @default_buttons[:next] unless index >= last_index
113 | buttons << @default_buttons[:finish] if index == last_index
114 | buttons << @default_buttons[:back] unless index == 0
115 | buttons << @default_buttons[:skip] if (@include_skip_button && index != last_index)
116 | buttons << @default_buttons[:cancel] if (@include_cancel_button)
117 | page.buttons = buttons
118 | @pages[page.id] = page
119 | end
120 | rescue Exception => e
121 | raise ValidationGroupError, "Failed to configure wizard from #{@wizard_model_class_name} validation groups: " + e.message, caller
122 | end
123 | end
124 |
125 | public
126 | # internal DSL method handlers
127 | def _when_completed_redirect_to(redir); @completed_redirect = redir; end
128 | def _when_canceled_redirect_to(redir); @canceled_redirect = redir; end
129 | def _change_button(name)
130 | raise(WizardConfigurationError, "Button :#{name} in _change_button() call does not exist", caller) unless self.buttons.key?(name)
131 | _buttons = self.buttons
132 | @buttons = nil # clear the buttons for regeneration after change in next line
133 | _buttons[name]
134 | end
135 | def _create_button(name, opts)
136 | id = opts[:id] || button_name_to_symbol(name)
137 | raise(WizardConfigurationError, "Button '#{name}' with id :#{id} cannot be created. The ID already exists.", caller) if self.buttons.key?(id)
138 | @buttons=nil
139 | @default_buttons[id] = UserDefinedButton.new(id, name)
140 | end
141 | def _set_page(name); @pages[name]; end
142 | def _mask_passwords(passwords)
143 | case passwords
144 | when String
145 | passwords = [passwords.to_sym]
146 | when Symbol
147 | passwords = [passwords]
148 | when Array
149 | else
150 | raise(WizardlyConfigurationError, "mask_passwords method only accepts string, symbol or array of password fields")
151 | end
152 | @password_fields.push(*passwords).uniq!
153 | end
154 |
155 | def print_config
156 | io = StringIO.new
157 | class_name = controller_name.to_s.camelize
158 | class_name += 'Controller' unless class_name =~ /Controller$/
159 | io.puts "#{class_name} wizard configuration"
160 | io.puts
161 | io.puts "model: #{model_class_name}"
162 | io.puts "instance: @#{model}"
163 | io.puts
164 | io.puts "pages:"
165 | self.page_order.each do |pid|
166 | page = pages[pid]
167 | # io.puts " #{index+1}. '#{page.title}' page (:#{page.id}) has"
168 | io.puts " '#{page.title}' page (:#{page.id}) has"
169 | io.puts " --fields: #{page.fields.inject([]){|a, f| a << '"'+f.name.to_s.titleize+'" [:'+f.column_type.to_s+']'}.join(', ')}"
170 | io.puts " --buttons: #{page.buttons.inject([]){|a, b| a << b.name.to_s }.join(', ')}"
171 | end
172 | io.puts
173 | io.puts "redirects:"
174 | io.puts " when completed: #{completed_redirect ? completed_redirect.inspect : 'redirects to initial referer by default (specify :completed=>url to override)'}"
175 | io.puts " when canceled: #{canceled_redirect ? canceled_redirect.inspect : 'redirects to initial referer by default (specify :canceled=>url to override)'}"
176 | io.puts
177 | io.puts "buttons:"
178 | self.buttons.each do |k, b|
179 | bs = StringIO.new
180 | bs << " #{b.name} (:#{b.id}) "
181 | if (b.user_defined?)
182 | bs << "-- user defined button and function"
183 | else
184 | dk = @default_buttons.index(b)
185 | bs << "-- used for internal <#{dk}> functionality"
186 | end
187 | io.puts bs.string
188 | end
189 | io.puts
190 | io.string
191 | end
192 | end
193 | end
194 | end
195 |
--------------------------------------------------------------------------------
/lib/wizardly/wizard/dsl.rb:
--------------------------------------------------------------------------------
1 | module Wizardly
2 | module Wizard
3 | class DSL
4 |
5 | def initialize(config)
6 | @config = config
7 | end
8 |
9 | # DSL methods
10 | def when_completed_redirect_to(redir); @config._when_completed_redirect_to(redir); end
11 | def when_canceled_redirect_to(redir); @config._when_canceled_redirect_to(redir); end
12 | def change_button(name)
13 | @config._change_button(name)
14 | end
15 | def create_button(name, opts)
16 | @config._create_button(name, opts)
17 | end
18 | def set_page(name);
19 | @config._set_page(name)
20 | end
21 | def mask_passwords(passwords)
22 | @config._mask_passwords(passwords)
23 | end
24 | alias_method :mask_password, :mask_passwords
25 | end
26 | end
27 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard/page.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly/wizard/text_helpers'
2 |
3 | module Wizardly
4 | module Wizard
5 | class Page
6 | include TextHelpers
7 |
8 | attr_reader :id, :title, :description
9 | attr_accessor :buttons, :fields
10 |
11 | def initialize(config, id, fields)
12 | @buttons = []
13 | @title = symbol_to_button_name(id)
14 | @id = id
15 | @description = ''
16 | @fields = fields
17 | @config = config
18 | end
19 |
20 | def name; id.to_s; end
21 |
22 | def buttons_to(*args)
23 | buttons = @config.buttons
24 | @buttons = args.map do |button_id|
25 | raise(WizardConfigurationError, ":#{button_id} not defined as a button id in :button_to() call", caller) unless buttons.key?(button_id)
26 | buttons[button_id]
27 | end
28 | end
29 | def title_to(name)
30 | @title = name.strip.squeeze(' ')
31 | end
32 | def description_to(name)
33 | @description = name.strip.squeeze(' ')
34 | end
35 | end
36 |
37 | class PageField
38 | attr_reader :name, :column_type
39 |
40 | def initialize(name, type)
41 | @name = name
42 | @column_type = type.to_sym
43 | @field_type = nil
44 | end
45 |
46 | def field_type
47 | @field_type ||= case @column_type
48 | when :string then :text_field
49 | when :password then :password_field
50 | when :enum then :enum_select
51 | when :text then :text_area
52 | when :boolean then :check_box
53 | when :integer, :float, :decimal then :text_field
54 | when :datetime, :timestamp, :time then :datetime_select
55 | when :date then :date_select
56 | else
57 | :text_field
58 | end
59 | end
60 | end
61 | end
62 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard/text_helpers.rb:
--------------------------------------------------------------------------------
1 | module Wizardly
2 | module Wizard
3 | module TextHelpers
4 | private
5 | def underscore_button_name(name)
6 | name.to_s.strip.squeeze(' ').gsub(/ /, '_').downcase
7 | end
8 | def button_name_to_symbol(str)
9 | underscore_button_name(str).to_sym
10 | end
11 | def symbol_to_button_name(sym)
12 | sym.to_s.gsub(/_/, ' ').squeeze(' ').titleize
13 | end
14 | end
15 | end
16 | end
--------------------------------------------------------------------------------
/lib/wizardly/wizard/utils.rb:
--------------------------------------------------------------------------------
1 | module Wizardly
2 | module Wizard
3 | module Utils
4 | def self.formatted_redirect(r)
5 | return(nil) unless r
6 | r.is_a?(Hash)? r : "'#{r}'"
7 | end
8 | end
9 | end
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/public/.gitignore:
--------------------------------------------------------------------------------
1 | system
2 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | The page you were looking for doesn't exist (404)
9 |
21 |
22 |
23 |
24 |
25 |
26 |
The page you were looking for doesn't exist.
27 |
You may have mistyped the address or the page may have moved.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | The change you wanted was rejected (422)
9 |
21 |
22 |
23 |
24 |
25 |
26 |
The change you wanted was rejected.
27 |
Maybe you tried to change something you didn't have access to.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | We're sorry, but something went wrong (500)
9 |
21 |
22 |
23 |
24 |
25 |
26 |
We're sorry, but something went wrong.
27 |
We've been notified about this issue and we'll take a look at it shortly.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/favicon.ico
--------------------------------------------------------------------------------
/public/images/avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/avatar.png
--------------------------------------------------------------------------------
/public/images/rails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/rails.png
--------------------------------------------------------------------------------
/public/images/wizardly/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/wizardly/back.png
--------------------------------------------------------------------------------
/public/images/wizardly/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/wizardly/cancel.png
--------------------------------------------------------------------------------
/public/images/wizardly/finish.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/wizardly/finish.png
--------------------------------------------------------------------------------
/public/images/wizardly/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/wizardly/next.png
--------------------------------------------------------------------------------
/public/images/wizardly/skip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/public/images/wizardly/skip.png
--------------------------------------------------------------------------------
/public/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // Place your application-specific JavaScript functions and classes here
2 | // This file is automatically included by javascript_include_tag :defaults
3 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/public/stylesheets/scaffold.css:
--------------------------------------------------------------------------------
1 | body { background-color: #fff; color: #333; }
2 |
3 | body, p, ol, ul, td {
4 | font-family: verdana, arial, helvetica, sans-serif;
5 | font-size: 13px;
6 | line-height: 18px;
7 | }
8 |
9 | pre {
10 | background-color: #eee;
11 | padding: 10px;
12 | font-size: 11px;
13 | }
14 |
15 | a { color: #000; }
16 | a:visited { color: #666; }
17 | a:hover { color: #fff; background-color:#000; }
18 |
19 | .fieldWithErrors {
20 | padding: 2px;
21 | background-color: red;
22 | display: table;
23 | }
24 |
25 | #errorExplanation {
26 | width: 400px;
27 | border: 2px solid red;
28 | padding: 7px;
29 | padding-bottom: 12px;
30 | margin-bottom: 20px;
31 | background-color: #f0f0f0;
32 | }
33 |
34 | #errorExplanation h2 {
35 | text-align: left;
36 | font-weight: bold;
37 | padding: 5px 5px 5px 15px;
38 | font-size: 12px;
39 | margin: -7px;
40 | background-color: #c00;
41 | color: #fff;
42 | }
43 |
44 | #errorExplanation p {
45 | color: #333;
46 | margin-bottom: 0;
47 | padding: 5px;
48 | }
49 |
50 | #errorExplanation ul li {
51 | font-size: 12px;
52 | list-style: square;
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_app/USAGE:
--------------------------------------------------------------------------------
1 | Prepares a rails application to use wizardly gem
2 |
3 | Moves the wizardly.rake file in to lib/tasks directory
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_app/templates/wizardly.rake:
--------------------------------------------------------------------------------
1 |
2 | namespace :wizardly do
3 | desc "Display wizard configuration details"
4 | task :config => :environment do
5 | name = ENV['name']
6 | return print_usage unless name
7 | begin
8 | name = name.strip.camelize
9 | name += 'Controller' unless name.match('Controller$')
10 | controller = name.constantize
11 | begin
12 | c = controller.wizard_config
13 | begin
14 | puts
15 | puts c.print_config
16 | rescue Exception=>e
17 | puts "Problem printing configuration."
18 | puts "#{e.class.name} -- #{e.message}"
19 | puts
20 | end
21 | rescue Exception=>e
22 | puts "{#{name}} is not a 'wizardly' controller.\nMake sure 'wizard_for_model' is defined in the controller class."
23 | puts "#{e.class.name} -- #{e.message}"
24 | puts
25 | end
26 | rescue Exception=>e
27 | puts "{#{name}} does not reference a controller class."
28 | puts "#{e.class.name} -- #{e.message}"
29 | puts
30 | end
31 | end
32 |
33 | def print_usage
34 | puts "Usage: rake wizardly:config name={controller_name}"
35 | puts
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_app/wizardly_app_generator.rb:
--------------------------------------------------------------------------------
1 | #require 'wizardly'
2 |
3 | class WizardlyAppGenerator < Rails::Generator::Base
4 |
5 | def initialize(runtime_args, runtime_options = {})
6 | super
7 | end
8 |
9 | def manifest
10 | record do |m|
11 | m.directory "lib/tasks"
12 |
13 | m.file "wizardly.rake", "lib/tasks/wizardly.rake"
14 |
15 | end
16 | end
17 |
18 | def controller_class_name
19 | "#{controller_name.camelize}Controller"
20 | end
21 | def model_class_name
22 | "#{model_name.camelize}"
23 | end
24 | def action_methods
25 | @wizard_config.print_page_action_methods
26 | end
27 | def callback_methods
28 | @wizard_config.print_callbacks
29 | end
30 | def helper_methods
31 | @wizard_config.print_helpers
32 | end
33 |
34 | protected
35 | # Override with your own usage banner.
36 | def banner
37 | "Usage: #{$0} wizardly_app"
38 | end
39 |
40 |
41 | end
42 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_controller/USAGE:
--------------------------------------------------------------------------------
1 | Generates a wizard controller with all the code displayed
2 |
3 |
4 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_controller/templates/controller.rb.erb:
--------------------------------------------------------------------------------
1 | #
2 | # <%= controller_class_name %> class generated by wizardly_controller
3 | #
4 |
5 | class <%= controller_class_name %> < ApplicationController
6 | before_filter :guard_entry
7 |
8 | <%= action_methods %>
9 |
10 | <%= callback_methods %>
11 |
12 | <%= helper_methods %>
13 |
14 | <%= callback_macro_methods %>
15 |
16 | public
17 | def wizard_config; self.class.wizard_config; end
18 | hide_action :wizard_config
19 |
20 | private
21 |
22 | def self.wizard_config; @wizard_config; end
23 | @wizard_config = Wizardly::Wizard::Configuration.create(:<%=controller_name %>, :<%=model_name %>, :allow_skip=>true) do
24 | <%= "when_completed_redirect_to #{Wizardly::Wizard::Utils.formatted_redirect(completed_redirect)}" if completed_redirect %>
25 | <%= "when_canceled_redirect_to #{Wizardly::Wizard::Utils.formatted_redirect(canceled_redirect)}" if canceled_redirect %>
26 |
27 | # other things you can configure
28 | # change_button(:next).to('Next One')
29 | # change_button(:back).to('Previous')
30 | # create_button('Help')
31 | # set_page(:init).buttons_to :next_one, :previous, :cancel, :help #this removes skip
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_controller/templates/helper.rb.erb:
--------------------------------------------------------------------------------
1 | module <%=controller_name.camelize %>Helper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | unless @@wizardly_submit[@step]
6 | buttons = @wizard.pages[@step].buttons
7 | @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button|
8 | io << submit_tag(button.name)
9 | end.string
10 | end
11 | @@wizardly_submit[@step]
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_controller/wizardly_controller_generator.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 |
3 | class WizardlyControllerGenerator < Rails::Generator::Base
4 | attr_reader :controller_name, :model_name, :completed_redirect, :canceled_redirect
5 |
6 | def initialize(runtime_args, runtime_options = {})
7 | super
8 | @controller_name = @args[0].sub(/^:/,'')
9 | @model_name = @args[1].sub(/^:/, '').underscore
10 | @completed_redirect = @args[2]
11 | @canceled_redirect = @args[3]
12 | opts = {}
13 | opts[:completed] = @completed_redirect if @completed_redirect
14 | opts[:canceled] = @canceled_redirect if @canceled_redirect
15 |
16 | @wizard_config = Wizardly::Wizard::Configuration.new(@controller_name, opts)
17 | @wizard_config.inspect_model!(@model_name.to_sym)
18 | end
19 |
20 | def manifest
21 | record do |m|
22 | m.directory "app/controllers"
23 |
24 | m.template "controller.rb.erb", "app/controllers/#{controller_name}_controller.rb"
25 |
26 | m.template "helper.rb.erb", "app/helpers/#{controller_name}_helper.rb"
27 |
28 | end
29 | end
30 |
31 | def controller_class_name
32 | "#{controller_name.camelize}Controller"
33 | end
34 | def model_class_name
35 | "#{model_name.camelize}"
36 | end
37 | def action_methods
38 | @wizard_config.print_page_action_methods
39 | end
40 | def callback_methods
41 | @wizard_config.print_callbacks
42 | end
43 | def helper_methods
44 | @wizard_config.print_helpers
45 | end
46 | def callback_macro_methods
47 | @wizard_config.print_callback_macros
48 | end
49 |
50 | protected
51 | # Override with your own usage banner.
52 | def banner
53 | "Usage: #{$0} wizardly_controller controller_name model_name [completed_redirect canceled_redirect]"
54 | end
55 |
56 |
57 | end
58 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/USAGE:
--------------------------------------------------------------------------------
1 | Generates a wizard scaffold from a wizard controller using wizard_for_model (or wizard_for)
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/form.html.erb:
--------------------------------------------------------------------------------
1 | <%= page.title %>
2 |
3 | <%= "#{page.description}
" if !page.description.blank? %>
4 | <%%= "
#{flash[:notice]}
" if flash[:notice] %>
5 |
6 | <%% form_for :<%= model_name %>, :url=>{:action=>:<%= page.name %>} do |f| %>
7 | <%%= f.error_messages %>
8 |
9 | <% for field in page.fields -%>
10 | <% first_field_id ||= "#{model_name}_#{field.name}" %>
11 |
12 | <%%= f.label :<%= field.name %> %>
13 | <%%= f.<%= field.field_type %> :<%= field.name %> %>
14 |
15 | <% end -%>
16 |
17 | <%%= <%= submit_tag %> %>
18 |
19 | <%% end %>
20 |
21 |
24 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/form.html.haml.erb:
--------------------------------------------------------------------------------
1 | %h1 <%= page.title %>
2 |
3 | <% unless page.description.blank? %>
4 | %p <%= page.description %>
5 | <% end %>
6 | - if flash[:notice]
7 | %p{:style=>'color: green'}= flash[:notice]
8 |
9 | - form_for :<%= model_name %>, :url=>{:action=>:<%= page.name %>} do |f|
10 | = f.error_messages
11 |
12 | <% for field in page.fields %>
13 | <% first_field_id ||= "#{model_name}_#{field.name}" %>
14 | %p
15 | = f.label :<%= field.name %>
16 | %br
17 | = f.<%= field.field_type %> :<%= field.name %>
18 | <% end %>
19 | %p= <%= submit_tag %>
20 |
21 | %script{:type=>'text/javascript'}
22 | document.getElementById('<%=first_field_id %>').focus()
23 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/helper.rb.erb:
--------------------------------------------------------------------------------
1 | module <%=controller_name.camelize %>Helper
2 |
3 | def wizardly_submit
4 | @@wizardly_submit ||= {}
5 | step_id = "#{controller_name}_#{@step}".to_sym
6 | unless @@wizardly_submit[step_id]
7 | buttons = @wizard.pages[@step].buttons
8 | @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
9 | io << submit_tag(button.name, :name=>button.id.to_s)
10 | end.string
11 | end
12 | @@wizardly_submit[step_id]
13 | end
14 |
15 | def wizardly_image_submit(asset_dir = nil, opts = {})
16 | @@wizardly_image_submit ||={}
17 | step_id = "#{controller_name}_#{@step}".to_sym
18 | unless @@wizardly_image_submit[step_id]
19 | asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
20 | buttons = @wizard.pages[@step].buttons
21 | @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
22 | opts[:value] = button.name
23 | opts[:name] = button.id.to_s
24 | io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
25 | end.string
26 | end
27 | @@wizardly_image_submit[step_id]
28 | end
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/images/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/templates/images/back.png
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/images/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/templates/images/cancel.png
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/images/finish.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/templates/images/finish.png
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/images/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/templates/images/next.png
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/images/skip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffp/wizardly/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/templates/images/skip.png
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/layout.html.erb:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | <%= controller_class_name %>: <%%= controller.action_name %>
8 | <%%= stylesheet_link_tag 'scaffold' %>
9 |
10 |
11 |
12 | <%%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/layout.html.haml.erb:
--------------------------------------------------------------------------------
1 | !!! XML
2 | !!!
3 | %html{ :'xml:lang' => "en", :lang => "en" }
4 | %head
5 | %title= "<%=controller_class_name %>: " + controller.action_name
6 | %meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset-utf-8" }
7 | %link{ :rel => "shortcut icon", :href => "/favicon.ico" }
8 | = stylesheet_link_tag "scaffold", :media => "screen"
9 | %body
10 | = yield
11 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/templates/style.css:
--------------------------------------------------------------------------------
1 | body { background-color: #fff; color: #333; }
2 |
3 | body, p, ol, ul, td {
4 | font-family: verdana, arial, helvetica, sans-serif;
5 | font-size: 13px;
6 | line-height: 18px;
7 | }
8 |
9 | pre {
10 | background-color: #eee;
11 | padding: 10px;
12 | font-size: 11px;
13 | }
14 |
15 | a { color: #000; }
16 | a:visited { color: #666; }
17 | a:hover { color: #fff; background-color:#000; }
18 |
19 | .fieldWithErrors {
20 | padding: 2px;
21 | background-color: red;
22 | display: table;
23 | }
24 |
25 | #errorExplanation {
26 | width: 400px;
27 | border: 2px solid red;
28 | padding: 7px;
29 | padding-bottom: 12px;
30 | margin-bottom: 20px;
31 | background-color: #f0f0f0;
32 | }
33 |
34 | #errorExplanation h2 {
35 | text-align: left;
36 | font-weight: bold;
37 | padding: 5px 5px 5px 15px;
38 | font-size: 12px;
39 | margin: -7px;
40 | background-color: #c00;
41 | color: #fff;
42 | }
43 |
44 | #errorExplanation p {
45 | color: #333;
46 | margin-bottom: 0;
47 | padding: 5px;
48 | }
49 |
50 | #errorExplanation ul li {
51 | font-size: 12px;
52 | list-style: square;
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb:
--------------------------------------------------------------------------------
1 | require 'wizardly'
2 |
3 | class WizardlyScaffoldGenerator < Rails::Generator::Base
4 | attr_reader :wizard_config, :pages, :submit_tag
5 | attr_reader :controller_name,
6 | :controller_class_path,
7 | :controller_file_path,
8 | :controller_class_nesting,
9 | :controller_class_nesting_depth,
10 | :controller_class_name,
11 | :controller_underscore_name
12 | attr_reader :model_name, :view_file_ext
13 |
14 | alias_method :controller_file_name, :controller_underscore_name
15 |
16 | def add_options!(opt)
17 | opt.on('--haml', 'Generate scaffold for haml wizard') { |v| options[:output] = :haml }
18 | opt.on('--ajax', 'Generate scaffold for ajax wizard') { |v| options[:output] = :ajax }
19 | opt.on('--underscore', 'Append an underscore to front of each file') { |v| options[:underscore] = true }
20 | opt.on('--image_submit', 'Use image submit tags in forms') {|v| options[:image_submit] = true }
21 | end
22 |
23 |
24 | def initialize(runtime_args, runtime_options = {})
25 | super
26 | name = @args[0].sub(/^:/, '').underscore.sub(/_controller$/, '').camelize + 'Controller'
27 |
28 | base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(name)
29 | @controller_class_name_without_nesting = base_name.camelize
30 | @controller_underscore_name = base_name.underscore
31 | @controller_name = @controller_underscore_name.sub(/_controller$/, '')
32 | if @controller_class_nesting.empty?
33 | @controller_class_name = @controller_class_name_without_nesting
34 | else
35 | @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
36 | end
37 |
38 | begin
39 | @controller_class = @controller_class_name.constantize
40 | rescue Exception => e
41 | raise Wizardly::WizardlyScaffoldError, "No controller #{@controller_class_name} found: " + e.message, caller
42 | end
43 | begin
44 | @wizard_config = @controller_class.wizard_config
45 | rescue Exception => e
46 | raise Wizardly::WizardlyScaffoldError, "#{@controller_class_name} must contain a valid 'act_wizardly_for' or 'wizard_for_model' macro: " + e.message, caller
47 | end
48 |
49 | @pages = @wizard_config.pages
50 | @model_name = @wizard_config.model
51 | @submit_tag = options[:image_submit] ? "wizardly_image_submit" : "wizardly_submit"
52 |
53 | #based on options, default is --html, others --ajax, --haml
54 | @view_file_ext = ["html.erb", "html.erb"]
55 | @view_file_ext = ["html.haml.erb", "html.haml"] if options[:output] == :haml
56 | #ajax
57 | end
58 |
59 | def manifest
60 | record do |m|
61 | # Helper, views, test and stylesheets directories.
62 | m.directory(File.join('app/helpers', controller_class_path))
63 | m.directory(File.join('app/views', controller_class_path, controller_name))
64 | m.directory(File.join('app/views/layouts', controller_class_path))
65 | m.directory('public/images/wizardly') if options[:image_submit]
66 | #m.directory(File.join('test/functional', controller_class_path))
67 | #m.directory(File.join('public/stylesheets', class_path))
68 |
69 | underscore = options[:underscore] ? '_' : ''
70 | pages.each do |id, page|
71 | m.template(
72 | "form.#{view_file_ext.first}",
73 | File.join('app/views', controller_class_path, controller_name, "#{underscore}#{id}.#{view_file_ext.last}"),
74 | :assigns=>{:id=>id, :page=>page}
75 | )
76 | end
77 |
78 | if options[:image_submit]
79 | %w(next skip back cancel finish).each do |fn|
80 | m.file("images/#{fn}.png", "public/images/wizardly/#{fn}.png")
81 | end
82 | end
83 |
84 | m.template("helper.rb.erb", File.join('app/helpers', controller_class_path, "#{controller_name}_helper.rb"))
85 |
86 | # Layout and stylesheet.
87 | m.template("layout.#{view_file_ext.first}", File.join('app/views/layouts', controller_class_path, "#{controller_name}.#{view_file_ext.last}"))
88 | m.template('style.css', 'public/stylesheets/scaffold.css')
89 |
90 | #m.dependency 'model', [name] + @args, :collision => :skip
91 | end
92 | end
93 |
94 | protected
95 | def banner
96 | "Usage: #{$0} wizardly_scaffold controller_name --ajax --haml"
97 | end
98 |
99 | def extract_modules(name)
100 | modules = name.include?('/') ? name.split('/') : name.split('::')
101 | name = modules.pop
102 | path = modules.map { |m| m.underscore }
103 | file_path = (path + [name.underscore]).join('/')
104 | nesting = modules.map { |m| m.camelize }.join('::')
105 | [name, path, file_path, nesting, modules.size]
106 | end
107 |
108 |
109 | end
110 |
--------------------------------------------------------------------------------
/script/about:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4 | require 'commands/about'
--------------------------------------------------------------------------------
/script/autospec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
3 | ENV['RSPEC'] = 'true' # allows autotest to discover rspec
4 | ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
5 | system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
6 | $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
7 |
--------------------------------------------------------------------------------
/script/console:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/console'
4 |
--------------------------------------------------------------------------------
/script/dbconsole:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/dbconsole'
4 |
--------------------------------------------------------------------------------
/script/destroy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/destroy'
4 |
--------------------------------------------------------------------------------
/script/generate:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/generate'
4 |
--------------------------------------------------------------------------------
/script/performance/benchmarker:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../../config/boot'
3 | require 'commands/performance/benchmarker'
4 |
--------------------------------------------------------------------------------
/script/performance/profiler:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../../config/boot'
3 | require 'commands/performance/profiler'
4 |
--------------------------------------------------------------------------------
/script/plugin:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/plugin'
4 |
--------------------------------------------------------------------------------
/script/runner:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/runner'
4 |
--------------------------------------------------------------------------------
/script/server:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require File.dirname(__FILE__) + '/../config/boot'
3 | require 'commands/server'
4 |
--------------------------------------------------------------------------------
/script/spec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
3 | require 'rubygems' unless ENV['NO_RUBYGEMS']
4 | else
5 | gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
6 | ENV["RAILS_ENV"] ||= 'test'
7 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
8 | end
9 | require 'spec/autorun'
10 | exit ::Spec::Runner::CommandLine.run
11 |
--------------------------------------------------------------------------------
/script/spec_server:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
3 |
4 | puts "Loading Rails environment"
5 | ENV["RAILS_ENV"] ||= 'test'
6 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
7 |
8 | require 'optparse'
9 | require 'spec/rails/spec_server'
10 |
--------------------------------------------------------------------------------
/spec/controllers/callbacks2_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | #require File.dirname(__FILE__) + '/../../app/controllers/callbacks_module'
3 |
4 |
5 |
6 | describe Callbacks2Controller do
7 |
8 | it "should redirect when getting the init form" do
9 | get :init
10 | response.should redirect_to('/main/index#on_get_init_form')
11 | end
12 | it "should raise CallbackError when posting to :second form" do
13 | lambda { post :second }.should raise_error(Wizardly::CallbackError)
14 | end
15 | it "should redirect when posting next to the init page with empty fields" do
16 | post :init, {:next=>'Next'}
17 | response.should redirect_to('/main/index#on_invalid_init_form')
18 | end
19 | it "should redirect when posting next to the init page with valid fields" do
20 | post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}}
21 | response.should redirect_to('/main/index#on_init_form_next')
22 | end
23 | it "should redirect when posting skip to init page" do
24 | post :init, {:commit=>'Skip'}
25 | response.should redirect_to('/main/index#on_init_form_skip')
26 | end
27 | it "should redirect when posting :back to init page" do
28 | post :init, {:commit=>'Back'}
29 | response.should redirect_to('/main/index#on_init_form_back')
30 | end
31 | it "should redirect when posting cancel to init page" do
32 | post :init, {:commit=>'Cancel'}
33 | response.should redirect_to('/main/index#on_init_form_cancel')
34 | end
35 | it "should redirect when posting finish to the finish page" do
36 | post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}}
37 | response.should redirect_to('/main/index#on_finish_form_finish')
38 | end
39 | end
40 |
41 |
--------------------------------------------------------------------------------
/spec/controllers/callbacks3_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 |
3 |
4 | describe Callbacks3Controller do
5 |
6 | it "should redirect when getting all forms" do
7 | get :init
8 | response.should redirect_to('/main/index#on_get_all')
9 | get :second
10 | response.should redirect_to('/main/index#on_get_all')
11 | get :finish
12 | response.should redirect_to('/main/index#on_get_all')
13 | end
14 | it "should set the @on_post_init_form when posting to init form" do
15 | post :init
16 | assigns[:on_post_init_form].should == true
17 | end
18 | it "should raise CallbackError when posting to :second form" do
19 | lambda { post :second }.should raise_error(Wizardly::CallbackError)
20 | end
21 | it "should redirect when posting next to the init page with empty fields" do
22 | post :init, {:commit=>'Next'}
23 | response.should redirect_to('/main/index#on_invalid_init_form')
24 | end
25 | it "should redirect when posting next to the init page with valid fields" do
26 | post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}}
27 | response.should redirect_to('/main/index#on_init_form_next')
28 | end
29 | #skip
30 | it "should redirect when posting skip to init and finish page" do
31 | post :init, {:commit=>'Skip'}
32 | response.should redirect_to('/main/index#on_init_and_finish_form_skip')
33 | post :finish, {:commit=>'Skip'}
34 | response.should redirect_to('/main/index#on_init_and_finish_form_skip')
35 | end
36 | #back
37 | it "should redirect when posting :back to init, finish page" do
38 | post :init, {:commit=>'Back'}
39 | response.should redirect_to('/main/index#on_init_and_finish_form_back')
40 | post :finish, {:commit=>'Back'}
41 | response.should redirect_to('/main/index#on_init_and_finish_form_back')
42 | end
43 | #cancel
44 | it "should redirect when posting cancel to init, finish page" do
45 | post :init, {:commit=>'Cancel'}
46 | response.should redirect_to('/main/index#on_init_and_finish_form_cancel')
47 | post :finish, {:commit=>'Cancel'}
48 | response.should redirect_to('/main/index#on_init_and_finish_form_cancel')
49 | end
50 | it "should redirect when posting finish to the finish page" do
51 | post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}}
52 | response.should redirect_to('/main/index#on_finish_form_finish')
53 | end
54 | end
55 |
56 |
--------------------------------------------------------------------------------
/spec/controllers/callbacks_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require File.dirname(__FILE__) + '/../../app/controllers/callbacks_module'
3 |
4 | #include Callbacks
5 |
6 |
7 | Spec::Matchers.define :have_callback do |*expected_callbacks|
8 | match do |value|
9 | Callbacks::action_callbacks.each do |b|
10 | value[b] == (expected_callbacks.include?(b) ? true : nil)
11 | end
12 | Callbacks::wizard_callbacks.each do |w|
13 | value[w] == (expected_callbacks.include?(w) ? true : nil)
14 | end
15 | true
16 | end
17 | end
18 |
19 |
20 | describe CallbacksController do
21 |
22 | it "should flag callbacks and render when requesting the init form" do
23 | get :init
24 | assigns.should have_callback(:on_get_init_form, :render_wizard_form)
25 | end
26 | it "should flag callbacks and re-render when posting next to the init page with empty fields" do
27 | post :init
28 | assigns.should have_callback(:on_post_init_form, :on_invalid_init_form, :render_wizard_form)
29 | end
30 | #should there be a _on_wizard_next
31 | it "should flag callbacks when posting next to the init page with valid fields" do
32 | post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}}
33 | response.should redirect_to(:action=>:second)
34 | assigns.should have_callback(:on_post_init_form, :on_init_form_next)
35 | end
36 | it "should flag callbacks and redirect to :second page when posting skip to init page" do
37 | post :init, {:commit=>'Skip', :user=>{:first_name=>'', :last_name=>''}}
38 | assigns.should have_callback(:on_post_init_form, :on_init_form_skip, :_on_wizard_skip)
39 | response.should redirect_to(:action=>:second)
40 | end
41 | it "should flag callbacks and redirect to :first page when posting :back to :second page" do
42 | post :second, {:commit=>'Back'}
43 | assigns.should have_callback(:on_post_second_form, :on_second_form_back, :_on_wizard_back)
44 | response.should redirect_to(:action=>:init)
45 | end
46 | it "should flag callbacks and redirect to :canceled page when posting cancel to second page" do
47 | post :second, {:commit=>'Cancel'}
48 | assigns.should have_callback(:on_post_second_form, :on_second_form_cancel, :_on_wizard_cancel)
49 | response.should redirect_to(:controller=>:main, :action=>:canceled)
50 | end
51 | it "should flag callbacks and redirect to :completed page when posting finish to the finish page" do
52 | post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}}
53 | assigns.should have_callback(:on_post_finish_form, :on_finish_form_finish, :_on_wizard_finish)
54 | response.should redirect_to(:controller=>:main, :action=>:finished)
55 | end
56 | end
57 |
58 |
59 | #module TestVariables
60 | # def init_page; "init"; end
61 | # def second_page; "second"; end
62 | # def third_page; "third"; end
63 | # def finish_page; "finish"; end
64 | # def blank_error; "*can't be blank"; end
65 | # def back_button; "back"; end
66 | # def next_button; "next"; end
67 | # def skip_button; "skip"; end
68 | # def finish_button; "finish"; end
69 | # def cancel_button; "cancel"; end
70 | # def field_first_name; "john"; end
71 | # def field_last_name; "doe"; end
72 | # def field_age; 30; end
73 | # def field_programmer; true; end
74 | # def field_status; "active"; end
75 | # def field_gender; "male"; end
76 | # def field_password; "password"; end
77 | # def field_password_confirmation; field_password; end
78 | # def field_username; "johndoe"; end
79 | # def index_page_path; '/callbacks/index'; end
80 | # def finish_page_path; '/callbacks/finish'; end
81 | # def second_page_path; '/callbacks/second'; end
82 | # def third_page_path; '/callbacks/third'; end
83 | # def init_page_path; '/callbacks/init'; end
84 | # def main_finished_path; '/main/finished'; end
85 | # def main_canceled_path; '/main/canceled'; end
86 | #end
87 |
--------------------------------------------------------------------------------
/spec/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 |
3 | # one:
4 | # column: value
5 | #
6 | # two:
7 | # column: value
8 |
--------------------------------------------------------------------------------
/spec/integrations/avatar_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'avatar_step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def finish_page; "finish"; end
8 | def blank_error; "can't be blank"; end
9 | def back_button; "back"; end
10 | def next_button; "next"; end
11 | def skip_button; "skip"; end
12 | def finish_button; "finish"; end
13 | def cancel_button; "cancel"; end
14 | def field_first_name; "john"; end
15 | def field_last_name; "doe"; end
16 | def field_age; 30; end
17 | def field_programmer; true; end
18 | def field_status; "active"; end
19 | def field_gender; "male"; end
20 | def field_password; "password"; end
21 | def field_password_confirmation; field_password; end
22 | def field_username; "johndoe"; end
23 | def field_avatar; File.dirname(__FILE__) + '/../../public/images/avatar.png'; end;
24 | def main_finished_path; '/main/finished'; end
25 | def main_canceled_path; '/main/canceled'; end
26 | end
27 |
28 | describe "AvatarSessionController" do
29 | include TestVariables
30 | include AvatarStepHelpers
31 | def index_page_path; '/avatar_session/index'; end
32 | def finish_page_path; '/avatar_session/finish'; end
33 | def second_page_path; '/avatar_session/second'; end
34 | def init_page_path; '/avatar_session/init'; end
35 |
36 | it "should accept avatar field" do
37 | step_to_second_page
38 | fill_in_second_page
39 | click_button next_button
40 | end
41 |
42 | it "should accept and save avatar field" do
43 | User.delete_all
44 | step_to_finish_page
45 | fill_in_finish_page
46 | click_button finish_button
47 | u = AvatarUser.find_by_username(field_username)
48 | u.should_not be_nil
49 | u.first_name.should == field_first_name
50 | u.avatar_file_name.should include('avatar.png')
51 | u.avatar_file_size.should_not == 0
52 | u.avatar_content_type.should == 'image/png'
53 | end
54 |
55 | it "should not reset form data when leaving wizard and returning" do
56 | step_to_finish_page
57 | click_button cancel_button
58 | click_link 'signup'
59 | current_url.should include(init_page)
60 | field_with_id(/first/).value.should == field_first_name
61 | field_with_id(/last/).value.should == field_last_name
62 | click_button next_button
63 | field_with_id(/age/).value.should == field_age.to_s
64 | field_with_id(/gender/).value.should == field_gender
65 | field_with_id(/programmer/).value.should == (field_programmer ? "1":"0")
66 | field_with_id(/status/).value.should == field_status
67 | end
68 | end
69 |
--------------------------------------------------------------------------------
/spec/integrations/avatar_step_helpers.rb:
--------------------------------------------------------------------------------
1 | module AvatarStepHelpers
2 | def step_to_init_page
3 | visit init_page_path
4 | end
5 | def fill_in_init_page
6 | fill_in(/first_name/, :with=>field_first_name)
7 | fill_in(/last_name/, :with=>field_last_name)
8 | end
9 | def step_to_second_page
10 | step_to_init_page
11 | fill_in_init_page
12 | click_button next_button
13 | end
14 | def fill_in_second_page
15 | fill_in(/age/, :with=>field_age)
16 | fill_in(/gender/, :with=>field_gender)
17 | fill_in(/status/, :with=>field_status)
18 | fill_in(/programmer/, :with=>field_programmer)
19 | fill_in(/avatar/, :with=>field_avatar)
20 | end
21 | def step_to_finish_page
22 | step_to_second_page
23 | fill_in_second_page
24 | click_button next_button
25 | end
26 | def fill_in_finish_page
27 | fill_in(/username/, :with=>field_username)
28 | fill_in("user[password]", :with=>field_password)
29 | fill_in("user[password_confirmation]", :with=>field_password_confirmation)
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/spec/integrations/data_modes2_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def finish_page; "finish"; end
8 | def blank_error; "can't be blank"; end
9 | def back_button; "back"; end
10 | def next_button; "next"; end
11 | def skip_button; "skip"; end
12 | def finish_button; "finish"; end
13 | def cancel_button; "cancel"; end
14 | def field_first_name; "john"; end
15 | def field_last_name; "doe"; end
16 | def field_age; 30; end
17 | def field_programmer; true; end
18 | def field_status; "active"; end
19 | def field_gender; "male"; end
20 | def field_password; "password"; end
21 | def field_password_confirmation; field_password; end
22 | def field_username; "johndoe"; end
23 | def index_page_path; '/data_modes2/index'; end
24 | def finish_page_path; '/data_modes2/finish'; end
25 | def second_page_path; '/data_modes2/second'; end
26 | def init_page_path; '/data_modes2/init'; end
27 | def main_finished_path; '/main/finished'; end
28 | def main_canceled_path; '/main/canceled'; end
29 | end
30 |
31 | #testing :persist_model=>:per_page, :form_data=>:sandbox
32 | describe "DataModes2Controller" do
33 | include TestVariables
34 | include StepHelpers
35 |
36 | it "should save model incrementally" do
37 | User.delete_all
38 | step_to_finish_page
39 | u = User.find(:first)
40 | assert u
41 | u.first_name.should == field_first_name
42 | u.last_name.should == field_last_name
43 | step_to_finish_page
44 | v = User.find(:first)
45 | assert v
46 | v.first_name.should == field_first_name
47 | v.last_name.should == field_last_name
48 | v.age.should == field_age
49 | v.status.should == field_status
50 | v.programmer.should == field_programmer
51 | v.gender.should == field_gender
52 | w = User.find(:all)
53 | w.size.should == 1
54 | end
55 |
56 | it "should complete wizard, save model, and create new model next time" do
57 | User.delete_all
58 | step_to_finish_page
59 | fill_in_finish_page
60 | click_button finish_button
61 | u = User.find(:first)
62 | assert u
63 | u.first_name.should == field_first_name
64 | u.password.should == field_password
65 | step_to_second_page
66 | w = User.find(:all)
67 | w.size.should == 2
68 | w.first.id.should_not == w.last.id
69 | end
70 |
71 | it "should fill in first page, leave and return to first page" do
72 | User.delete_all
73 | step_to_init_page
74 | current_url.should include(init_page)
75 | field_with_id(/first/).value.should be_blank
76 | field_with_id(/last/).value.should be_blank
77 | fill_in_init_page
78 | click_button cancel_button
79 | visit init_page_path
80 | current_url.should include(init_page)
81 | field_with_id(/first/).value.should be_blank
82 | field_with_id(/last/).value.should be_blank
83 | end
84 |
85 | it "should fill in second page, leave and return to init page when trying to return to second page directly" do
86 | User.delete_all
87 | step_to_second_page
88 | current_url.should include(second_page)
89 | field_with_id(/age/).value.should be_blank
90 | field_with_id(/status/).value.should be_blank
91 | fill_in_second_page
92 | click_button cancel_button
93 | visit '/data_modes/'+ second_page
94 | current_url.should include(init_page)
95 | field_with_id(/first/).value.should be_blank
96 | field_with_id(/last/).value.should be_blank
97 | click_button next_button
98 | end
99 |
100 |
101 | it_should_behave_like "form data using sandbox"
102 | it_should_behave_like "all implementations"
103 |
104 | end
105 |
--------------------------------------------------------------------------------
/spec/integrations/data_modes_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def finish_page; "finish"; end
8 | def blank_error; "can't be blank"; end
9 | def back_button; "back"; end
10 | def next_button; "next"; end
11 | def skip_button; "skip"; end
12 | def finish_button; "finish"; end
13 | def cancel_button; "cancel"; end
14 | def field_first_name; "john"; end
15 | def field_last_name; "doe"; end
16 | def field_age; 30; end
17 | def field_programmer; true; end
18 | def field_status; "active"; end
19 | def field_gender; "male"; end
20 | def field_password; "password"; end
21 | def field_password_confirmation; field_password; end
22 | def field_username; "johndoe"; end
23 | def index_page_path; '/data_modes/index'; end
24 | def finish_page_path; '/data_modes/finish'; end
25 | def second_page_path; '/data_modes/second'; end
26 | def init_page_path; '/data_modes/init'; end
27 | def main_finished_path; '/main/finished'; end
28 | def main_canceled_path; '/main/canceled'; end
29 | end
30 |
31 | #testing :persist_model=>:per_page, :form_data=>:session
32 | describe "DataModesController" do
33 | include TestVariables
34 | include StepHelpers
35 |
36 | it "should save model incrementally" do
37 | User.delete_all
38 | step_to_finish_page
39 | u = User.find(:first)
40 | assert u
41 | u.first_name.should == field_first_name
42 | u.last_name.should == field_last_name
43 | step_to_finish_page
44 | v = User.find(:first)
45 | assert v
46 | v.first_name.should == field_first_name
47 | v.last_name.should == field_last_name
48 | v.age.should == field_age
49 | v.status.should == field_status
50 | v.programmer.should == field_programmer
51 | v.gender.should == field_gender
52 | w = User.find(:all)
53 | w.size.should == 1
54 | end
55 |
56 | it "should complete wizard, save model, and create new model next time" do
57 | User.delete_all
58 | step_to_finish_page
59 | fill_in_finish_page
60 | click_button finish_button
61 | u = User.find(:first)
62 | assert u
63 | u.first_name.should == field_first_name
64 | u.password.should == field_password
65 | step_to_second_page
66 | w = User.find(:all)
67 | w.size.should == 2
68 | w.first.id.should_not == w.last.id
69 | end
70 |
71 | it "should fill in first page, leave and return to first page" do
72 | User.delete_all
73 | step_to_init_page
74 | current_url.should include(init_page)
75 | field_with_id(/first/).value.should be_blank
76 | field_with_id(/last/).value.should be_blank
77 | fill_in_init_page
78 | click_button cancel_button
79 | step_to_init_page
80 | field_with_id(/first/).value.should == field_first_name
81 | field_with_id(/last/).value.should == field_last_name
82 | end
83 |
84 | it "should fill in second page, leave and return to second page directly" do
85 | User.delete_all
86 | step_to_second_page
87 | current_url.should include(second_page)
88 | field_with_id(/age/).value.should be_blank
89 | field_with_id(/status/).value.should be_blank
90 | fill_in_second_page
91 | click_button cancel_button
92 | visit '/data_modes/'+ second_page
93 | current_url.should include(second_page)
94 | field_with_id(/age/).value.should == field_age.to_s
95 | field_with_id(/gender/).value.should == field_gender
96 | field_with_id(/programmer/).value.should == (field_programmer ? "1":"0")
97 | field_with_id(/status/).value.should == field_status
98 | click_button next_button
99 | end
100 |
101 |
102 | it_should_behave_like "form data using session"
103 | it_should_behave_like "all implementations"
104 |
105 | end
106 |
--------------------------------------------------------------------------------
/spec/integrations/four_step_helpers.rb:
--------------------------------------------------------------------------------
1 | module FourStepHelpers
2 | def step_to_init_page
3 | visit init_page_path
4 | end
5 | def fill_in_init_page
6 | fill_in(/first_name/, :with=>field_first_name)
7 | fill_in(/last_name/, :with=>field_last_name)
8 | end
9 | def step_to_second_page
10 | step_to_init_page
11 | fill_in_init_page
12 | click_button next_button
13 | end
14 | def fill_in_second_page
15 | fill_in(/age/, :with=>field_age)
16 | fill_in(/gender/, :with=>field_gender)
17 | end
18 | def step_to_third_page
19 | step_to_second_page
20 | fill_in_second_page
21 | click_button next_button
22 | end
23 | def fill_in_third_page
24 | fill_in(/status/, :with=>field_status)
25 | fill_in(/programmer/, :with=>field_programmer)
26 | end
27 | def step_to_finish_page
28 | step_to_third_page
29 | fill_in_third_page
30 | click_button next_button
31 | end
32 | def fill_in_finish_page
33 | fill_in(/username/, :with=>field_username)
34 | fill_in(/user_password/, :with=>field_password)
35 | fill_in(/user_password_confirmation/, :with=>field_password_confirmation)
36 | end
37 |
38 | end
--------------------------------------------------------------------------------
/spec/integrations/generated_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'step_helpers'
3 |
4 | #require 'rails_generator'
5 | #require 'rails_generator/scripts/generate'
6 | #
7 | #gen_argv = []
8 | #gen_argv << "wizardly_controller" << "generated" << "user" << "/main/finished" << "/main/canceled" << "--force"
9 | #Rails::Generator::Scripts::Generate.new.run(gen_argv)
10 |
11 | #load 'app/controllers/generated_controller.rb'
12 |
13 | module TestVariables
14 | def init_page; "init"; end
15 | def second_page; "second"; end
16 | def finish_page; "finish"; end
17 | def blank_error; "can't be blank"; end
18 | def back_button; "back"; end
19 | def next_button; "next"; end
20 | def skip_button; "skip"; end
21 | def finish_button; "finish"; end
22 | def cancel_button; "cancel"; end
23 | def field_first_name; "john"; end
24 | def field_last_name; "doe"; end
25 | def field_age; 30; end
26 | def field_programmer; true; end
27 | def field_status; "active"; end
28 | def field_gender; "male"; end
29 | def field_password; "password"; end
30 | def field_password_confirmation; field_password; end
31 | def field_username; "johndoe"; end
32 | def index_page_path; '/generated/index'; end
33 | def finish_page_path; '/generated/finish'; end
34 | def second_page_path; '/generated/second'; end
35 | def init_page_path; '/generated/init'; end
36 | def main_finished_path; '/main/finished'; end
37 | def main_canceled_path; '/main/canceled'; end
38 | end
39 |
40 | describe "GeneratedController" do
41 | include TestVariables
42 | include StepHelpers
43 |
44 | it_should_behave_like "form data using session"
45 | it_should_behave_like "all implementations"
46 | end
47 |
48 |
--------------------------------------------------------------------------------
/spec/integrations/macro_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def finish_page; "finish"; end
8 | def blank_error; "can't be blank"; end
9 | def back_button; "back"; end
10 | def next_button; "next"; end
11 | def skip_button; "skip"; end
12 | def finish_button; "finish"; end
13 | def cancel_button; "cancel"; end
14 | def field_first_name; "john"; end
15 | def field_last_name; "doe"; end
16 | def field_age; 30; end
17 | def field_programmer; true; end
18 | def field_status; "active"; end
19 | def field_gender; "male"; end
20 | def field_password; "password"; end
21 | def field_password_confirmation; field_password; end
22 | def field_username; "johndoe"; end
23 | def index_page_path; '/macro/index'; end
24 | def finish_page_path; '/macro/finish'; end
25 | def second_page_path; '/macro/second'; end
26 | def init_page_path; '/macro/init'; end
27 | def main_finished_path; '/main/finished'; end
28 | def main_canceled_path; '/main/canceled'; end
29 | end
30 |
31 | describe "MacroController" do
32 | include TestVariables
33 | include StepHelpers
34 |
35 | it_should_behave_like "form data using sandbox"
36 | it_should_behave_like "all implementations"
37 | end
38 |
--------------------------------------------------------------------------------
/spec/integrations/matchers.rb:
--------------------------------------------------------------------------------
1 | #defines custom rspec matcher for this test
2 | Spec::Matchers.define :be_blank do
3 | match do |value|
4 | value == nil || value == ''
5 | end
6 | end
7 | Spec::Matchers.define :be_nil do
8 | match do |value|
9 | value == nil
10 | end
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/spec/integrations/sandbox_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'four_step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def third_page; "third"; end
8 | def finish_page; "finish"; end
9 | def blank_error; "can't be blank"; end
10 | def back_button; "back"; end
11 | def next_button; "next"; end
12 | def skip_button; "skip"; end
13 | def finish_button; "finish"; end
14 | def cancel_button; "cancel"; end
15 | def field_first_name; "john"; end
16 | def field_last_name; "doe"; end
17 | def field_age; 30; end
18 | def field_programmer; true; end
19 | def field_status; "active"; end
20 | def field_gender; "male"; end
21 | def field_password; "password"; end
22 | def field_password_confirmation; field_password; end
23 | def field_username; "johndoe"; end
24 | def index_page_path; '/sandbox/index'; end
25 | def finish_page_path; '/sandbox/finish'; end
26 | def second_page_path; '/sandbox/second'; end
27 | def init_page_path; '/sandbox/init'; end
28 | def main_finished_path; '/main/finished'; end
29 | def main_canceled_path; '/main/canceled'; end
30 | end
31 |
32 | #testing :form_data=>:sandbox
33 | describe "SandboxController" do
34 | include TestVariables
35 | include FourStepHelpers
36 |
37 | it "should fill in first page, navigate with link and return to first page with empty fields" do
38 | step_to_init_page
39 | current_url.should include(init_page)
40 | field_with_id(/first/).value.should be_blank
41 | field_with_id(/last/).value.should be_blank
42 | fill_in_init_page
43 | click_button cancel_button
44 | click_link 'sandbox' #visit index_page_path
45 | current_url.should include(init_page)
46 | field_with_id(/first/).value.should be_blank
47 | field_with_id(/last/).value.should be_blank
48 | end
49 |
50 | it "should fill in first page, leave and navigate with link to first page with empty fields" do
51 | step_to_init_page
52 | current_url.should include(init_page)
53 | field_with_id(/first/).value.should be_blank
54 | field_with_id(/last/).value.should be_blank
55 | fill_in_init_page
56 | click_button cancel_button
57 | click_link 'sandbox' #visit index_page_path
58 | current_url.should include(init_page)
59 | field_with_id(/first/).value.should be_blank
60 | field_with_id(/last/).value.should be_blank
61 | end
62 |
63 | it "should fill in first page, post, leave and navigate with link to first page with empty fields" do
64 | step_to_init_page
65 | current_url.should include(init_page)
66 | field_with_id(/first/).value.should be_blank
67 | field_with_id(/last/).value.should be_blank
68 | fill_in_init_page
69 | click_button next_button
70 | current_url.should include(second_page)
71 | click_button cancel_button
72 | current_url.should include('main')
73 | click_link 'sandbox' #visit index_page_path
74 | current_url.should include(init_page)
75 | field_with_id(/first/).value.should be_blank
76 | field_with_id(/last/).value.should be_blank
77 | end
78 |
79 | it "should fill in second page, post, leave and navigate with link to init when trying to return to second page" do
80 | step_to_second_page
81 | current_url.should include(second_page)
82 | field_with_id(/age/).value.should be_blank
83 | field_with_id(/gender/).value.should be_blank
84 | fill_in_second_page
85 | click_button next_button
86 | current_url.should include(third_page)
87 | click_button cancel_button
88 | current_url.should include('main')
89 | click_link 'sandbox_second' #visit second_page_path
90 | current_url.should include(init_page)
91 | field_with_id(/first/).value.should be_blank
92 | field_with_id(/last/).value.should be_blank
93 | end
94 |
95 | it "should fill in first page, navigate with url and return to first page with empty fields" do
96 | step_to_init_page
97 | current_url.should include(init_page)
98 | field_with_id(/first/).value.should be_blank
99 | field_with_id(/last/).value.should be_blank
100 | fill_in_init_page
101 | click_button cancel_button
102 | visit index_page_path
103 | current_url.should include(init_page)
104 | field_with_id(/first/).value.should be_blank
105 | field_with_id(/last/).value.should be_blank
106 | end
107 |
108 | it "should fill in first page, leave and navigate with url to first page with empty fields" do
109 | step_to_init_page
110 | current_url.should include(init_page)
111 | field_with_id(/first/).value.should be_blank
112 | field_with_id(/last/).value.should be_blank
113 | fill_in_init_page
114 | click_button cancel_button
115 | visit index_page_path
116 | current_url.should include(init_page)
117 | field_with_id(/first/).value.should be_blank
118 | field_with_id(/last/).value.should be_blank
119 | end
120 |
121 | it "should fill in first page, post, leave and navigate with url to first page with empty fields" do
122 | step_to_init_page
123 | current_url.should include(init_page)
124 | field_with_id(/first/).value.should be_blank
125 | field_with_id(/last/).value.should be_blank
126 | fill_in_init_page
127 | click_button next_button
128 | current_url.should include(second_page)
129 | click_button cancel_button
130 | current_url.should include('main')
131 | visit index_page_path
132 | current_url.should include(init_page)
133 | field_with_id(/first/).value.should be_blank
134 | field_with_id(/last/).value.should be_blank
135 | end
136 |
137 | it "should fill in second page, post, leave and navigate with url to init when trying to return to second page" do
138 | step_to_second_page
139 | current_url.should include(second_page)
140 | field_with_id(/age/).value.should be_blank
141 | field_with_id(/gender/).value.should be_blank
142 | fill_in_second_page
143 | click_button next_button
144 | current_url.should include(third_page)
145 | click_button cancel_button
146 | current_url.should include('main')
147 | visit second_page_path
148 | current_url.should include(init_page)
149 | field_with_id(/first/).value.should be_blank
150 | field_with_id(/last/).value.should be_blank
151 | end
152 |
153 | it "should skip first page and return to first page when back clicked on second page" do
154 | step_to_init_page
155 | fill_in_init_page
156 | click_button skip_button
157 | current_url.should include(second_page)
158 | click_button back_button
159 | current_url.should include(init_page)
160 | #field_with_id(/first/).value.should be_blank
161 | #field_with_id(/last/).value.should be_blank
162 | end
163 |
164 | it "should skip the second page and return to init page when back clicked on third page" do
165 | step_to_second_page
166 | fill_in_second_page
167 | click_button skip_button
168 | current_url.should include(third_page)
169 | click_button back_button
170 | current_url.should include(init_page)
171 | end
172 |
173 | it "should skip both init and second page and return to init page when back clicked on third page" do
174 | step_to_init_page
175 | click_button skip_button
176 | current_url.should include(second_page)
177 | click_button skip_button
178 | current_url.should include(third_page)
179 | click_button back_button
180 | current_url.should include(init_page)
181 | end
182 |
183 | it "should skip third and return to second when back pressed on finish page" do
184 | step_to_third_page
185 | current_url.should include(third_page)
186 | click_button skip_button
187 | current_url.should include(finish_page)
188 | click_button back_button
189 | current_url.should include(second_page)
190 | end
191 |
192 | end
193 |
--------------------------------------------------------------------------------
/spec/integrations/scaffold_test_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'step_helpers'
3 |
4 | require 'rails_generator'
5 | require 'rails_generator/scripts/generate'
6 |
7 | scaf_argv = []
8 | scaf_argv << "wizardly_scaffold" << "scaffold_test" << "--force"
9 | Rails::Generator::Scripts::Generate.new.run(scaf_argv)
10 |
11 | module TestVariables
12 | def init_page; "init"; end
13 | def second_page; "second"; end
14 | def finish_page; "finish"; end
15 | def blank_error; "can't be blank"; end
16 | def back_button; "back"; end
17 | def next_button; "next"; end
18 | def skip_button; "skip"; end
19 | def finish_button; "finish"; end
20 | def cancel_button; "cancel"; end
21 | def field_first_name; "john"; end
22 | def field_last_name; "doe"; end
23 | def field_age; 30; end
24 | def field_programmer; true; end
25 | def field_status; "active"; end
26 | def field_gender; "male"; end
27 | def field_password; "password"; end
28 | def field_password_confirmation; field_password; end
29 | def field_username; "johndoe"; end
30 | def index_page_path; '/scaffold_test/index'; end
31 | def finish_page_path; '/scaffold_test/finish'; end
32 | def second_page_path; '/scaffold_test/second'; end
33 | def init_page_path; '/scaffold_test/init'; end
34 | def main_finished_path; '/main/finished'; end
35 | def main_canceled_path; '/main/canceled'; end
36 | end
37 |
38 | describe "ScaffoldTestController" do
39 | include TestVariables
40 | include StepHelpers
41 |
42 | it_should_behave_like "form data using sandbox"
43 | it_should_behave_like "all implementations"
44 | end
45 |
--------------------------------------------------------------------------------
/spec/integrations/session_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../spec_helper'
2 | require 'four_step_helpers'
3 |
4 | module TestVariables
5 | def init_page; "init"; end
6 | def second_page; "second"; end
7 | def third_page; "third"; end
8 | def finish_page; "finish"; end
9 | def blank_error; "can't be blank"; end
10 | def back_button; "back"; end
11 | def next_button; "next"; end
12 | def skip_button; "skip"; end
13 | def finish_button; "finish"; end
14 | def cancel_button; "cancel"; end
15 | def field_first_name; "john"; end
16 | def field_last_name; "doe"; end
17 | def field_age; 30; end
18 | def field_programmer; true; end
19 | def field_status; "active"; end
20 | def field_gender; "male"; end
21 | def field_password; "password"; end
22 | def field_password_confirmation; field_password; end
23 | def field_username; "johndoe"; end
24 | def index_page_path; '/session/index'; end
25 | def finish_page_path; '/session/finish'; end
26 | def second_page_path; '/session/second'; end
27 | def init_page_path; '/session/init'; end
28 | def main_finished_path; '/main/finished'; end
29 | def main_canceled_path; '/main/canceled'; end
30 | end
31 |
32 | #testing :form_data=>:sandbox
33 | describe "SessionController" do
34 | include TestVariables
35 | include FourStepHelpers
36 |
37 | it "should return to last page in progression when leaving and trying to return to lager page in othe order" do
38 | step_to_second_page
39 | fill_in_second_page
40 | click_button cancel_button
41 | current_url.should include('main')
42 | click_link 'session_finish'
43 | current_url.should include(second_page)
44 | field_with_id(/age/).value.should == field_age.to_s
45 | field_with_id(/gender/).value.should == field_gender
46 | end
47 |
48 | it "should clear all session variables including fields, progression when finishing and trying to return to page other than first" do
49 | User.delete_all
50 | step_to_finish_page
51 | fill_in_finish_page
52 | click_button finish_button
53 | (u = User.find(:first)).should_not be_nil
54 | u.first_name.should == field_first_name
55 | u.last_name.should == field_last_name
56 | u.age.should == field_age
57 | u.gender.should == field_gender
58 | u.programmer.should == field_programmer
59 | u.status.should == field_status
60 | u.username.should == field_username
61 | u.password.should == field_password
62 | current_url.should include('main')
63 | click_link 'session_third'
64 | current_url.should include(init_page)
65 | field_with_id(/first/).value.should be_blank
66 | field_with_id(/last/).value.should be_blank
67 | end
68 |
69 | it "should fill in first page, navigate with link and return to first page with empty fields" do
70 | step_to_init_page
71 | current_url.should include(init_page)
72 | field_with_id(/first/).value.should be_blank
73 | field_with_id(/last/).value.should be_blank
74 | fill_in_init_page
75 | click_button cancel_button
76 | click_link 'session' #visit index_page_path
77 | current_url.should include(init_page)
78 | field_with_id(/first/).value.should == field_first_name
79 | field_with_id(/last/).value.should == field_last_name
80 | end
81 |
82 | it "should fill in first page, leave and navigate with link to first page with same fields" do
83 | step_to_init_page
84 | current_url.should include(init_page)
85 | field_with_id(/first/).value.should be_blank
86 | field_with_id(/last/).value.should be_blank
87 | fill_in_init_page
88 | click_button cancel_button
89 | click_link 'session_init' #visit index_page_path
90 | current_url.should include(init_page)
91 | field_with_id(/first/).value.should == field_first_name
92 | field_with_id(/last/).value.should == field_last_name
93 | end
94 |
95 | it "should fill in first page, post, leave and return to first page with same fields" do
96 | step_to_init_page
97 | current_url.should include(init_page)
98 | field_with_id(/first/).value.should be_blank
99 | field_with_id(/last/).value.should be_blank
100 | fill_in_init_page
101 | click_button next_button
102 | current_url.should include(second_page)
103 | click_button cancel_button
104 | current_url.should include('main')
105 | click_link 'session_init' #visit index_page_path
106 | current_url.should include(init_page)
107 | field_with_id(/first/).value.should == field_first_name
108 | field_with_id(/last/).value.should == field_last_name
109 | end
110 |
111 | it "should fill in second page, post, leave and return to second when trying to return to navigate by link to second page" do
112 | step_to_second_page
113 | current_url.should include(second_page)
114 | field_with_id(/age/).value.should be_blank
115 | field_with_id(/gender/).value.should be_blank
116 | fill_in_second_page
117 | click_button next_button
118 | current_url.should include(third_page)
119 | click_button cancel_button
120 | current_url.should include('main')
121 | click_link 'session_second' #visit second_page_path
122 | current_url.should include(second_page)
123 | field_with_id(/age/).value.should == field_age.to_s
124 | field_with_id(/gender/).value.should == field_gender
125 | end
126 |
127 | it "should fill in first page, navigate with url and return to first page with same fields" do
128 | step_to_init_page
129 | current_url.should include(init_page)
130 | field_with_id(/first/).value.should be_blank
131 | field_with_id(/last/).value.should be_blank
132 | fill_in_init_page
133 | click_button cancel_button
134 | visit index_page_path
135 | current_url.should include(init_page)
136 | field_with_id(/first/).value.should == field_first_name
137 | field_with_id(/last/).value.should == field_last_name
138 | end
139 |
140 | it "should fill in first page, leave and navigate with url to first page with same fields" do
141 | step_to_init_page
142 | current_url.should include(init_page)
143 | field_with_id(/first/).value.should be_blank
144 | field_with_id(/last/).value.should be_blank
145 | fill_in_init_page
146 | click_button cancel_button
147 | visit init_page_path
148 | current_url.should include(init_page)
149 | field_with_id(/first/).value.should == field_first_name
150 | field_with_id(/last/).value.should == field_last_name
151 | end
152 |
153 | it "should fill in first page, post, leave and navigate with url to first page with same fields" do
154 | step_to_init_page
155 | current_url.should include(init_page)
156 | field_with_id(/first/).value.should be_blank
157 | field_with_id(/last/).value.should be_blank
158 | fill_in_init_page
159 | click_button next_button
160 | current_url.should include(second_page)
161 | click_button cancel_button
162 | current_url.should include('main')
163 | visit index_page_path
164 | current_url.should include(init_page)
165 | field_with_id(/first/).value.should == field_first_name
166 | field_with_id(/last/).value.should == field_last_name
167 | end
168 |
169 | it "should fill in second page, post, leave and navigate with url to init when trying to return to second page" do
170 | step_to_second_page
171 | current_url.should include(second_page)
172 | field_with_id(/age/).value.should be_blank
173 | field_with_id(/gender/).value.should be_blank
174 | fill_in_second_page
175 | click_button next_button
176 | current_url.should include(third_page)
177 | click_button cancel_button
178 | current_url.should include('main')
179 | visit second_page_path
180 | current_url.should include(second_page)
181 | field_with_id(/age/).value.should == field_age.to_s
182 | field_with_id(/gender/).value.should == field_gender
183 | end
184 |
185 | it "should skip first page and return to first page when back clicked on second page" do
186 | step_to_init_page
187 | fill_in_init_page
188 | click_button skip_button
189 | current_url.should include(second_page)
190 | click_button back_button
191 | current_url.should include(init_page)
192 | #field_with_id(/first/).value.should be_blank
193 | #field_with_id(/last/).value.should be_blank
194 | end
195 |
196 | it "should skip the second page and return to init page when back clicked on third page" do
197 | step_to_second_page
198 | fill_in_second_page
199 | click_button skip_button
200 | current_url.should include(third_page)
201 | click_button back_button
202 | current_url.should include(init_page)
203 | end
204 |
205 | it "should skip both init and second page and return to init page when back clicked on third page" do
206 | step_to_init_page
207 | click_button skip_button
208 | current_url.should include(second_page)
209 | click_button skip_button
210 | current_url.should include(third_page)
211 | click_button back_button
212 | current_url.should include(init_page)
213 | end
214 |
215 | it "should skip third and return to second when back pressed on finish page" do
216 | step_to_third_page
217 | current_url.should include(third_page)
218 | click_button skip_button
219 | current_url.should include(finish_page)
220 | click_button back_button
221 | current_url.should include(second_page)
222 | end
223 |
224 | end
225 |
--------------------------------------------------------------------------------
/spec/integrations/shared_examples.rb:
--------------------------------------------------------------------------------
1 | shared_examples_for "form data using sandbox" do
2 | it "should reset form data when leaving wizard and returning" do
3 | step_to_finish_page
4 | click_button cancel_button
5 | click_link 'signup'
6 | current_url.should include(init_page)
7 | field_with_id(/first/).value.should be_blank
8 | field_with_id(/last/).value.should be_blank
9 | end
10 | end
11 |
12 | shared_examples_for "form data using session" do
13 | it "should not reset form data when leaving wizard and returning" do
14 | step_to_finish_page
15 | click_button cancel_button
16 | click_link 'signup'
17 | current_url.should include(init_page)
18 | field_with_id(/first/).value.should == field_first_name
19 | field_with_id(/last/).value.should == field_last_name
20 | click_button next_button
21 | field_with_id(/age/).value.should == field_age.to_s
22 | field_with_id(/gender/).value.should == field_gender
23 | field_with_id(/programmer/).value.should == (field_programmer ? "1":"0")
24 | field_with_id(/status/).value.should == field_status
25 | end
26 | end
27 |
28 | shared_examples_for "all implementations" do
29 |
30 | it "should save user when clicking finish on finish page" do
31 | User.delete_all
32 | step_to_finish_page
33 | fill_in_finish_page
34 | click_button finish_button
35 | current_url.should include(main_finished_path)
36 | (u = User.find(:first)).should_not be_nil
37 | u.first_name.should == field_first_name
38 | u.last_name.should == field_last_name
39 | u.age.should == field_age
40 | u.gender.should == field_gender
41 | u.programmer.should == field_programmer
42 | u.status.should == field_status
43 | u.username.should == field_username
44 | u.password.should == field_password
45 | end
46 | it "should back up to second page from finish page and maintain field data when back button clicked" do
47 | step_to_finish_page
48 | click_button back_button
49 | current_url.should include(second_page)
50 | field_with_id(/age/).value.should == field_age.to_s
51 | field_with_id(/gender/).value.should == field_gender
52 | field_with_id(/programmer/).value.should == (field_programmer ? "1":"0")
53 | field_with_id(/status/).value.should == field_status
54 | end
55 | it "should back up to init from second page and maintain field data when back button clicked" do
56 | step_to_second_page
57 | click_button back_button
58 | field_with_id(/first_name/).value.should == field_first_name
59 | field_with_id(/last_name/).value.should == field_last_name
60 | end
61 | it "should maintain field data after backing up then returning to page via next button" do
62 | step_to_second_page
63 | fill_in(/age/, :with=>field_age)
64 | fill_in(/gender/, :with=>field_gender)
65 | fill_in(/programmer/, :with=>'')
66 | fill_in(/status/, :with=>'')
67 | click_button back_button
68 | current_url.should include(init_page)
69 | click_button next_button
70 | field_with_id(/age/).value.should == field_age.to_s
71 | field_with_id(/gender/).value.should == field_gender
72 | field_with_id(/programmer/).value.should be_blank
73 | field_with_id(/status/).value.should be_blank
74 | end
75 |
76 | it "should redirect to referrer page when coming from referrer and cancelled from init page" do
77 | end
78 | it "should redirect to ..main/canceled when clicking cancel button on second page" do
79 | step_to_second_page
80 | click_button cancel_button
81 | current_url.should include(main_canceled_path)
82 | end
83 | it "should redirect to ..main/canceled when clicking cancel button on finish page" do
84 | step_to_finish_page
85 | click_button cancel_button
86 | current_url.should include(main_canceled_path)
87 | end
88 | it "should redirect to ..main/canceled when clicking cancel button on init page" do
89 | step_to_init_page
90 | click_button cancel_button
91 | current_url.should include(main_canceled_path)
92 | end
93 | it "should invalidate finish page with empty fields" do
94 | step_to_finish_page
95 | click_button finish_button
96 | current_url.should include(finish_page)
97 | response.body.should contain(blank_error)
98 | end
99 | it "should invalidate second page with empty fields" do
100 | step_to_second_page
101 | click_button next_button
102 | current_url.should include(second_page)
103 | response.body.should contain(blank_error)
104 | end
105 | it "should invalidate init page with empty fields" do
106 | visit init_page_path
107 | click_button next_button
108 | current_url.should include(init_page)
109 | response.body.should include(blank_error)
110 | end
111 | it "should redirect to init page if entering from finish page" do
112 | visit finish_page_path
113 | current_url.should include(init_page)
114 | end
115 | it "should redirect to init page if entering from second page" do
116 | visit second_page_path
117 | current_url.should include(init_page)
118 | end
119 | it "should start at init page and fields should be empty when entering from index" do
120 | visit index_page_path
121 | current_url.should include(init_page)
122 | field_with_id(/first/).value.should be_blank
123 | field_with_id(/last/).value.should be_blank
124 | end
125 | it "should navigate from init to second screen on next button without validation errors" do
126 | User.delete_all
127 | step_to_second_page
128 | current_url.should include(second_page)
129 | end
130 | it "should go from init to finish screen on next buttons without validation errors" do
131 | User.delete_all
132 | step_to_finish_page
133 | current_url.should include(finish_page)
134 | end
135 | it "should complete form and save User object on completion without validation errors" do
136 | User.delete_all
137 | step_to_finish_page
138 | fill_in_finish_page
139 | click_button finish_button
140 | current_url.should include(main_finished_path)
141 | User.find_by_username(field_username).should_not be_nil
142 | end
143 |
144 |
145 | end
146 |
--------------------------------------------------------------------------------
/spec/integrations/step_helpers.rb:
--------------------------------------------------------------------------------
1 | module StepHelpers
2 | def step_to_init_page
3 | visit init_page_path
4 | end
5 | def fill_in_init_page
6 | fill_in(/first_name/, :with=>field_first_name)
7 | fill_in(/last_name/, :with=>field_last_name)
8 | end
9 | def step_to_second_page
10 | step_to_init_page
11 | fill_in_init_page
12 | click_button next_button
13 | end
14 | def fill_in_second_page
15 | fill_in(/age/, :with=>field_age)
16 | fill_in(/gender/, :with=>field_gender)
17 | fill_in(/status/, :with=>field_status)
18 | fill_in(/programmer/, :with=>field_programmer)
19 | end
20 | def step_to_finish_page
21 | step_to_second_page
22 | fill_in_second_page
23 | click_button next_button
24 | end
25 | def fill_in_finish_page
26 | fill_in(/username/, :with=>field_username)
27 | fill_in("user[password]", :with=>field_password)
28 | fill_in("user[password_confirmation]", :with=>field_password_confirmation)
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/spec/models/user_specd.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2 |
3 | describe User do
4 | before(:each) do
5 | @valid_attributes = {
6 | }
7 | end
8 |
9 | it "should create a new instance given valid attributes" do
10 | User.create!(@valid_attributes)
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/rcov.opts:
--------------------------------------------------------------------------------
1 | --exclude "spec/*,gems/*"
2 | --rails
--------------------------------------------------------------------------------
/spec/spec.opts:
--------------------------------------------------------------------------------
1 | --colour
2 | --format progress
3 | --loadby mtime
4 | --reverse
5 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2 | # from the project root directory.
3 | ENV["RAILS_ENV"] ||= 'test'
4 | require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
5 | #require 'validation_group'
6 | #require 'wizardly'
7 | require 'spec/autorun'
8 | require 'spec/rails'
9 |
10 | require 'spec/integrations/shared_examples'
11 | require 'spec/integrations/matchers'
12 |
13 | Webrat.configure do |config|
14 | config.mode = :rails
15 | end
16 |
17 | Spec::Runner.configure do |config|
18 | # If you're not using ActiveRecord you should remove these
19 | # lines, delete config/database.yml and disable :active_record
20 | # in your config/boot.rb
21 | # config.use_transactional_fixtures = true
22 | # config.use_instantiated_fixtures = false
23 | # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
24 | end
25 |
26 | #setup for integrating webrat with rspec
27 | module Spec::Rails::Example
28 | class IntegrationExampleGroup < ActionController::IntegrationTest
29 |
30 | def initialize(defined_description, options={}, &implementation)
31 | defined_description.instance_eval do
32 | def to_s
33 | self
34 | end
35 | end
36 | super(defined_description)
37 | end
38 |
39 | Spec::Example::ExampleGroupFactory.register(:integration, self)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/test/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 |
3 | one:
4 | first_name: MyString
5 | last_name: MyString
6 | username: MyString
7 | password: MyString
8 | age: 1
9 | gender: MyString
10 | programmer: false
11 | status: MyString
12 |
13 | two:
14 | first_name: MyString
15 | last_name: MyString
16 | username: MyString
17 | password: MyString
18 | age: 1
19 | gender: MyString
20 | programmer: false
21 | status: MyString
22 |
--------------------------------------------------------------------------------
/test/functional/callbacks_controller_test.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../test_helper'
2 |
3 | module TestVariables
4 | def init_page; "init"; end
5 | def second_page; "second"; end
6 | def third_page; "third"; end
7 | def finish_page; "finish"; end
8 | def blank_error; "*can't be blank"; end
9 | def back_button; "back"; end
10 | def next_button; "next"; end
11 | def skip_button; "skip"; end
12 | def finish_button; "finish"; end
13 | def cancel_button; "cancel"; end
14 | def field_first_name; "john"; end
15 | def field_last_name; "doe"; end
16 | def field_age; 30; end
17 | def field_programmer; true; end
18 | def field_status; "active"; end
19 | def field_gender; "male"; end
20 | def field_password; "password"; end
21 | def field_password_confirmation; field_password; end
22 | def field_username; "johndoe"; end
23 | def index_page_path; '/callbacks/index'; end
24 | def finish_page_path; '/callbacks/finish'; end
25 | def second_page_path; '/callbacks/second'; end
26 | def third_page_path; '/callbacks/third'; end
27 | def init_page_path; '/callbacks/init'; end
28 | def main_finished_path; '/main/finished'; end
29 | def main_canceled_path; '/main/canceled'; end
30 | end
31 |
32 | class CallbacksControllerTest < ActionController::TestCase
33 | include TestVariables
34 |
35 | # def test_should_flag_on_get_init_page_when_calling_get_on_init_action
36 | # get init_page
37 | # assert_response :success
38 | # assert assigns['on_get_init_page']
39 | # end
40 | # def test_should_flag_on_init_page_errors_when_clicking_next_on_init_page_with_empty_fields
41 | # post init_page, :commit=>next_button
42 | # assert_template init_page
43 | # assert assigns['on_init_page_errors']
44 | # end
45 | def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page
46 | post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next
47 | #assert_redirected_to :action=>second_page
48 | assert assigns['on_init_page_next']
49 | end
50 | # def test_should_flag_ON_INIT_PAGE_SKIP_when_clicking_skip_on_init_page
51 | # post init_page, :commit=>skip_button
52 | # assert_redirected_to :action=>second_page
53 | # assert assigns['on_init_page_skip']
54 | # end
55 | # def test_should_flag_ON_SECOND_PAGE_BACK_when_clicking_back_from_second_page
56 | # post init_page, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>next_button
57 | # #assert_redirected_to :action=>second_page
58 | # post second_page, :user=>{:age=>field_age.to_s, :gender=>field_gender}, :commit=>back_button
59 | # #assert_redirected_to :action=>init_page
60 | # assert assigns['on_second_page_back']
61 | # end
62 | end
63 |
--------------------------------------------------------------------------------
/test/functional/image_submit_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ImageSubmitControllerTest < ActionController::TestCase
4 | # Replace this with your real tests.
5 | test "the truth" do
6 | assert true
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/test/performance/browsing_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 | require 'performance_test_help'
3 |
4 | # Profiling results for each test method are written to tmp/performance.
5 | class BrowsingTest < ActionController::PerformanceTest
6 | def test_homepage
7 | get '/'
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV["RAILS_ENV"] = "test"
2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3 | require 'test_help'
4 |
5 |
6 |
7 | class ActiveSupport::TestCase
8 | # Transactional fixtures accelerate your tests by wrapping each test method in
9 | # a transaction that's rolled back on completion. This ensures that the test
10 | # database remains unchanged so your fixtures don't have to be reloaded
11 | # between every test method. Fewer database queries means faster tests.
12 | #
13 | # Read Mike Clark's excellent walkthrough at
14 | # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
15 | #
16 | # Every Active Record database supports transactions except MyISAM tables in
17 | # MySQL. Turn off transactional fixtures in this case; however, if you don't
18 | # care one way or the other, switching from MyISAM to InnoDB tables is
19 | # recommended.
20 | #
21 | # The only drawback to using transactional fixtures is when you actually need
22 | # to test transactions. Since your test is bracketed by a transaction, any
23 | # transactions started in your code will be automatically rolled back.
24 | self.use_transactional_fixtures = true
25 |
26 | # Instantiated fixtures are slow, but give you @david where otherwise you
27 | # would need people(:david). If you don't want to migrate your existing test
28 | # cases which use the @david style and don't mind the speed hit (each
29 | # instantiated fixtures translates to a database query per test method), then
30 | # set this back to true.
31 | self.use_instantiated_fixtures = false
32 |
33 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in
34 | # alphabetical order.
35 | #
36 | # Note: You'll currently still have to declare fixtures explicitly in
37 | # integration tests -- they do not yet inherit this setting
38 | fixtures :all
39 |
40 | # Add more helper methods to be used by all tests here...
41 | end
42 |
43 |
44 |
45 | Webrat.configure do |config|
46 | config.mode = :rails
47 | end
48 |
--------------------------------------------------------------------------------
/test/unit/helpers/callbacks_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CallbacksHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/image_submit_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ImageSubmitHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/user_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UserTest < ActiveSupport::TestCase
4 | # Replace this with your real tests.
5 | test "the truth" do
6 | assert true
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/wizardly.gemspec:
--------------------------------------------------------------------------------
1 | # -*- encoding: utf-8 -*-
2 |
3 | Gem::Specification.new do |s|
4 | s.name = %q{wizardly}
5 | s.version = "0.1.8.9"
6 |
7 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8 | s.authors = ["Jeff Patmon"]
9 | s.date = %q{2009-10-07}
10 | s.description = %q{Create wizards from any model in three steps}
11 | s.email = %q{jpatmon@yahoo.com}
12 | s.files = ["lib/generators", "lib/wizardly.rb", "lib/validation_group.rb", "lib/jeffp-wizardly.rb", "lib/wizardly", "lib/wizardly/wizard.rb", "lib/wizardly/wizard", "lib/wizardly/wizard/page.rb", "lib/wizardly/wizard/configuration.rb", "lib/wizardly/wizard/button.rb", "lib/wizardly/wizard/utils.rb", "lib/wizardly/wizard/dsl.rb", "lib/wizardly/wizard/configuration", "lib/wizardly/wizard/configuration/methods.rb", "lib/wizardly/wizard/text_helpers.rb", "lib/wizardly/action_controller.rb", "rails_generators/wizardly_app", "rails_generators/wizardly_app/USAGE", "rails_generators/wizardly_app/wizardly_app_generator.rb", "rails_generators/wizardly_app/templates", "rails_generators/wizardly_app/templates/wizardly.rake", "rails_generators/wizardly_scaffold", "rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb", "rails_generators/wizardly_scaffold/USAGE", "rails_generators/wizardly_scaffold/templates", "rails_generators/wizardly_scaffold/templates/style.css", "rails_generators/wizardly_scaffold/templates/form.html.haml.erb", "rails_generators/wizardly_scaffold/templates/form.html.erb", "rails_generators/wizardly_scaffold/templates/layout.html.haml.erb", "rails_generators/wizardly_scaffold/templates/layout.html.erb", "rails_generators/wizardly_scaffold/templates/images", "rails_generators/wizardly_scaffold/templates/images/next.png", "rails_generators/wizardly_scaffold/templates/images/finish.png", "rails_generators/wizardly_scaffold/templates/images/back.png", "rails_generators/wizardly_scaffold/templates/images/cancel.png", "rails_generators/wizardly_scaffold/templates/images/skip.png", "rails_generators/wizardly_scaffold/templates/helper.rb.erb", "rails_generators/wizardly_controller", "rails_generators/wizardly_controller/USAGE", "rails_generators/wizardly_controller/wizardly_controller_generator.rb", "rails_generators/wizardly_controller/templates", "rails_generators/wizardly_controller/templates/controller.rb.erb", "rails_generators/wizardly_controller/templates/helper.rb.erb", "CHANGELOG.rdoc", "init.rb", "LICENSE", "README.rdoc"]
13 | s.homepage = %q{http://github.com/jeffp/wizardly/tree/master}
14 | s.require_paths = ["lib"]
15 | s.rubygems_version = %q{1.3.5}
16 | s.summary = %q{Produces controllers and wizard scaffolding for models with validation_groups}
17 |
18 | if s.respond_to? :specification_version then
19 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20 | s.specification_version = 3
21 |
22 | if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23 | else
24 | end
25 | else
26 | end
27 | end
28 |
--------------------------------------------------------------------------------