Sha256: 513514354247c283292e3ccfddb839d0ddccf306b8af35b368ac7252d766a288

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

module Mako
  class SubscriptionListParser
    include FileOpenUtil

    attr_reader :list

    def initialize(args)
      @list = args.fetch(:list)
    end

    # Parses OPML, JSON, or plain text documents and returns an Array of feed urls.
    #
    # @return [Array]
    def parse
      loaded_list = load_resource(list)
      case File.extname list
      when '.xml' || '.opml'
        Nokogiri::XML(loaded_list).xpath('//@xmlUrl').map(&:value)
      when '.json'
        JSON.parse(loaded_list)
      when '.txt'
        loaded_list.split("\n")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mako_rss-0.1.0 lib/mako/subscription_list_parser.rb