ultra_light_wizard 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8aa77dc46a2504759cd6e587b87259a3c939541
4
- data.tar.gz: db43b213bf6684703c6e5e05a4b2bd51709a7585
3
+ metadata.gz: 0eed69b8666f7e033857cad5aa839661f30df94e
4
+ data.tar.gz: b72d941f28d75b57295f237648b59492f688c7a3
5
5
  SHA512:
6
- metadata.gz: 1f97a1b85a1532534b8cf9e05027cb4724d1261ebd107dc36d8c198f4397ce8e9e78f408e315a988b24a3491fec19c40d74b2f8bb8cde3026449195ebaca3351
7
- data.tar.gz: a12fdbf28e420f159677fa1604b5c2627863faed215c6069a2812d2c583ab9183964e9d8d84002d3d6d8192b0ba2c3b79ddc1dd6ab817d00e8fbfc600fdc462e
6
+ metadata.gz: 58de5808aed736f727936ffe2b1da5b19d35930141333ffec43cd7826efb7a3a6b049faac74f75c8f6ad0fabb8f663ca21fa8a0f0655ad9b037e7e985cebbc06
7
+ data.tar.gz: 0b921b545634a843236709114d82cbd0364ab02dd69568086d77c1c8c390ae12b0aa883834fd5aff765bc48b0805655c56844e103e66b9889c126fd861e45470
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Ultra Light Wizard v0.1.0 (beta)
1
+ Ultra Light Wizard v0.1.1 (beta)
2
2
  ================================
3
3
 
4
4
  No time to manage a wizard state machine, session variables, or complicated controllers? Use Ultra Light Wizard!! A RESTful session-less validation-friendly simple wizard approach in Rails.
@@ -25,15 +25,31 @@ Principles
25
25
  Instructions
26
26
  ============
27
27
 
28
- Simply use the following command in place of the Rails scaffold generator, and it will scaffold both standard resource and wizard components
28
+ Add the following to your Rails project ```Gemfile```:
29
29
 
30
- ```rails generate ultra_light_wizard:scaffold (resource) steps:(step1),(step2),(step3),... attributes:(attribute1:db_type1),(attribute2:db_type2),...```
30
+ ```
31
+ gem 'ultra_light_wizard', '~> 0.1.0'
32
+ ```
33
+
34
+ Run the command:
35
+
36
+ ```
37
+ bundle
38
+ ```
39
+
40
+ Then, use the following command in place of the Rails scaffold generator, and it will scaffold both standard resource components and wizard-related components:
41
+
42
+ ```
43
+ rails generate ultra_light_wizard:scaffold (resource) steps:(step1),(step2),(step3),... attributes:(attribute1:db_type1),(attribute2:db_type2),...
44
+ ```
31
45
 
32
46
  This will generate wizard step routes, controller, models, and views
33
47
 
34
48
  Example:
35
49
 
36
- ```rails generate ultra_light_wizard:scaffold Project steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date```
50
+ ```
51
+ rails generate ultra_light_wizard:scaffold Project steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date
52
+ ```
37
53
 
38
54
  Output:
39
55
 
@@ -98,7 +114,9 @@ To kick-off wizard, simply trigger the main model controller create action, and
98
114
 
99
115
  For example, the following will kick-off the project wizard by creating a project and automatically redirecting to first step:
100
116
 
101
- ```<%= link_to 'New Project', projects_path, method: :post %>```
117
+ ```
118
+ <%= link_to 'New Project', projects_path, method: :post %>
119
+ ```
102
120
 
103
121
  It will ask you at one point to overwrite projects_controller generated in included scaffold. Type y or a to have it continue.
104
122
 
@@ -106,7 +124,9 @@ If you'd like to customize the term "step", you can add a step_alias:(alias) opt
106
124
 
107
125
  Example:
108
126
 
109
- ```rails generate ultra_light_wizard:scaffold Project steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date step_alias:part```
127
+ ```
128
+ rails generate ultra_light_wizard:scaffold Project step_alias:part steps:basic_info,project_detail,file_uploads,preview attributes:name:string,description:text,start_date:date,delivery_date:date
129
+ ```
110
130
 
111
131
  Output:
112
132
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,15 +5,15 @@ class <%= class_name %><%= step_alias.pluralize.camelize %>Controller < Applicat
5
5
  <%= step_alias.pluralize.upcase %> = %w(<%= steps.to_a.join(' ') %>)
6
6
 
7
7
  def edit
8
- if <%= file_path %>_<%= step_alias %>_model.editable?
9
- if <%= step_alias %>.present?
10
- render <%= step_alias %>
11
- else
12
- render "#{Rails.root.to_s}/public/404.html", :layout => false, :status => 404
13
- end
8
+ if <%= file_path %>_<%= step_alias %>_model.editable?
9
+ if <%= step_alias %>.present?
10
+ render <%= step_alias %>
14
11
  else
15
- redirect_to :back, :alert => I18n.t("<%= file_path %>.#{@<%= file_path %>.status}_editable_error")
12
+ render "#{Rails.root.to_s}/public/404.html", :layout => false, :status => 404
16
13
  end
14
+ else
15
+ redirect_to :back, :alert => I18n.t("<%= file_path %>.#{@<%= file_path %>.status}_editable_error")
16
+ end
17
17
  end
18
18
 
19
19
  def update
@@ -42,6 +42,10 @@ module UltraLightWizard
42
42
  end
43
43
  end
44
44
 
45
+ def attributes_names
46
+ hashed_model_attributes.keys
47
+ end
48
+
45
49
  def scaffold_attributes
46
50
  model_attributes.gsub(',', ' ')
47
51
  end
@@ -80,7 +84,20 @@ module UltraLightWizard
80
84
  desc "Creates a configuration file for a specific application context (e.g. admin). Takes context path as argument (e.g. admin or internal/wiki) to create config/features/[context_path].yml"
81
85
  def copy_config
82
86
  generate "scaffold", "#{file_path} #{scaffold_attributes} #{arg_options}"
83
- template "app/controllers/model_controller.rb.erb", "app/controllers/#{file_path.pluralize}_controller.rb"
87
+
88
+ gsub_file "app/controllers/#{file_path.pluralize}_controller.rb",
89
+ "@#{singular_table_name}.save\n",
90
+ "@#{singular_table_name}.save(validation: false)\n"
91
+ gsub_file "app/controllers/#{file_path.pluralize}_controller.rb",
92
+ "redirect_to @#{singular_table_name}, notice: 'Video was successfully created.'",
93
+ "redirect_to edit_#{file_path}_#{file_path}_#{step_alias}_path(@#{singular_table_name}, #{orm_class}#{step_alias.camelize.titleize.pluralize}Helper::#{step_alias.pluralize.upcase}.first)"
94
+ inject_into_file "app/controllers/#{file_path.pluralize}_controller.rb",
95
+ after: "def #{singular_table_name}_params\n" do
96
+ " return {} unless params[:#{singular_table_name}].present?\n"
97
+ end
98
+ gsub_file "app/views/#{file_path.pluralize}/index.html.erb",
99
+ "new_#{singular_table_name}_path",
100
+ "#{file_path.pluralize}_path, method: :post"
84
101
  template "app/controllers/wizard_steps_controller.rb.erb", "app/controllers/#{file_path}_#{step_alias.pluralize}_controller.rb"
85
102
  template "app/helpers/wizard_steps_helper.rb.erb", "app/helpers/#{file_path}_#{step_alias.pluralize}_helper.rb"
86
103
  template "app/views/wizard_step_navigation_view.html.erb", "app/views/#{file_path}_#{step_alias.pluralize}/_#{step_alias}_navigation.html.erb"
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: ultra_light_wizard 0.1.0 ruby lib
5
+ # stub: ultra_light_wizard 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "ultra_light_wizard"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Andy Maleh"]
14
- s.date = "2016-02-14"
14
+ s.date = "2016-02-17"
15
15
  s.description = "Ultra light & maintainble wizards in Rails that honor REST, MVC, and OO with minimal writing of code involved and maximum flexibility"
16
16
  s.email = "andy.am@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  "README.md",
28
28
  "Rakefile",
29
29
  "VERSION",
30
- "lib/generators/templates/app/controllers/model_controller.rb.erb",
31
30
  "lib/generators/templates/app/controllers/wizard_steps_controller.rb.erb",
32
31
  "lib/generators/templates/app/helpers/wizard_steps_helper.rb.erb",
33
32
  "lib/generators/templates/app/models/wizard_step_model.rb.erb",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra_light_wizard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-14 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jeweler
@@ -41,7 +41,6 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - VERSION
44
- - lib/generators/templates/app/controllers/model_controller.rb.erb
45
44
  - lib/generators/templates/app/controllers/wizard_steps_controller.rb.erb
46
45
  - lib/generators/templates/app/helpers/wizard_steps_helper.rb.erb
47
46
  - lib/generators/templates/app/models/wizard_step_model.rb.erb
@@ -1,37 +0,0 @@
1
- <% if namespaced? -%>
2
- require_dependency "<%= namespaced_file_path %>/application_controller"
3
-
4
- <% end -%>
5
- <% module_namespacing do -%>
6
- class <%= controller_class_name %>Controller < ApplicationController
7
- before_action :set_<%= singular_table_name %>, only: [:show, :destroy]
8
-
9
- # GET <%= route_url %>
10
- def index
11
- @<%= plural_table_name %> = <%= orm_class %>.all
12
- end
13
-
14
- # GET <%= route_url %>/1
15
- def show
16
- end
17
-
18
- # POST <%= route_url %>
19
- def create
20
- @<%= singular_table_name %> = <%= orm_class %>.new
21
- @<%= singular_table_name %>.save(validation: false)
22
- redirect_to edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(@<%= singular_table_name %>, <%= orm_class %><%= step_alias.camelize.titleize.pluralize %>Helper::<%= step_alias.pluralize.upcase %>.first)
23
- end
24
-
25
- # DELETE <%= route_url %>/1
26
- def destroy
27
- @<%= singular_table_name %>.destroy
28
- redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
29
- end
30
-
31
- private
32
- # Use callbacks to share common setup or constraints between actions.
33
- def set_<%= singular_table_name %>
34
- @<%= singular_table_name %> = <%= orm_class %>.find(params[:id])
35
- end
36
- end
37
- <% end -%>