edk-wizardly 0.1.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/CHANGELOG.rdoc +38 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +645 -0
  4. data/init.rb +1 -0
  5. data/lib/jeffp-wizardly.rb +1 -0
  6. data/lib/validation_group.rb +147 -0
  7. data/lib/wizardly/action_controller.rb +36 -0
  8. data/lib/wizardly/wizard/button.rb +35 -0
  9. data/lib/wizardly/wizard/configuration/methods.rb +414 -0
  10. data/lib/wizardly/wizard/configuration.rb +194 -0
  11. data/lib/wizardly/wizard/dsl.rb +27 -0
  12. data/lib/wizardly/wizard/page.rb +62 -0
  13. data/lib/wizardly/wizard/text_helpers.rb +16 -0
  14. data/lib/wizardly/wizard/utils.rb +11 -0
  15. data/lib/wizardly/wizard.rb +16 -0
  16. data/lib/wizardly.rb +31 -0
  17. data/rails_generators/wizardly_app/USAGE +6 -0
  18. data/rails_generators/wizardly_app/templates/wizardly.rake +37 -0
  19. data/rails_generators/wizardly_app/wizardly_app_generator.rb +41 -0
  20. data/rails_generators/wizardly_controller/USAGE +3 -0
  21. data/rails_generators/wizardly_controller/templates/controller.rb.erb +34 -0
  22. data/rails_generators/wizardly_controller/templates/helper.rb.erb +14 -0
  23. data/rails_generators/wizardly_controller/wizardly_controller_generator.rb +57 -0
  24. data/rails_generators/wizardly_scaffold/USAGE +4 -0
  25. data/rails_generators/wizardly_scaffold/templates/form.html.erb +23 -0
  26. data/rails_generators/wizardly_scaffold/templates/form.html.haml.erb +22 -0
  27. data/rails_generators/wizardly_scaffold/templates/helper.rb.erb +30 -0
  28. data/rails_generators/wizardly_scaffold/templates/images/back.png +0 -0
  29. data/rails_generators/wizardly_scaffold/templates/images/cancel.png +0 -0
  30. data/rails_generators/wizardly_scaffold/templates/images/finish.png +0 -0
  31. data/rails_generators/wizardly_scaffold/templates/images/next.png +0 -0
  32. data/rails_generators/wizardly_scaffold/templates/images/skip.png +0 -0
  33. data/rails_generators/wizardly_scaffold/templates/layout.html.erb +15 -0
  34. data/rails_generators/wizardly_scaffold/templates/layout.html.haml.erb +10 -0
  35. data/rails_generators/wizardly_scaffold/templates/style.css +54 -0
  36. data/rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb +109 -0
  37. metadata +100 -0
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,54 @@
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
+
@@ -0,0 +1,109 @@
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
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: edk-wizardly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8.9
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Patmon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Create wizards from any model in three steps
17
+ email: jpatmon@yahoo.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/generators
26
+ - lib/wizardly.rb
27
+ - lib/validation_group.rb
28
+ - lib/jeffp-wizardly.rb
29
+ - lib/wizardly
30
+ - lib/wizardly/wizard.rb
31
+ - lib/wizardly/wizard
32
+ - lib/wizardly/wizard/page.rb
33
+ - lib/wizardly/wizard/configuration.rb
34
+ - lib/wizardly/wizard/button.rb
35
+ - lib/wizardly/wizard/utils.rb
36
+ - lib/wizardly/wizard/dsl.rb
37
+ - lib/wizardly/wizard/configuration
38
+ - lib/wizardly/wizard/configuration/methods.rb
39
+ - lib/wizardly/wizard/text_helpers.rb
40
+ - lib/wizardly/action_controller.rb
41
+ - rails_generators/wizardly_app
42
+ - rails_generators/wizardly_app/USAGE
43
+ - rails_generators/wizardly_app/wizardly_app_generator.rb
44
+ - rails_generators/wizardly_app/templates
45
+ - rails_generators/wizardly_app/templates/wizardly.rake
46
+ - rails_generators/wizardly_scaffold
47
+ - rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb
48
+ - rails_generators/wizardly_scaffold/USAGE
49
+ - rails_generators/wizardly_scaffold/templates
50
+ - rails_generators/wizardly_scaffold/templates/style.css
51
+ - rails_generators/wizardly_scaffold/templates/form.html.haml.erb
52
+ - rails_generators/wizardly_scaffold/templates/form.html.erb
53
+ - rails_generators/wizardly_scaffold/templates/layout.html.haml.erb
54
+ - rails_generators/wizardly_scaffold/templates/layout.html.erb
55
+ - rails_generators/wizardly_scaffold/templates/images
56
+ - rails_generators/wizardly_scaffold/templates/images/next.png
57
+ - rails_generators/wizardly_scaffold/templates/images/finish.png
58
+ - rails_generators/wizardly_scaffold/templates/images/back.png
59
+ - rails_generators/wizardly_scaffold/templates/images/cancel.png
60
+ - rails_generators/wizardly_scaffold/templates/images/skip.png
61
+ - rails_generators/wizardly_scaffold/templates/helper.rb.erb
62
+ - rails_generators/wizardly_controller
63
+ - rails_generators/wizardly_controller/USAGE
64
+ - rails_generators/wizardly_controller/wizardly_controller_generator.rb
65
+ - rails_generators/wizardly_controller/templates
66
+ - rails_generators/wizardly_controller/templates/controller.rb.erb
67
+ - rails_generators/wizardly_controller/templates/helper.rb.erb
68
+ - CHANGELOG.rdoc
69
+ - init.rb
70
+ - LICENSE
71
+ - README.rdoc
72
+ has_rdoc: false
73
+ homepage: http://github.com/edk/wizardly/tree/master
74
+ licenses:
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.3.5
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Produces controllers and wizard scaffolding for models with validation_groups
99
+ test_files: []
100
+