Sha256: d522baa40ebb26a4efee8fe6704d5b686da7cb7d558f14ac3b15fdc0af347815

Contents?: true

Size: 764 Bytes

Versions: 31

Compression:

Stored size: 764 Bytes

Contents

require 'pathname'

module SchemaDev
  GEMFILES_DIR = "gemfiles"

  module GemfileSelector
    extend self

    def gemfile(opts = {})
      opts = opts.keyword_args(activerecord: :required, db: :required)
      Pathname.new(GEMFILES_DIR).join("activerecord-#{opts.activerecord}", "Gemfile.#{opts.db}")
    end

    def command(opts={})
      opts = opts.keyword_args(activerecord: :required, db: :required)
      "BUNDLE_GEMFILE=#{gemfile(activerecord: opts.activerecord, db: opts.db)}"
    end

    def infer_db
      (env = ENV['BUNDLE_GEMFILE']) =~ %r{activerecord.*/Gemfile[.](.*)}
      $1 or raise "Can't infer db: Env BUNDLE_GEMFILE=#{env.inspect}) isn't a schema_dev standard Gemfile path.  (Run 'schema_dev rspec' instead of 'rspec'?)"
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
schema_dev-4.0.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.13.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.13.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.12.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.12.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.11.2 lib/schema_dev/gemfile_selector.rb
schema_dev-3.11.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.11.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.10.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.10.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.9.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.8.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.8.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.7.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.7.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.6.2 lib/schema_dev/gemfile_selector.rb
schema_dev-3.6.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.6.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.5.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.5.0 lib/schema_dev/gemfile_selector.rb