lib/generators/permits/config/config_generator.rb in cream-0.8.5 vs lib/generators/permits/config/config_generator.rb in cream-0.8.6
- old
+ new
@@ -1,19 +1,22 @@
require 'sugar-high/file'
require 'sugar-high/module'
require 'cream'
require 'rails3_artifactor'
require 'logging_assist'
+require 'generators/cream/helpers/all'
module Permits
module Generators
class ConfigGenerator < Rails::Generators::Base
desc "Configure Permits"
# ORM to use
- class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use"
- class_option :roles, :type => :array, :default => ['guest', 'admin'], :desc => "Roles for permits"
+ class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use"
+ class_option :roles, :type => :array, :desc => "Roles for permits"
+ class_option :default_roles, :type => :boolean, :default => true, :desc => "Create default roles :admin and :guest"
+
class_option :logfile, :type => :string, :default => nil, :desc => "Logfile location"
class_option :gems, :type => :boolean, :default => false, :desc => "Add gems to gemfile?"
def configure_permits
logger.add_logfile :logfile => logfile if logfile
@@ -27,50 +30,17 @@
end
protected
include Rails3::Assist::BasicLogger
- extend Rails3::Assist::UseMacro
-
- use_helpers :app, :file, :special
- def gems?
- options[:gems]
- end
-
- # rails generate ...
- def rgen command
- execute "rails g #{command}"
- end
-
- def execute command
- logger.debug command
- run command
- end
-
- def logfile
- options[:logfile]
- end
-
- def roles
- options[:roles]
- end
-
- def roles_list
- roles.join(' ')
- end
-
- def orm
- options[:orm]
- end
-
+ include Cream::GeneratorHelper::Orm
+ include Cream::GeneratorHelper::Executor
+ include Cream::GeneratorHelper::Args
+
def permits_gems
gem 'cancan-permits'
bundle_install # 'cancan-permits'
- end
-
- def bundle_install #*gems
- run "bundle install" # #{gems.jon(' ')}"
end
end
end
end
\ No newline at end of file