Skip to content

Commit e6b56c3

Browse files
authored
Merge pull request #163 from tulibraries/DEVO-654-ruby-upgrade
Update ingest command
2 parents baba026 + 68be411 commit e6b56c3

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

exe/cob_web_index

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ class App
3333
end
3434

3535
if options["use-fixtures"]
36-
CobWebIndex::CLI.ingest_fixtures(opts)
36+
CobWebIndex::CLI.ingest_fixtures(**opts)
3737
elsif args.empty?
38-
CobWebIndex::CLI.pull(opts)
38+
CobWebIndex::CLI.pull(**opts)
3939
else
40-
CobWebIndex::CLI.ingest(opts.merge(ingest_path: args[0], delete_collection: true))
40+
opts.merge!(ingest_path: args[0], delete_collection: true)
41+
CobWebIndex::CLI.ingest(**opts)
4142
end
4243
end
4344
end

lib/cob_web_index.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def self.ingest(ingest_path: nil, ingest_string: "", **opts)
1717
if ingest_path
1818
logger.info "Ingesting #{ingest_path}"
1919
ingest_string = CobWebIndex::CLI.open_read(ingest_path)
20+
2021
data = JSON.parse(ingest_string).fetch("data")
2122

2223
# Protect against trying to ingest nil data
@@ -60,7 +61,8 @@ def self.open_read(url)
6061
options = { http_basic_authentication: [ENV["WEB_CONTENT_BASIC_AUTH_USER"], ENV["WEB_CONTENT_BASIC_AUTH_PASSWORD"]] }
6162
end
6263
options[:read_timeout] = ENV["WEB_CONTENT_READ_TIMEOUT"].to_i if ENV["WEB_CONTENT_READ_TIMEOUT"]
63-
URI.open(url, options).read
64+
file = options.empty? ? URI.open(url) : URI.open(url, options)
65+
file.read
6466
end
6567

6668
def self.ingest_fixtures(opts = {})

spec/cob_web_index_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
}
9797

9898
it "receives no options" do
99-
expect(URI).to receive(:open).with(uri, {})
99+
expect(URI).to receive(:open).with(uri)
100100
CobWebIndex::CLI.open_read(uri)
101101
end
102102

0 commit comments

Comments
 (0)