dm-haml-scaffold-generator 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ class DmHamlScaffoldGenerator < Rails::Generator::NamedBase
83
83
 
84
84
  # partial for the index
85
85
  m.template "dm_haml_scaffold:view__singular_haml.erb",
86
- File.join('app/views', controller_class_path, controller_file_name, "_#{ name.singularize }.#{ default_file_extension }")
86
+ File.join('app/views', controller_class_path, controller_file_name, "_#{ singular_name }.#{ default_file_extension }")
87
87
 
88
88
  # Model class, unit test
89
89
  m.template 'dm_haml_scaffold:model.rb',
@@ -149,23 +149,23 @@ protected
149
149
 
150
150
  def route_resources resource
151
151
  sentinel = 'ActionController::Routing::Routes.draw do |map|'
152
- logger.route "map.resources #{ resource }"
152
+ route_symbol = resource.underscore.pluralize
153
+ logger.route "map.resources #{ route_symbol }"
153
154
  unless options[:pretend]
154
155
  gsub_file 'config/routes.rb', /(#{ Regexp.escape(sentinel) })/mi do |match|
155
156
 
156
157
  if !resource.split('/')[1].nil?
157
158
  one = resource.split('/')[0]
158
- two = resource.split('/')[1]
159
+ two = resource.split('/')[1].underscore
159
160
  "#{ match }\n map.namespace(:#{ one }) do |#{ one }|\n #{ one }.resources :#{ two.pluralize }\n end"
160
161
  else
161
- "#{ match }\n map.resources :#{ resource.pluralize }\n"
162
+ "#{ match }\n map.resources :#{ route_symbol }\n"
162
163
  end
163
164
 
164
165
  end
165
166
  end
166
167
  end
167
168
 
168
-
169
169
  def gsub_file relative_destination, regexp, *args, &block
170
170
  path = destination_path relative_destination
171
171
  content = File.read(path).gsub(regexp, *args, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-haml-scaffold-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - BM5k