the gz file is downloaded but is not extractable. Here is a working program that downloads the file but itself cannot extract it.
require 'open-uri'
require 'zlib'
(2017..2017).each{|year|
(1..1).each{|weekno|
symbols.each{|instrument|
url="https://tickdata.fxcorporate.com/#{instrument}/#{year}/#{weekno}.csv.gz"
puts url
begin
open("#{instrument}#{year}#{weekno}.csv.gz", 'w') do |local_file|
open(url) do |remote_file|
local_file.write(Zlib::GzipReader.new(remote_file).read)
end
end
Zlib::GzipReader.open("#{instrument}#{year}#{weekno}.csv.gz") {|gz|
print gz.read
}
rescue StandardError => e
puts e.message
puts e.backtrace.inspect
end
}
}
}
I get error
https://tickdata.fxcorporate.com/AUDCAD/2017/1.csv.gz
not in gzip format
["downloadtickfiles.rb:26:in `initialize'", "downloadtickfiles.rb:26:in `open'", "downloadtickfiles.rb:26:in `block (3 levels) in <main>'", "downloadtickfiles.rb:16:in `each'", "downloadtickfiles.rb:16:in `block (2 levels) in <main>'", "downloadtickfiles.rb:15:in `each'", "downloadtickfiles.rb:15:in `block in <main>'", "downloadtickfiles.rb:14:in `each'", "downloadtickfiles.rb:14:in `<main>'"]
Related
I want to enumerate through the contents of a tar file in alphabetical order of the filenames contained in the tar file. The following dies with the error Error: closed Gem::Package::TarReader::Entry.
Gem::Package::TarReader.new io do |tar|
tar.sort_by{ |e| e.full_name }.each.map do |tar_entry|
file_contents = tar_entry.read
# more code here, not shown for clarity
file_contents
end
end
Here is the stack trace:
Liquid Exception: closed Gem::Package::TarReader::Entry in /var/sitesUbuntu/www.mslinn.com/_drafts/2020-09-28-using-aws-cloud9-with-jump-server.html
jekyll 3.8.7 | Error: closed Gem::Package::TarReader::Entry
/usr/lib/ruby/2.7.0/rubygems/package/tar_reader/entry.rb:30:in `check_closed': closed Gem::Package::TarReader::Entry (IOError)
from /usr/lib/ruby/2.7.0/rubygems/package/tar_reader/entry.rb:133:in `read'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:14:in `block (2 levels) in untar_contents'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `each'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `each'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `map'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `block in untar_contents'
from /usr/lib/ruby/2.7.0/rubygems/package/tar_reader.rb:29:in `new'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:12:in `untar_contents'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:25:in `block in render'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:24:in `open'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:24:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:91:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:126:in `render_liquid'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:79:in `render_document'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:62:in `run'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:479:in `render_regenerated'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:464:in `block (2 levels) in render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:463:in `each'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:463:in `block in render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:462:in `each_value'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:462:in `render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:191:in `render'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:71:in `process'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/command.rb:28:in `process_site'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:65:in `build'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:36:in `process'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
from /home/mslinn/gems/bin/jekyll:23:in `load'
from /home/mslinn/gems/bin/jekyll:23:in `<main>'
I just had to sort the result:
require 'rubygems/package'
File.open(tar_name, "rb") do |file|
Gem::Package::TarReader.new(file) do |tar|
return tar.each.map { |tar_entry|
if tar_entry.file?
file_contents = tar_entry.read.strip
"<div class='codeLabel'>#{tar_entry.full_name}</div><pre data-lt-active='false'>#{file_contents}</pre>"
else
""
end
}.sort_by{ |e| e.full_name }
end
end
Here is how I actually wrote the code in production:
def traverse_tar(tar_name)
require 'rubygems/package'
File.open(tar_name, "rb") do |file|
Gem::Package::TarReader.new(file) do |tar|
return tar.each.map { |entry|
if entry.file? then { :name => entry.full_name, :content => entry.read.strip } else nil end
}.compact.sort_by { |entry| entry[:name] }.map { |entry|
"<div class='codeLabel'>#{entry[:name]}</div><pre data-lt-active='false'>#{entry[:content]}</pre>"
}
end
end
end
describe "The Original Method list_instances_of_with_resources_change" do
it "Should execute successfully and return Array of Google::Apis::DnsV1::Change object" do
expect{subject_class::list_instances_of_with_resources_change("Dummy ID",custom_params)}.to raise_error
end
end
The error which I am getting.
2) Testing Change Resource : The Original Method list_instances_of_with_resources_change Should execute successfully and return Array of Google::Apis::DnsV1::Change object
Failure/Error: response = client.send("list_changes", project, managed_zone, max_results:max_results, page_token:page_token, sort_by:sort_by, sort_order:sort_order)
Google::Apis::ClientError:
invalid: Invalid value for project: graphite-development1
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:211:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/api_command.rb:102:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:179:in `process_response'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:286:in `execute_once'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:107:in `block (2 levels) in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:104:in `block in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:96:in `execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/base_service.rb:345:in `execute_or_queue_command'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/generated/google/apis/dns_v1/service.rb:191:in `list_changes'
# ./lib/puppet_x/puppetlabs/google_cloud_dns/provider.rb:165:in `list_instances_of_change'
# ./spec/unit/neg_google_cloud_dns_change_spec.rb:24:in `block (2 levels) in <top (required)>'
I have an URL that I can't access with Mechanize and I don't know why:
# Use ruby 2.1.6
require 'mechanize'
require 'axlsx' # 2.0.1
require 'roo' # 1.13.2
mechanize = Mechanize.new
mechanize.request_headers = { "Accept-Encoding" => "" }
mechanize.ignore_bad_chunking = true
mechanize.follow_meta_refresh = true
xlsx = Roo::Excelx.new("./base_list.xlsx")
xlsx.each_with_pagename do |page, sheet|
sheet.each do |row|
page = mechanize.get(row[0])
end
end
When I iterate on my list I get urls like : https://angel.co/_helencousins, I can access it with my browser but not with Mechanize, and I have this error:
/.rvm/gems/ruby-2.1.6/gems/mechanize-2.7.4/lib/mechanize/http/agent.rb:316:in `fetch': 404 => Net::HTTPNotFound for https://angel.co/_helencousins -- unhandled response (Mechanize::ResponseCodeError)
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/mechanize-2.7.4/lib/mechanize.rb:464:in `get'
from scraper.rb:15:in `block (2 levels) in <main>'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:428:in `block in each'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:427:in `upto'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:427:in `each'
from scraper.rb:14:in `block in <main>'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:398:in `block in each_with_pagename'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:397:in `each'
from /Users/xxx/.rvm/gems/ruby-2.1.6/gems/roo-1.13.2/lib/roo/base.rb:397:in `each_with_pagename'
from scraper.rb:13:in `<main>'
Ok,
The problème was that the website disable the Mechanize user agent.
I just changed it to : mechanize.user_agent_alias = 'Windows Chrome'
I made rake task.
My rails app is running without problems.
Code
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name.nil?
model2hash(model)
end
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end
Error
** Invoke i18n_master:check (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute i18n_master:check
rake aborted!
TypeError: no implicit conversion of nil into String
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quote_ident'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quoted'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/quoting.rb:31:in `quote_table_name'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:742:in `column_definitions'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/schema_statements.rb:186:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/attributes.rb:93:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/model_schema.rb:260:in `column_names'
ror_app/lib/tasks/i18n_master.rake:13:in `model2hash'
ror_app/lib/tasks/i18n_master.rake:6:in `block (3 levels) in <top (required)>'
ror_app/lib/tasks/i18n_master.rake:4:in `map'
ror_app/lib/tasks/i18n_master.rake:4:in `block (2 levels) in <top (required)>'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/bin/rake:37:in `<main>'
Tasks: TOP => i18n_master:check
I read this
Rails 4.0.0 - Got "no implicit conversion of nil into String"
the above problems is gem for sqlite3.
so I think my problem is gem for postgresql.
But My rails app is running without problems.
And I use bundle.
% bundle pristine
Could not find command "pristine".
Why
Why TypeError: no implicit conversion of nil into String is occur in utils.rb:24:in quote_ident'
How to fix it?
I got it.
Globalize::ActiveRecord::Translation#column_names occur this error.
so, skip this.
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name == 'Globalize::ActiveRecord::Translation'
model2hash(model)
end.compact
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end
Same script different error. This might be related more to my network instead of my code. The script is as follows:
#!/usr/bin/env ruby -rubygems
require File.join(File.dirname(__FILE__), 'authentication')
require "csv" # faster_csv (ruby 1.9)
lines = CSV.read(File.join(File.dirname(__FILE__), 'karaoke.csv')) # Exported an Excel file as CSV
lines.slice!(0) # remove header line
collection = StorageRoom::Collection.find('collection ID')
Song = collection.entry_class
lines.each do |row|
karaoke = Song.new(:artist => row[0], :song => row[1], :genre => row[2], :file => StorageRoom::File.new_with_filename("#{karaoke.artist}#{karaoke.song}.mov"))
if karaoke.save
puts "Song saved: #{karaoke.artist}, #{karaoke.song}, #{karaoke.genre}"
else
puts "Song could not be saved: #{karaoke.errors.join(', ')}"
end
end
And the error is:
/usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error)
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:134:in `rbuf_fill'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:627:in `start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty/request.rb:73:in `perform'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:391:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib/httparty.rb:359:in `post'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:69:in `block (2 levels) in create'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:403:in `_run__3801264735883484179__create__2558870880708463764__callbacks'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:68:in `block in create'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:403:in `_run__3801264735883484179__save__2558870880708463764__callbacks'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:67:in `create'
from /home/hanleyhansen/Desktop/thriventures-storage_room_gem-f7015ed/lib/storage_room/model.rb:61:in `save'
from import_csv.rb:17:in `block in <main>'
from import_csv.rb:14:in `each'
from import_csv.rb:14:in `<main>'
I'm interested in learning why this error occurred as well as the solution. Thanks in advance!
Found this while perusing the web. Hopes it helps somebody! Setting a longer timeout
Here is how you can adjust the timeout in the Net::HTTP API:
require 'net/http'
http = Net::HTTP.new(#host, #port)
http.read_timeout = 500