Sha256: cad308444d8e6b8134353c369e9ac0c82bedb48bb7489e338f775be60d403da7

Contents?: true

Size: 651 Bytes

Versions: 13

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

require 'rails-pg-extras'

namespace :pg_extras do
  task :establish_connection do
    if ENV['DATABASE_URL'].present?
      ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
    else
      db_config_file = File.read('config/database.yml')
      db_config = YAML::load(ERB.new(db_config_file).result)
      ActiveRecord::Base.establish_connection(db_config[Rails.env])
    end
  end

  RailsPGExtras::QUERIES.each do |query_name|
    desc RubyPGExtras.description_for(query_name: query_name)
    task query_name.to_sym => :establish_connection do
      RailsPGExtras.public_send(query_name)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails-pg-extras-2.3.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-2.2.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-2.1.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-2.0.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.6.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.5.3 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.5.2 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.5.1 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.5.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.4.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.3.1 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.3.0 lib/rails-pg-extras/tasks/all.rake
rails-pg-extras-1.2.4 lib/rails-pg-extras/tasks/all.rake