<commit_before>require 'nokogiri'

module Feed2Email
  class OPMLImporter
    def self.import(path)
      require 'feed2email/feed'

      n = 0

      open(path) do |f|
        new(f).import do |uri|
          feed = Feed.create(uri: uri)
          puts "Imported feed: #{feed}"
          n += 1
        end
      end

      n
    end

    def initialize(io)
      @io = io
    end

    def import
      uris.each {|uri| yield uri }
    end

    private

    def data
      io.read
    end

    def io; @io end

    def uris
      Nokogiri::XML(data).css('opml body outline').map {|outline|
        outline['xmlUrl']<commit_msg>Pass import block to each directly<commit_after>require 'nokogiri'

module Feed2Email
  class OPMLImporter
    def self.import(path)
      require 'feed2email/feed'

      n = 0

      open(path) do |f|
        new(f).import do |uri|
          feed = Feed.create(uri: uri)
          puts "Imported feed: #{feed}"
          n += 1
        end
      end

      n
    end

    def initialize(io)
      @io = io
    end

    def import(&blk)
      uris.each(&blk)
    end

    private

    def data
      io.read
    end

    def io; @io end

    def uris
      Nokogiri::XML(data).css('opml body outline').map {|outline|
        outline['xmlUrl']
{'fraction_non_alphanumeric': 0.10062893081761007, 'fraction_numerical': 0.006289308176100629, 'mean_word_length': 1.6970338983050848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7126417', 'n_tokens_mistral': 447, 'n_tokens_neox': 424, 'n_words': 119}