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-3.4.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.3.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.2.4 lib/schema_dev/gemfile_selector.rb
schema_dev-3.2.3 lib/schema_dev/gemfile_selector.rb
schema_dev-3.2.2 lib/schema_dev/gemfile_selector.rb
schema_dev-3.2.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.2.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.1.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.1.0 lib/schema_dev/gemfile_selector.rb
schema_dev-3.0.1 lib/schema_dev/gemfile_selector.rb
schema_dev-3.0.0 lib/schema_dev/gemfile_selector.rb