Sha256: 70ab46101d935d37cff242f0d660b2375a607b8ac493ce4ceba743ddf89a5884

Contents?: true

Size: 1007 Bytes

Versions: 3

Compression:

Stored size: 1007 Bytes

Contents

module Sengiri
  class Railtie < Rails::Railtie
    rake_tasks do
      dbdir = Rails.application.config.paths["db"].first
      dirs = Dir.glob(dbdir + '/sengiri/*').select do |f|
        FileTest::directory? f
      end
      sharding_names = dirs.map{|dir| dir.split('/').last }
      sharding_names.each do |name|
        ENV['SHARD'] = name
        load "sengiri/railties/sharding.rake"
      end

      namespace :sengiri do
        task :load_task do
          Rake.application.in_namespace(:sengiri) do
            # load activerecord databasees task in namespace
            spec     = Gem::Specification.find_by_name("activerecord")
            rakefile = spec.gem_dir + "/lib/active_record/railties/databases.rake"
            Rake.load_rakefile rakefile
          end
        end
      end
    end

    generators do
      require "sengiri/generators/sharding_generator"
      require "sengiri/generators/migration_generator"
      require "sengiri/generators/model_generator"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sengiri-0.1.0 lib/sengiri/railtie.rb
sengiri-0.0.2 lib/sengiri/railtie.rb
sengiri-0.0.1 lib/sengiri/railtie.rb