ultra_light_wizard 0.0.4 → 0.0.5

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: 80b4dd5230aa70e805ce0b3f516dc4e882ea0d38
4
- data.tar.gz: f9db7ab36afbb0fe06db8ad9937a7b04f250bac8
3
+ metadata.gz: 2929282783a52ec498589168a0c2d4f9a293ba48
4
+ data.tar.gz: 1a659b6b9a05a82a7f7464e6fe335cadb3f0c73c
5
5
  SHA512:
6
- metadata.gz: f366407e1b4216e618f9c4668eb6fd76a7d4a7c164ed039f152d4bdb4543cb01038a888d4a920206186a8beebb9488ace94af395bd454b367eab90e15cbf1e11
7
- data.tar.gz: 396ad497eabb8ba6ad460295c20ce903a03e6e287fdd9cb8c7003b5b14788c5175780b8a3f9d692c7256ac5ec500e4592828821774508abd7f7779b00e20ffba
6
+ metadata.gz: 8ed1443f1dc071f13c03abfaa9956aa9dc852aab3657fc990f1b06b8ed47be1f46f790e63e4a7fbabad92d88a9067c988a24dbd85a300b62c914e5380f3e67eb
7
+ data.tar.gz: 49bd8560e293d95aa42ab7c0f183a35a7f8bb61d6a5ca86865c2f54d288affcee70c4ce46ac2c7251211f61b1eb8036dbb2008f9629a055f1e708cd80c922572
data/.ruby-gemset CHANGED
File without changes
data/.ruby-version CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -95,8 +95,9 @@ Features
95
95
  + [DONE] Helper (or Controller SuperModule trait) for ultra light wizard support
96
96
  + [DONE] Route helper methods
97
97
  + [DONE] Wizard kick-off helper/view
98
- - Forms
98
+ + [DONE] Forms
99
99
  - Scaffolding of main model controller/views/migration
100
+ - Support for attributes
100
101
  - Support for nested resources
101
102
  - Modularize (perhaps extracting sub-generators)
102
103
  + [DONE] Customize name conventions
data/Rakefile CHANGED
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -1,4 +1,5 @@
1
1
  class <%= class_name %><%= step_alias.pluralize.camelize %>Controller < ApplicationController
2
+ include <%= class_name %><%= step_alias.pluralize.camelize %>Helper
2
3
  before_action :load_<%= file_path %>
3
4
 
4
5
  <%= step_alias.pluralize.upcase %> = %w(<%= steps.to_a.join(' ') %>)
@@ -16,8 +17,8 @@ class <%= class_name %><%= step_alias.pluralize.camelize %>Controller < Applicat
16
17
  end
17
18
 
18
19
  def update
19
- if <%= file_path %>_<%= step_alias %>_model.update_attributes(params[:<%= file_path %>])
20
- if next_<%= step_alias %> && params[:commit].downcase.include?('continue')
20
+ if <%= file_path %>_<%= step_alias %>_model.update_attributes(<%= file_path %>_params || {})
21
+ if next_<%= step_alias %> && params[:commit].downcase.include?('next')
21
22
  redirect_to edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(<%= file_path %>_<%= step_alias %>_model, next_<%= step_alias %>)
22
23
  else
23
24
  redirect_to <%= file_path %>_path(@<%= file_path %>)
@@ -33,18 +34,8 @@ class <%= class_name %><%= step_alias.pluralize.camelize %>Controller < Applicat
33
34
  @<%= file_path %> = <%= file_path %>_<%= step_alias %>_model
34
35
  end
35
36
 
36
- def <%= file_path %>_<%= step_alias %>_model
37
- <%= file_path %>_class = "<%= class_name %>::#{<%= step_alias %>.camelcase}".constantize rescue <%= class_name %>
38
- <%= file_path %>_class.find(params[:<%= file_path %>_id])
39
- end
40
-
41
- def <%= step_alias %>
42
- <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase}
43
- end
44
-
45
- def next_<%= step_alias %>
46
- current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
47
- next_<%= step_alias %> = <%= step_alias.pluralize.upcase %>[current_<%= step_alias %>_index+1]
37
+ def <%= file_path %>_params
38
+ params.require(:<%= file_path %>).permit(<%= controller_attribute_names %>)
48
39
  end
49
40
 
50
41
  end
@@ -3,12 +3,14 @@ module <%= class_name %><%= step_alias.pluralize.camelize %>Helper
3
3
 
4
4
  def <%= file_path %>_<%= step_alias %>_model
5
5
  <%= file_path %>_class = "<%= class_name %>::#{<%= step_alias %>.camelcase}".constantize rescue <%= class_name %>
6
- <%= file_path %>_class.find(params[:<%= file_path %>_id])
6
+ @<%= file_path %> ||= <%= file_path %>_class.find(params[:<%= file_path %>_id])
7
7
  end
8
8
 
9
9
  def <%= step_alias %>
10
- <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase}
10
+ # Filter for security reasons
11
+ @<%= step_alias %> ||= <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase}
11
12
  end
13
+ alias current_<%= step_alias %> <%= step_alias %>
12
14
 
13
15
  def previous_<%= step_alias %>
14
16
  current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
@@ -22,24 +24,30 @@ module <%= class_name %><%= step_alias.pluralize.camelize %>Helper
22
24
  end
23
25
 
24
26
  <% %w(path url).each do |route_term| %>
25
- def first_<%= step_alias %>_<%= route_term %>
26
- <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.first)
27
+ <% ["edit_", ""].each do |action_prefix| %>
28
+ def <%= action_prefix %>first_<%= step_alias %>_<%= route_term %>
29
+ <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.first)
27
30
  end
28
31
 
29
- def previous_<%= step_alias %>_<%= route_term %>
30
- <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(previous_<%= step_alias %>)
32
+ def <%= action_prefix %>previous_<%= step_alias %>_<%= route_term %>
33
+ <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(previous_<%= step_alias %>)
31
34
  end
32
35
 
33
- def next_<%= step_alias %>_<%= route_term %>
34
- <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(next_<%= step_alias %>)
36
+ def <%= action_prefix %>next_<%= step_alias %>_<%= route_term %>
37
+ <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(next_<%= step_alias %>)
35
38
  end
36
39
 
37
- def last_<%= step_alias %>_<%= route_term %>
38
- <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.last)
40
+ def <%= action_prefix %>last_<%= step_alias %>_<%= route_term %>
41
+ <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias.pluralize.upcase %>.last)
39
42
  end
40
43
 
41
- def <%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias %>)
42
- edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_<%= route_term %>(<%= file_path %>_<%= step_alias %>_model, <%= step_alias %>)
44
+ def <%= action_prefix %>current_<%= step_alias %>_<%= route_term %>
45
+ <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias %>)
43
46
  end
47
+
48
+ def <%= action_prefix %><%= file_path %>_<%= step_alias %>_model_<%= route_term %>(<%= step_alias %>)
49
+ <%= action_prefix %><%= file_path %>_<%= file_path %>_<%= step_alias %>_<%= route_term %>(<%= file_path %>_<%= step_alias %>_model, <%= step_alias %>)
50
+ end
51
+ <% end %>
44
52
  <% end %>
45
53
  end
@@ -1,10 +1,6 @@
1
1
  <ul>
2
2
  <%% if <%= "previous_#{step_alias}" %>.present? %>
3
- <li><%%= link_to "Previous <%= step_alias %>", edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(<%= file_path %>_<%= step_alias %>_model, previous_<%= step_alias %>) %></li>
4
- <%% end %>
5
- <%% if <%= "next_#{step_alias}" %>.present? %>
6
- <li><%%= link_to "Next <%= step_alias %>", edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(<%= file_path %>_<%= step_alias %>_model, next_<%= step_alias %>) %></li>
7
- <%% else %>
8
- <li><%%= link_to "Finish <%= step_alias %>", <%= file_path %>_path(<%= file_path %>_<%= step_alias %>_model) %></li>
3
+ <li><%%= link_to "Previous <%= step_alias %>", edit_previous_<%= step_alias %>_path %></li>
9
4
  <%% end %>
5
+ <li><%%= f.submit <%= "next_#{step_alias}" %>.present? ? "next" : "finish" %></li>
10
6
  </ul>
@@ -1,3 +1,6 @@
1
1
  <h1><%= file_path.humanize %> wizard</h1>
2
2
  <h2><%= step_alias.titleize %>: <%= @wizard_step.humanize %></h2>
3
- <%%= render '<%= step_alias %>_navigation' %>
3
+ <%%= form_for <%= file_path %>_<%= step_alias %>_model, :url => current_<%= step_alias %>_path, :as => :<%= file_path %> do |f| %>
4
+ <%%# Please insert the fields of this particular step %>
5
+ <%%= render '<%= step_alias %>_navigation', f: f %>
6
+ <%% end %>
@@ -29,6 +29,10 @@ module UltraLightWizard
29
29
  file_path.pluralize
30
30
  end
31
31
 
32
+ def controller_attribute_names
33
+ [].join(',')
34
+ end
35
+
32
36
  def human_name
33
37
  file_path.humanize
34
38
  end
File without changes
data/ruby187.Gemfile CHANGED
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
File without changes
@@ -1,17 +1,17 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: ultra_light_wizard 0.0.4 ruby lib
5
+ # stub: ultra_light_wizard 0.0.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "ultra_light_wizard"
9
- s.version = "0.0.4"
9
+ s.version = "0.0.5"
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-01-29"
14
+ s.date = "2016-01-30"
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 = [
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  ]
44
44
  s.homepage = "http://github.com/AndyObtiva/ultra_light_wizard"
45
45
  s.licenses = ["MIT"]
46
- s.rubygems_version = "2.4.5.1"
46
+ s.rubygems_version = "2.4.8"
47
47
  s.summary = "Ultra Light & Maintainable Wizards In Rails"
48
48
 
49
49
  if s.respond_to? :specification_version then
File without changes
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.0.4
4
+ version: 0.0.5
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-01-29 00:00:00.000000000 Z
11
+ date: 2016-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jeweler
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.4.5.1
77
+ rubygems_version: 2.4.8
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Ultra Light & Maintainable Wizards In Rails