Sha256: 503bfb16ac18d293b3dd731b942d6481f0452114465e59d042726666966eab82

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

module Html2rss
  module ItemExtractor
    TEXT = proc { |xml, options| xml.css(options['selector'])&.text&.strip }
    ATTRIBUTE = proc { |xml, options| xml.css(options['selector']).attr(options['attribute']).to_s }

    HREF = proc { |xml, options|
      href = xml.css(options['selector']).attr('href').to_s
      path, query = href.split('?')

      if href.start_with?('http')
        uri = URI(href)
      else
        uri = URI(options['channel']['url'])
        uri.path = path.start_with?('/') ? path : "/#{path}"
        uri.query = query
      end

      uri
    }

    HTML = proc { |xml, options| xml.css(options['selector']).to_s }
    STATIC = proc { |_xml, options| options['static'] }
    CURRENT_TIME = proc { |_xml, _options| Time.new }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
html2rss-0.2.2 lib/html2rss/item_extractor.rb
html2rss-0.2.1 lib/html2rss/item_extractor.rb
html2rss-0.2.0 lib/html2rss/item_extractor.rb
html2rss-0.1.0 lib/html2rss/item_extractor.rb