Sha256: f7ab0539d3976c95b257b197431a6372060b8c87b7d7cd1e8a5f2d3354987a07

Contents?: true

Size: 668 Bytes

Versions: 18

Compression:

Stored size: 668 Bytes

Contents

require 'pathname'

module SchemaDev
  GEMFILES_DIR = "gemfiles"

  module GemfileSelector
    extend self

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

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

    def 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 standard Gemfile path"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
schema_dev-2.0.4 lib/schema_dev/gemfile_selector.rb
schema_dev-2.0.3 lib/schema_dev/gemfile_selector.rb
schema_dev-2.0.2 lib/schema_dev/gemfile_selector.rb
schema_dev-2.0.1 lib/schema_dev/gemfile_selector.rb
schema_dev-2.0.0 lib/schema_dev/gemfile_selector.rb
schema_dev-1.4.0 lib/schema_dev/gemfile_selector.rb
schema_dev-1.3.0 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.5 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.4 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.3 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.2 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.1 lib/schema_dev/gemfile_selector.rb
schema_dev-1.2.0 lib/schema_dev/gemfile_selector.rb
schema_dev-1.1.0 lib/schema_dev/gemfile_selector.rb
schema_dev-1.0.3 lib/schema_dev/gemfile_selector.rb
schema_dev-1.0.2 lib/schema_dev/gemfile_selector.rb
schema_dev-1.0.1 lib/schema_dev/gemfile_selector.rb
schema_dev-1.0.0 lib/schema_dev/gemfile_selector.rb