mondo-generators 0.6.4 → 0.6.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.4
1
+ 0.6.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mondo-generators}
8
- s.version = "0.6.4"
8
+ s.version = "0.6.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Luca Tironi"]
@@ -1,4 +1,15 @@
1
1
  Rails::Generator::Commands::Create.class_eval do
2
+ def route_root(route_options = {})
3
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
4
+
5
+ logger.route "map.root :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
6
+ unless options[:pretend]
7
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
8
+ "#{match}\n map.root :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
9
+ end
10
+ end
11
+ end
12
+
2
13
  def route_resource(*resources)
3
14
  resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
4
15
  sentinel = 'ActionController::Routing::Routes.draw do |map|'
@@ -14,10 +25,10 @@ Rails::Generator::Commands::Create.class_eval do
14
25
  def route_resource_with_options(resource, route_options = {})
15
26
  sentinel = 'ActionController::Routing::Routes.draw do |map|'
16
27
 
17
- logger.route "map.resource #{resource}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
28
+ logger.route "map.resource #{resource.to_sym.inspect}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
18
29
  unless options[:pretend]
19
30
  gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
20
- "#{match}\n map.resource #{resource}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }\n"
31
+ "#{match}\n map.resource #{resource.to_sym.inspect}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }\n"
21
32
  end
22
33
  end
23
34
  end
@@ -44,6 +55,14 @@ Rails::Generator::Commands::Create.class_eval do
44
55
  end
45
56
 
46
57
  Rails::Generator::Commands::Destroy.class_eval do
58
+ def route_root(route_options = {})
59
+ look_for = "\n map.root :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
60
+ logger.route "map.root :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
61
+ unless options[:pretend]
62
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
63
+ end
64
+ end
65
+
47
66
  def route_resource(*resources)
48
67
  resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
49
68
  look_for = "\n map.resource #{resource_list}\n"
@@ -54,8 +73,8 @@ Rails::Generator::Commands::Destroy.class_eval do
54
73
  end
55
74
 
56
75
  def route_resource_with_options(resource, route_options = {})
57
- look_for = "\n map.resource #{resource}, #{route_options}\n"
58
- logger.route "map.resource #{resource}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
76
+ look_for = "\n map.resource #{resource.to_sym.inspect}, #{route_options}\n"
77
+ logger.route "map.resource #{resource.to_sym.inspect}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
59
78
  unless options[:pretend]
60
79
  gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
61
80
  end
@@ -78,13 +97,17 @@ Rails::Generator::Commands::Destroy.class_eval do
78
97
  end
79
98
 
80
99
  Rails::Generator::Commands::List.class_eval do
100
+ def route_root(route_options = {})
101
+ logger.route "map.root :controller => '{options[:controller]}', :action => '#{options[:action]}'"
102
+ end
103
+
81
104
  def route_resource(*resources)
82
105
  resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
83
106
  logger.route "map.resource #{resource_list}"
84
107
  end
85
108
 
86
109
  def route_resource_with_options(resource, route_options = {})
87
- logger.route "map.resource #{resource}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
110
+ logger.route "map.resource #{resource.to_sym.inspect}, :member => { #{route_options[:members]} }, :collection => { #{route_options[:collections]} }"
88
111
  end
89
112
 
90
113
  def route_name(name, path, options = {})
@@ -44,7 +44,8 @@ class MondoAuthenticationGenerator < Rails::Generator::Base
44
44
  m.route_name :signup, '/signup', :controller => user_plural_name, :action => 'new'
45
45
  m.route_name :logout, '/logout', :controller => session_plural_name, :action => 'destroy'
46
46
  m.route_name :login, '/login', :controller => session_plural_name, :action => 'new'
47
- m.route_name :root, '/', :controller => 'static_pages', :action => 'home'
47
+
48
+ m.route_root :controller => 'static_pages', :action => 'home'
48
49
 
49
50
  m.route_resources session_plural_name
50
51
  m.route_resource_with_options user_plural_name, :collections => ':mass_new => :get, :mass_create => :post'
@@ -1,5 +1,5 @@
1
1
  = f.error_messages
2
- - disabled = (permitted_to? :manage, @<%= user_singular_name %>) ? false : true
2
+ - disabled = (permitted_to? :manage, @<%= user_singular_name %>) || @<%= user_singular_name %>.new_record? ? false : true
3
3
  %p
4
4
  = f.label :first_name
5
5
  %br
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 4
9
- version: 0.6.4
8
+ - 5
9
+ version: 0.6.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luca Tironi