<commit_before>class GemfileParser
  attr_reader :gemfile

  def self.gems_status gemfile
    new(gemfile).gems_status
  end

  def initialize gemfile
    @gemfile = gemfile
  end

  def gems_status
    gemfile
      .scan(/gem\s+['"](\w+)['"]/)
      .flatten
      .reject { |gem| gem == "rails" }
      .map { |gem| Rubygem.by_name(gem).first }
      .compact
  end
end
<commit_msg>Refactor GemParser class<commit_after>class GemfileParser
  attr_reader :gemfile

  EXCLUDED = ["rails"]

  def self.gems_status gemfile
    new(gemfile).gems_status
  end

  def initialize gemfile
    @gemfile = gemfile
  end

  def gems_status
    Rubygem.where(name: gems_without_excluded).to_a
  end

  private

  def gems_without_excluded
    gems.reject { |gem| EXCLUDED.include? gem }
  end

  def gems
    gemfile.scan(/gem\s+['"](\w+)['"]/).flatten
  end
end

{'fraction_non_alphanumeric': 0.11254396248534584, 'fraction_numerical': 0.0, 'mean_word_length': 2.972093023255814, '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': '2058947', 'n_tokens_mistral': 328, 'n_tokens_neox': 302, 'n_words': 67}