I'm trying to parse 3 arguments (this works) and request a file that has a bunch of txt and URLs in it. I'm trying to put each URL into an array I have try with some regexp with no luck and also with scan(URI.regexp)
et.c and cant see to figure what I'm doing wrong.
#!/usr/bin/env ruby
require 'uri'
require 'open-uri'
HOST=ARGV[0]
ID=ARGV[1]
VERSION=ARGV[2]
MYLINKS = Array.new
file = open("http://#{HOST}/v1/dc/manifest/#{ID}/#{VERSION}").read
file.each_line do |line|
#puts "doing #{line}" # this works..
MYLINKS << URI.extract(line, ['http', 'https'])
end
PS: the file is a JSON file. This is all working on a Bash script but I'm migrating it to Ruby. In the Bash script I download the file to /tmp
then I parse it with awk
/tr
etc.