lib/volt/cli/generate.rb in volt-0.9.3.pre3 vs lib/volt/cli/generate.rb in volt-0.9.3.pre4
- old
+ new
@@ -31,11 +31,16 @@
desc: 'Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)'
def gem(name)
require 'volt/cli/new_gem'
+ # remove prefixed volt-
+ name = name.gsub(/^volt[-]/, '')
+
if name =~ /[-]/
+ require 'volt'
+ require 'volt/extra_core/logger'
Volt.logger.error('Gem names should use underscores for their names. Currently volt only supports a single namespace for a component.')
return
end
NewGem.new(self, name, options)
@@ -60,15 +65,15 @@
desc 'controller NAME COMPONENT', 'Creates a model controller named NAME in the app folder of the component named COMPONENT.'
method_option :name, type: :string, banner: 'The name of the model controller.'
method_option :component, type: :string, default: 'main', banner: 'The component the controller should be created in.', required: false
def controller(name, component = 'main')
- controller_name = name.underscore.pluralize + '_controller' unless name =~ /_controller$/
+ controller_name = name.underscore + '_controller' unless name =~ /_controller$/
output_file = Dir.pwd + "/app/#{component.underscore}/controllers/#{controller_name}.rb"
- spec_file = Dir.pwd + "/spec/app/#{component.underscore}/integration/#{name.underscore.pluralize}_spec.rb"
+ spec_file = Dir.pwd + "/spec/app/#{component.underscore}/integration/#{name.underscore}_spec.rb"
template('controller/model_controller.rb.tt', output_file, component_module: component.camelize, model_controller_name: controller_name.camelize)
- template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore.pluralize)
+ template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore)
end
desc 'task NAME COMPONENT', 'Creates a task named NAME in the app folder of the component named COMPONENT.'
method_option :name, type: :string, banner: 'The name of the task.'
method_option :component, type: :string, default: 'main', banner: 'The component the task should be created in.', required: false