Sha256: 6b13cf9505035e521f7d144054ddc0215e63cdd7356231fbe2560930bf2d77b1

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

# Get and filter links
module AwesomeBot
  require 'uri'

  class << self
    def links_filter(list)
      list.reject { |x| x.length < 9 }
        .map do |x|
          x.gsub(/'.*/, '').gsub(/,.*/, '').gsub('/:', '/')
        end
        .map do |x|
          if x.include? ')]'
            x.gsub /\)\].*/, ''
          elsif (x.scan(')').count == 2) && (x.scan('(').count == 1)
            x.gsub(/\)\).*/, ')')
          elsif x.scan(')').count > 0
            x.gsub(/\).*/, '')
          elsif x.include? '[' # adoc
            x.gsub(/\[.*/, '')
          else
            x
          end
        end
    end

    def links_find(content)
      URI.extract(content, /http()s?/)
    end
  end # class
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awesome_bot-1.7.1 lib/awesome_bot/links.rb