Sha256: 71c51b10305f79ff823315594a0741ad8ed9045f1c7b183437f1864f70432f6d

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

namespace :sunspot do
  namespace :solr do
    desc 'Start the Solr instance'
    task :start => :environment do
      if RUBY_PLATFORM =~ /w(in)?32$/
        abort('This command does not work on Windows. Please use rake sunspot:solr:run to run Solr in the foreground.')
      end
      Sunspot::Rails::Server.start
    end

    desc 'Run the Solr instance in the foreground'
    task :run => :environment do
      Sunspot::Rails::Server.run
    end

    desc 'Stop the Solr instance'
    task :stop => :environment do
      if RUBY_PLATFORM =~ /w(in)?32$/
        abort('This command does not work on Windows.')
      end
      Sunspot::Rails::Server.stop
    end

    desc 'Reindex all solr models'
    task :reindex => :environment do
      all_files = Dir.glob(File.join(RAILS_ROOT, 'app', 'models', '*.rb'))
      all_models = all_files.map { |path| File.basename(path, '.rb').camelize.constantize }
      sunspot_models = all_models.select { |m| m < ActiveRecord::Base and m.searchable? }
      
      sunspot_models.each do |model|
        model.reindex :batch_commit => false
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
sunspot_rails-0.11.5 lib/sunspot/rails/tasks.rb
sunspot_rails-0.11.4 lib/sunspot/rails/tasks.rb
nxa-sunspot_rails-0.11.3 lib/sunspot/rails/tasks.rb
sunspot_rails-0.11.3 lib/sunspot/rails/tasks.rb
sunspot_rails-0.11.2 lib/sunspot/rails/tasks.rb
sunspot_rails-0.11.1 lib/sunspot/rails/tasks.rb
sunspot_rails-0.11.0 lib/sunspot/rails/tasks.rb