Module: SchemaDev::GemfileSelector

Extended by:
GemfileSelector
Included in:
GemfileSelector
Defined in:
lib/schema_dev/gemfile_selector.rb

Instance Method Summary collapse

Instance Method Details

#command(opts = {}) ⇒ Object



19
20
21
22
# File 'lib/schema_dev/gemfile_selector.rb', line 19

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

#gemfile(opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/schema_dev/gemfile_selector.rb', line 9

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

#infer_dbObject



24
25
26
27
# File 'lib/schema_dev/gemfile_selector.rb', line 24

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 Gemfile path with db"
end