Sha256: 053bfcd77a5e52f1362c0beb2ab51990c44590d042df30bc81d2ef22f5c9de85

Contents?: true

Size: 754 Bytes

Versions: 26

Compression:

Stored size: 754 Bytes

Contents

#!/usr/bin/env ruby

scrappers = []
results = []

class QuotedUrlScrapper
  REGEX = /"\w+:\/\/[^"]+"/
  def initialize(text)
    @text = text
  end
  def get_urls
    @text.scan(REGEX).map do |url|
      url.chop!
      url.reverse.chop.reverse
    end
  end
end

class TextUrlScrapper
  REGEX = /\w+:\/\/[^\s]+/
  def initialize(text)
    @text = text
  end
  def get_urls
    @text.scan(REGEX).map do |url|
      url.gsub!(/".*/, '')
      url.gsub!(/'.*/, '')
    end
  end
end

scrappers.push(QuotedUrlScrapper)
scrappers.push(TextUrlScrapper)

STDIN.each_line do |line|
  scrappers.each do |scrapper|
    parser = scrapper.new(line)
    parser.get_urls.each do |url|
      results << url
    end
  end
end

results.uniq.each do |url|
  puts url
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ix-cli-0.0.27 bin/ix-urls
ix-cli-0.0.26 bin/ix-urls
ix-cli-0.0.25 bin/ix-urls
ix-cli-0.0.24 bin/ix-urls
ix-cli-0.0.23 bin/ix-urls
ix-cli-0.0.22 bin/ix-urls
ix-cli-0.0.21 bin/ix-urls
ix-cli-0.0.20 bin/ix-urls
ix-cli-0.0.19 bin/ix-urls
ix-cli-0.0.18 bin/ix-urls
ix-cli-0.0.17 bin/ix-urls
ix-cli-0.0.16 bin/ix-urls
ix-cli-0.0.15 bin/ix-urls
ix-cli-0.0.14 bin/ix-urls
ix-cli-0.0.13 bin/ix-urls
ix-cli-0.0.12 bin/ix-urls
ix-cli-0.0.11 bin/ix-urls
ix-cli-0.0.10 bin/ix-urls
ix-cli-0.0.9 bin/ix-urls
ix-cli-0.0.7 bin/ix-urls