<commit_before>require 'pathname'

module SchemaDev
  GEMFILES_DIR = "gemfiles"

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

    def self.command(opts={})
      opts = opts.keyword_args(rails: :required, db: nil)
      "BUNDLE_GEMFILE=#{gemfile(rails: opts.rails, db: opts.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<commit_msg>fix for use with non-db gemfile setup<commit_after>require 'pathname'

module SchemaDev
  GEMFILES_DIR = "gemfiles"

  module GemfileSelector
    def self.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

    def self.command(opts={})
      opts = opts.keyword_args(rails: :required, db: nil)
      "BUNDLE_GEMFILE=#{gemfile(rails: opts.rails, db: opts.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
{'fraction_non_alphanumeric': 0.14826498422712933, 'fraction_numerical': 0.0012618296529968455, 'mean_word_length': 3.0253807106598987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '953947', 'n_tokens_mistral': 607, 'n_tokens_neox': 587, 'n_words': 125}