Class: Miteru::Feeds::Base

Inherits:
Service
  • Object
show all
Defined in:
lib/miteru/feeds/base.rb

Direct Known Subclasses

Ayashige, PhishingDatabase, TweetFeed, UrlScan, UrlScanPro

Constant Summary collapse

IGNORE_EXTENSIONS =
%w[.htm .html .php .asp .aspx .exe .txt].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call, #result, result

Constructor Details

#initialize(base_url) ⇒ Base

Returns a new instance of Base.

Parameters:

  • base_url (String)


17
18
19
20
21
22
# File 'lib/miteru/feeds/base.rb', line 17

def initialize(base_url)
  super()

  @base_url = base_url
  @headers = {}
end

Instance Attribute Details

#base_urlString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/miteru/feeds/base.rb', line 9

def base_url
  @base_url
end

#headersHash (readonly)

Returns:

  • (Hash)


12
13
14
# File 'lib/miteru/feeds/base.rb', line 12

def headers
  @headers
end

Class Method Details

.inherited(child) ⇒ Object



54
55
56
57
# File 'lib/miteru/feeds/base.rb', line 54

def inherited(child)
  super
  Miteru.feeds << child
end

Instance Method Details

#callArray<Miteru::Website>

Returns:



49
50
51
# File 'lib/miteru/feeds/base.rb', line 49

def call
  decomposed_urls.map { |url| Website.new(url, source:) }
end

#decomposed_urlsArray<String>

Return decomposed URLs

Returns:

  • (Array<String>)

    Decomposed URLs



42
43
44
# File 'lib/miteru/feeds/base.rb', line 42

def decomposed_urls
  urls.uniq.select { |url| url.start_with?("http://", "https://") }.map { |url| decompose(url) }.flatten.uniq
end

#sourceObject



24
25
26
# File 'lib/miteru/feeds/base.rb', line 24

def source
  @source ||= self.class.to_s.split("::").last
end

#urlsArray<String>

Return URLs

Returns:

  • (Array<String>)

    URLs

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/miteru/feeds/base.rb', line 33

def urls
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
end