Permalink
Browse files

Added checking of devise and initialisation for it

  • Loading branch information...
1 parent e765186 commit 1905ec20ef38da6187482a09323b875591dbf82d hurrycane committed Aug 25, 2010
View
1 Gemfile
@@ -1,3 +1,4 @@
source 'http://rubygems.org'
+gem 'jeweler'
gem 'devise'
View
10 Gemfile.lock
@@ -5,7 +5,16 @@ GEM
devise (1.1.1)
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)
+ gemcutter (0.6.1)
+ git (1.2.5)
+ jeweler (1.4.0)
+ gemcutter (>= 0.1.0)
+ git (>= 1.2.5)
+ rubyforge (>= 2.0.0)
+ json_pure (1.4.6)
rack (1.2.1)
+ rubyforge (2.0.4)
+ json_pure (>= 1.1.7)
warden (0.10.7)
rack (>= 1.0.0)
@@ -14,3 +23,4 @@ PLATFORMS
DEPENDENCIES
devise
+ jeweler
View
8 lib/generators/rails_admin/install_admin_generator.rb
@@ -0,0 +1,8 @@
+module RailsAdmin
+ class InstallAdminGenerator < Rails::Generators::Base
+
+ source_root File.expand_path("../templates", __FILE__)
+
+ desc "RailsAdmin Install"
+ end
+end
View
54 lib/generators/rails_admin/rails_admin_generator.rb
@@ -0,0 +1,54 @@
+module RailsAdmin
+ class RailsAdminGenerator < Rails::Generators::Base
+ namespace "rails_admin"
+ source_root File.expand_path("../templates", __FILE__)
+
+ desc "RailsAdmin"
+
+ def check_for_devise
+# railsPath = Rails.public_path
+ # search Gemfile for
+# puts __FILE__
+ # check if devise is installed
+# invoke 'devise'
+ loaded_gems = Bundler.setup.gems
+ is_loaded = loaded_gems.reject{|t| t.name == "devise" ? false : true }.size == 1 ? true : false
+
+ if is_loaded
+ #File.exists?
+ devise_path = FileUtils.pwd + "/config/initializers/devise.rb"
+
+ if File.exists?(devise_path)
+ # check if migrations exist
+ app_path = Rails.public_path.split("/")
+ app_path.delete_at(-1)
+ app_path = app_path.join("/")
+ ###
+ routes_path = app_path + "/config/routes.rb"
+
+ content = ""
+
+ File.readlines(routes_path).each{|line|
+ content += line
+ }
+
+ unless content.index("devise_for").nil?
+ # there is a devise_for in routes => Do nothing
+ puts "Great! You have devise installed and setup!"
+ else
+ invoke 'devise', ['user']
+ end
+
+ else
+ invoke 'devise:install'
+ invoke 'devise', ['user']
+ end
+
+ else
+ puts "Please put gem 'devise' into your Gemfile"
+ end
+ end
+
+ end
+end
+# unirii, brinco, obor, opera, kisself, tipogrf, uverturii.
View
7 lib/rails_admin.rb
@@ -1,3 +1,8 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.setup
+
module RailsAdmin
require 'rails_admin/engine' if defined?(Rails)
-end
+end
View
6 rails_admin.gemspec
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.version = "0.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.date = %q{2010-08-21}
+ s.date = %q{2010-08-25}
s.extra_rdoc_files = [
"README"
]
@@ -49,11 +49,13 @@ Gem::Specification.new do |s|
"app/views/rails_admin/list.html.erb",
"app/views/rails_admin/new.html.erb",
"config/routes.rb",
+ "lib/generators/rails_admin/rails_admin_generator.rb",
"lib/rails_admin.rb",
"lib/rails_admin/abstract_model.rb",
"lib/rails_admin/active_record_support.rb",
"lib/rails_admin/engine.rb",
- "lib/rails_admin/generic_support.rb"
+ "lib/rails_admin/generic_support.rb",
+ "lib/rails_admin/railties/tasks.rake"
]
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]

0 comments on commit 1905ec2

Please sign in to comment.