Skip to content
Browse files

rails engine stuff

  • Loading branch information...
1 parent 58aefb8 commit 7103c92bfb68651282e7a7c87b056fcbd663fe14 @raggi committed
View
0 migrations/create_openid_associations.rb → db/migrations/create_openid_associations.rb
File renamed without changes.
View
0 migrations/create_openid_nonces.rb → db/migrations/create_openid_nonces.rb
File renamed without changes.
View
53 install.rb
@@ -1,53 +0,0 @@
-# Install hook code here
-
-require 'ftools'
-
-# keep everything in this scope
-class InstallOpenIdActiveRecordStore
-
- def initialize
- show_banner
- check_system_consistency
- copy_migration_files
- end
-
- def here
- File.dirname(__FILE__)
- end
-
- def sources
- Dir.glob(File.join([here, 'migrations', '*.*']))
- end
-
- def target
- File.join([here, '..', '..', '..', 'db', 'migrate'])
- end
-
- def validate_file_existence(file)
- abort "File not found: #{target}" unless File.exist? file
- end
-
- def show_banner
- puts '
- ** Copying migrations to your application
- '
- end
-
- def check_system_consistency
- validate_file_existence(target)
- sources.each { |file| validate_file_existence(file) }
- end
-
- def copy_migration_files
- sources.each do |file|
- File.copy(file, target)
- puts "
- Source : #{file}
- Target : #{target}
- "
- end
- end
-
-end
-
-InstallOpenIdActiveRecordStore.new
View
8 lib/openid_active_record_store.rb
@@ -0,0 +1,8 @@
+require 'rails/engine'
+require 'openid/store/active_record'
+
+module OpenidActiveRecordStore
+ class Engine < Rails::Engine
+ config.eager_load_paths << File.expand_path("../../app/models", __FILE__)
+ end
+end
View
7 test/test_helper.rb
@@ -1,5 +1,5 @@
require 'test/unit'
-require 'openid/store/active_record'
+require 'openid_active_record_store'
require 'active_record'
db = {
@@ -7,17 +7,18 @@
:database => 'openid_active_record_store'
}
+# XXX yes, there are better ways. patches please!
+
system "echo 'drop database #{db[:database]};' | mysql5 -uroot" rescue nil
system "echo 'create database #{db[:database]};' | mysql5 -uroot"
ActiveRecord::Base.establish_connection db
-# TODO removeme once the railtie bootstrap is used
Dir['app/models/*.rb'].each do |model|
require File.expand_path(model)
end
-Dir['migrations/*.rb'].each do |migration|
+Dir['db/migrations/*.rb'].each do |migration|
require migration
Object.const_get(File.basename(migration, '.rb').camelize).up
end
View
55 uninstall.rb
@@ -1,55 +0,0 @@
-# Uninstall hook code here
-
-require 'ftools'
-
-# keep everything inside fo this scope
-class UnInstallOpenIdActiveRecordStore
-
- def initialize
- show_banner
- check_system_cosistency
- remove_migration_files
- end
-
- def here
- File.dirname(__FILE__)
- end
-
- def sources
- Dir.glob(File.join([here, 'migrations', '*.*']))
- end
-
- def migrations_files
- Dir.glob(File.join([target, '*.*']))
- end
-
- def validate_file_existance(file)
- abort "File not found: #{target}" unless File.exist? file
- end
-
- def show_banner
- puts '
- ** Deleting migrations to your application
- '
- end
-
- def check_system_cosistency
- validate_file_existance(target)
- sources.each { |file| validate_file_existance(file) }
- end
-
- def remove_migration_files
- migrations_files.each do |file|
- puts 'Will delete ' + file
- validate_file_existance(file)
- File.rm_f file
- end
- end
-
- def target
- File.join([here, '..', '..', '..', 'db', 'migrate'])
- end
-
-end
-
-UnInstallOpenIdActiveRecordStore.new

0 comments on commit 7103c92

Please sign in to comment.
Something went wrong with that request. Please try again.