Sha256: 03c93dc468b61aff692653539805fec3f76ca1faee28ac823393ad83d23974a3

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 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("/api/v1/domains/")
        res = JSON.parse(get(url))

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

      private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
miteru-1.2.2 lib/miteru/feeds/ayashige.rb
miteru-1.2.1 lib/miteru/feeds/ayashige.rb
miteru-1.2.0 lib/miteru/feeds/ayashige.rb