Sha256: 440c24829a3d78a319fbf84fe1dc9d8b260c106da2ed96527146589d50308d03

Contents?: true

Size: 928 Bytes

Versions: 2

Compression:

Stored size: 928 Bytes

Contents

namespace :db do
  desc "Loads seed data from schema/data for the current environment."
  task :seed => :merb_env do
    require File.join( File.dirname(__FILE__), "seeder")
    
    # load ruby seed files
    seed_path = ENV["SEED_PATH"] ? ENV["SEED_PATH"] : (Merb::Plugins.config[:merb_seed][:seed_path] || "schema/data")
    Dir[File.join(Merb.root, seed_path, '*.rb')].sort.each { |seed| 
      puts "\n== Seeding from #{File.split(seed).last} " + ("=" * (60 - (17 + File.split(seed).last.length)))
      load seed 
      puts "=" * 60 + "\n"
    }
    
    # load environment specific seed files
    Dir[File.join(Merb.root, seed_path, Merb.env, '*.rb')].sort.each { |seed| 
      puts "\n== [#{Merb.env}] Seeding from #{File.split(seed).last} " + ("=" * (60 - (20 + File.split(seed).last.length + Merb.env.length)))
      load seed 
      puts "=" * 60 + "\n"
    }
    
    # load seed files from yml
    # TODO
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
merb_seed-0.1.0 lib/merb_seed/merbtasks.rb
merb_seed-0.1.1 lib/merb_seed/merbtasks.rb