Sha256: 7a3c0a78bc5e90b48f56211311cdc98435f994c106137c771d0374123be0dcd3

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

module SchemaDev
  GEMFILES_DIR = 'gemfiles'

  module GemfileSelector
    extend self

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

    def command(activerecord:, db:)
      "BUNDLE_GEMFILE=#{gemfile(activerecord: activerecord, db: 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

4 entries across 4 versions & 1 rubygems

Version Path
schema_dev-4.2.0 lib/schema_dev/gemfile_selector.rb
schema_dev-4.2.beta.5 lib/schema_dev/gemfile_selector.rb
schema_dev-4.1.1 lib/schema_dev/gemfile_selector.rb
schema_dev-4.1.0 lib/schema_dev/gemfile_selector.rb