Sha256: d0d4fb32736b6bc8733b935e6d5ec1dd510cb9159510e921842e26a031a32f92

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 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
        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-1.1.0 lib/miteru/feeds/ayashige.rb
miteru-1.0.2 lib/miteru/feeds/ayashige.rb