lib/generators/venomi/install_generator.rb in venomi-0.0.2 vs lib/generators/venomi/install_generator.rb in venomi-0.0.3
- old
+ new
@@ -6,31 +6,38 @@
module Generators
class InstallGenerator < Rails::Generators::Base
include Venomi::Generators::Utils::InstanceMethods
source_root File.expand_path("../../templates", __FILE__)
+ argument :translation_table_name, :type => :string
+
def copy_initializer
if libraries_available?("mongoid", "rails-i18n")
template "mongoid.rb", "lib/i18n/backend/mongoid.rb"
- template "translation.rb", "app/models/translation.rb"
- template "locale.rb", "config/initializers/locale.rb"
+ template "translation.rb.erb", "app/models/#{table_name.downcase}.rb"
+ template "locale.rb.erb", "config/initializers/locale.rb"
else
say("Mongoid or rails-i18n aren't installed!", :yellow)
end
end
def install
case self.behavior
when :invoke
if libraries_available?("mongoid","rails_admin")
- Venomi::RailsAdmin.configure
+ Venomi::RailsAdmin.configure table_name
else
say("Rails-admin isn`t required or installed!", :yellow)
end
when :revoke
- Venomi::RailsAdmin.rollback
+ Venomi::RailsAdmin.rollback table_name
end
end
+
+ private
+ def table_name
+ translation_table_name.downcase.capitalize
+ end
end
end
end