Permalink
Browse files

refactor migrations code

  • Loading branch information...
1 parent 858622a commit 30366852c3d5bc49ce310d9e26ca76c7cf7f9768 @raggi committed May 24, 2011
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/openid_active_record_store.rb
@@ -9,17 +9,22 @@ class Railtie < Rails::Railtie
rake_tasks do
namespace :openid_active_record_store do
namespace :install do
- desc "install migrations"
- task :migrations => %w[db/migrations/create_openid_associations.rb db/migrations/create_openid_nonces.rb]
- cp_task = lambda do |t|
- basename = File.basename(t.name)
- cp File.expand_path("../../db/migrations/#{basename}", __FILE__), t.name
+ files = File.expand_path("../../db/migrate/*.rb", __FILE__)
+ sources = FileList[files]
+ targets = sources.map do |source|
+ ts = Time.now.to_f.to_s.sub('.', '')
+ "db/migrate/#{ts}_#{File.basename(source)}"
end
- file 'db/migrations/create_openid_associations.rb', &cp_task
+ desc "install migrations"
+ task :migrations => targets
- file 'db/migrations/create_openid_nonces.rb', &cp_task
+ sources.zip(targets).each do |source, target|
+ file target => source do
+ cp source, target
+ end
+ end
end
end

0 comments on commit 3036685

Please sign in to comment.