Sha256: e9ada13d1401e9ff3a90539a46414bdb8c1965ca252b1193a2494ca0c352c816

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

require "json"
require "uri"

module Miteru
  class Feeds
    class Ayashige < Feed
      HOST = "ayashige.herokuapp.com"
      URL = "https://#{HOST}"

      def urls
        url = url_for("/feed")
        res = JSON.parse(get(url))

        domains = res.map { |item| item["domain"] }
        domains.map do |domain|
          [
            "https://#{domain}",
            "http://#{domain}"
          ]
        end.flatten
      rescue HTTPResponseError, JSON::ParserError => e
        puts "Failed to load ayashige feed (#{e})"
        []
      end

      private

      def url_for(path)
        URI(URL + path)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miteru-0.12.10 lib/miteru/feeds/ayashige.rb
miteru-0.12.9 lib/miteru/feeds/ayashige.rb