Sha256: a83d7439589be0fda063562a9d85fbc579913fef09815c92da6021ca4aafe9d1

Contents?: true

Size: 622 Bytes

Versions: 4

Compression:

Stored size: 622 Bytes

Contents

require 'pathname'

module SchemaDev
  GEMFILES_DIR = "gemfiles"

  module GemfileSelector
    def self.gemfile(rails:, db: nil)
      root = Pathname.new(GEMFILES_DIR)
      if db
        root.join("rails-#{rails}", "Gemfile.#{db}")
      else
        root.join("Gemfile.#{rails}")
      end
    end

    def self.command(rails:, db: nil)
      "BUNDLE_GEMFILE=#{gemfile(rails: rails, db: db)}"
    end

    def self.infer_db
      (env = ENV['BUNDLE_GEMFILE']) =~ %r{rails.*/Gemfile[.](.*)}
      $1 or raise "Can't infer db: Env BUNDLE_GEMFILE=#{env.inspect}) isn't a schema_dev Gemfile path with db"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
schema_dev-0.1.3 lib/schema_dev/gemfile_selector.rb
schema_dev-0.1.2 lib/schema_dev/gemfile_selector.rb
schema_dev-0.1.1 lib/schema_dev/gemfile_selector.rb
schema_dev-0.1.0 lib/schema_dev/gemfile_selector.rb