lib/generators/venomi/install_generator.rb in venomi-0.0.1 vs lib/generators/venomi/install_generator.rb in venomi-0.0.2
- old
+ new
@@ -1,24 +1,32 @@
require 'rails/generators/base'
require 'venomi/rails_admin'
+require 'generators/utils'
module Venomi
module Generators
class InstallGenerator < Rails::Generators::Base
+ include Venomi::Generators::Utils::InstanceMethods
source_root File.expand_path("../../templates", __FILE__)
- desc 'Venomi installation generator'
-
def copy_initializer
- template "translation.rb", "app/models/translation.rb"
- template "locale.rb", "config/initializers/locale.rb"
- template "mongoid.rb", "lib/i18n/backend/mongoid.rb"
+ 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"
+ else
+ say("Mongoid or rails-i18n aren't installed!", :yellow)
+ end
end
def install
case self.behavior
when :invoke
- Venomi::RailsAdmin.configure
+ if libraries_available?("mongoid","rails_admin")
+ Venomi::RailsAdmin.configure
+ else
+ say("Rails-admin isn`t required or installed!", :yellow)
+ end
when :revoke
Venomi::RailsAdmin.rollback
end
end