Skip to content

Commit

Permalink
Merge pull request #99 from sul-dlss/logs
Browse files Browse the repository at this point in the history
Scripts don't hardcode log names
  • Loading branch information
atz authored Aug 10, 2018
2 parents 19b93da + ce6bcb8 commit 04db652
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Metrics/LineLength:
- spec/preservation_ingest/update_moab_spec.rb # one long ling with fully namespaced classes
- spec/preservation_ingest/validate_bag_spec.rb # one long line with fully namespaced classes
- spec/preservation_ingest/verify_apo_spec.rb # one long line with fully namespaced classes

- spec/lib/reporter_spec.rb # one long line #10

Metrics/MethodLength:
Exclude:
- lib/activity_reporter.rb # converted bash script
Expand Down
9 changes: 1 addition & 8 deletions lib/activity_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ def extract_druid(file, today, counter)
end

def default_log_files
[
"sdr_preservationIngestWF_transfer-object.log",
"sdr_preservationIngestWF_validate-bag.log",
"sdr_preservationIngestWF_verify-apo.log",
"sdr_preservationIngestWF_update-moab.log",
"sdr_preservationIngestWF_update-catalog.log",
"sdr_preservationIngestWF_complete-ingest.log"
].map { |file| "#{Dir.pwd}/log/#{file}" }
Reporter.default_log_files
end
end
9 changes: 1 addition & 8 deletions lib/error_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ def warning_table
end

def default_log_files
[
"sdr_preservationIngestWF_transfer-object.log",
"sdr_preservationIngestWF_validate-bag.log",
"sdr_preservationIngestWF_verify-apo.log",
"sdr_preservationIngestWF_update-moab.log",
"sdr_preservationIngestWF_update-catalog.log",
"sdr_preservationIngestWF_complete-ingest.log"
].map { |file| "#{Dir.pwd}/log/#{file}" }
Reporter.default_log_files
end
end
6 changes: 6 additions & 0 deletions lib/reporter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# houses shared functionality for the *_reporters
class Reporter
def self.default_log_files
Dir.glob("#{Dir.pwd}/log/sdr_preservationIngestWF*.log").sort
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ INFO [2017-04-27 11:07:36] (17545) :: druid:db274ff1758 processing
ERROR [2017-04-27 11:07:37] (17541) :: Some Random Error
/bundle/ruby
/usr/local/rvm
resque-signals/
resque-signals/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INFO [2018-08-03 01:58:11] (31220) :: Testing default_log_files method
4 changes: 2 additions & 2 deletions spec/lib/activity_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
let(:date) { "2017-04-27" }
let(:activity_reporter) { described_class.new }
let(:base_path) { "#{Dir.pwd}/spec/fixtures" }
let(:error_path) { "#{base_path}/sdr_preservationIngestWF_transfer-object.log" }
let(:happy_path) { "#{base_path}/sdr_preservationIngestWF_validate-bag.log" }
let(:error_path) { "#{base_path}/log/sdr_preservationIngestWF_transfer-object.log" }
let(:happy_path) { "#{base_path}/log/sdr_preservationIngestWF_validate-bag.log" }
let(:dbl_date) { instance_double(Time, to_date: date) }
let(:output) { activity_reporter.output }

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/error_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:date) { "2017-04-27" }
let(:dbl_date) { instance_double(Time, to_date: date) }
let(:base_path) { "#{Dir.pwd}/spec/fixtures" }
let(:error_path) { "#{base_path}/sdr_preservationIngestWF_transfer-object.log" }
let(:warn_path) { "#{base_path}/sdr_preservationIngestWF_validate-bag.log" }
let(:error_path) { "#{base_path}/log/sdr_preservationIngestWF_transfer-object.log" }
let(:warn_path) { "#{base_path}/log/sdr_preservationIngestWF_validate-bag.log" }

describe '#table_generator' do
context 'file does not exist' do
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/reporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'reporter'
describe Reporter do
let(:base_path) { "#{Dir.pwd}/spec/fixtures" }

describe '.default_log_files' do
it 'returns a filtered array of log files' do
allow(Dir).to receive(:pwd).and_return(base_path)
expect(described_class.default_log_files).to eq ["#{base_path}/log/sdr_preservationIngestWF_transfer-object.log",
"#{base_path}/log/sdr_preservationIngestWF_validate-bag.log"]
expect(described_class.default_log_files).not_to include "#{base_path}/log/sdr_preservationIngestWF_validate-bag.log.1"
end
end
end

0 comments on commit 04db652

Please sign in to comment.