libis-tools 1.0.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +40 -0
  6. data/Gemfile +7 -0
  7. data/README.md +202 -0
  8. data/Rakefile +11 -0
  9. data/bin/libis_tool +5 -0
  10. data/lib/libis-tools.rb +1 -0
  11. data/lib/libis/tools.rb +25 -0
  12. data/lib/libis/tools/assert.rb +52 -0
  13. data/lib/libis/tools/checksum.rb +106 -0
  14. data/lib/libis/tools/cli/cli_helper.rb +189 -0
  15. data/lib/libis/tools/cli/reorg.rb +416 -0
  16. data/lib/libis/tools/command.rb +133 -0
  17. data/lib/libis/tools/command_line.rb +23 -0
  18. data/lib/libis/tools/config.rb +147 -0
  19. data/lib/libis/tools/config_file.rb +85 -0
  20. data/lib/libis/tools/csv.rb +38 -0
  21. data/lib/libis/tools/deep_struct.rb +71 -0
  22. data/lib/libis/tools/extend/array.rb +16 -0
  23. data/lib/libis/tools/extend/empty.rb +7 -0
  24. data/lib/libis/tools/extend/hash.rb +147 -0
  25. data/lib/libis/tools/extend/kernel.rb +25 -0
  26. data/lib/libis/tools/extend/ostruct.rb +3 -0
  27. data/lib/libis/tools/extend/roo.rb +91 -0
  28. data/lib/libis/tools/extend/string.rb +94 -0
  29. data/lib/libis/tools/extend/struct.rb +29 -0
  30. data/lib/libis/tools/extend/symbol.rb +8 -0
  31. data/lib/libis/tools/logger.rb +130 -0
  32. data/lib/libis/tools/mets_dnx.rb +61 -0
  33. data/lib/libis/tools/mets_file.rb +504 -0
  34. data/lib/libis/tools/mets_objects.rb +547 -0
  35. data/lib/libis/tools/parameter.rb +372 -0
  36. data/lib/libis/tools/spreadsheet.rb +196 -0
  37. data/lib/libis/tools/temp_file.rb +42 -0
  38. data/lib/libis/tools/thread_safe.rb +31 -0
  39. data/lib/libis/tools/version.rb +5 -0
  40. data/lib/libis/tools/xml_document.rb +583 -0
  41. data/libis-tools.gemspec +55 -0
  42. data/spec/assert_spec.rb +65 -0
  43. data/spec/checksum_spec.rb +68 -0
  44. data/spec/command_spec.rb +90 -0
  45. data/spec/config_file_spec.rb +83 -0
  46. data/spec/config_spec.rb +113 -0
  47. data/spec/csv_spec.rb +159 -0
  48. data/spec/data/test-headers.csv +2 -0
  49. data/spec/data/test-headers.tsv +2 -0
  50. data/spec/data/test-noheaders.csv +1 -0
  51. data/spec/data/test-noheaders.tsv +1 -0
  52. data/spec/data/test.data +9 -0
  53. data/spec/data/test.xlsx +0 -0
  54. data/spec/data/test.xml +8 -0
  55. data/spec/data/test.yml +2 -0
  56. data/spec/data/test_config.yml +15 -0
  57. data/spec/deep_struct_spec.rb +138 -0
  58. data/spec/logger_spec.rb +165 -0
  59. data/spec/mets_file_spec.rb +223 -0
  60. data/spec/parameter_container_spec.rb +152 -0
  61. data/spec/parameter_spec.rb +148 -0
  62. data/spec/spec_helper.rb +29 -0
  63. data/spec/spreadsheet_spec.rb +1820 -0
  64. data/spec/temp_file_spec.rb +76 -0
  65. data/spec/test.xsd +20 -0
  66. data/spec/thread_safe_spec.rb +64 -0
  67. data/spec/xmldocument_spec.rb +421 -0
  68. data/test/test_helper.rb +7 -0
  69. data/test/webservices/test_ca_item_info.rb +59 -0
  70. data/test/webservices/test_ca_search.rb +35 -0
  71. metadata +437 -0
@@ -0,0 +1,159 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'rspec/matchers'
4
+ require 'libis/tools/csv'
5
+
6
+ describe 'CSV File' do
7
+
8
+ let(:path) { File.absolute_path('data', File.dirname(__FILE__)) }
9
+ let(:csv) {
10
+ Libis::Tools::Csv.open(
11
+ File.join(path, csv_file),
12
+ required: required_headers,
13
+ optional: optional_headers
14
+ )
15
+ }
16
+
17
+ let(:optional_headers) { [] }
18
+
19
+ after(:example) { csv.close rescue nil }
20
+
21
+ context 'with headers' do
22
+ let(:csv_file) { 'test-headers.csv' }
23
+
24
+ context 'well-formed' do
25
+
26
+ let(:required_headers) { %w'FirstName LastName' }
27
+
28
+ it 'opens correctly' do
29
+ expect{ csv }.not_to raise_error
30
+ end
31
+
32
+ it 'contains expected headers' do
33
+ required_headers.each do |header|
34
+ expect(csv.headers).to include header
35
+ end
36
+ expect(csv.headers).to eq %w'FirstName LastName address'
37
+ end
38
+
39
+ it '#shift returns Row object' do
40
+ row = csv.shift
41
+ expect(row).to be_a CSV::Row
42
+ expect(row['FirstName']).to eq 'John'
43
+ expect(row['LastName']).to eq 'Smith'
44
+ expect(row['address']).to eq 'mystreet 1, myplace'
45
+ expect(row['phone']).to be_nil
46
+ end
47
+
48
+ end
49
+
50
+ context 'not well-formed' do
51
+
52
+ let(:required_headers) { %w'FirstName LastName address phone'}
53
+
54
+ it 'throws error when opened' do
55
+ expect { csv }.to raise_error(RuntimeError, 'CSV headers not found: ["phone"]')
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ context 'without headers' do
62
+ let(:csv_file) { 'test-noheaders.csv' }
63
+
64
+ context 'well-formed and strict' do
65
+ let(:required_headers) { %w'FirstName LastName' }
66
+
67
+ it 'opens correctly' do
68
+ expect { csv }.not_to raise_error
69
+ end
70
+
71
+ it 'contains only required headers' do
72
+ required_headers.each do |header|
73
+ expect(csv.headers).to include header
74
+ end
75
+ expect(csv.headers).to eq %w'FirstName LastName'
76
+ end
77
+
78
+ it '#shift returns Row object' do
79
+ row = csv.shift
80
+ expect(row).to be_a CSV::Row
81
+ expect(row['FirstName']).to eq 'John'
82
+ expect(row['LastName']).to eq 'Smith'
83
+ expect(row['address']).to be_nil
84
+ expect(row['phone']).to be_nil
85
+ end
86
+
87
+ end
88
+
89
+ context 'well-formed with optional headers' do
90
+ let(:required_headers) { %w'FirstName LastName' }
91
+ let(:optional_headers) { %w'address' }
92
+
93
+ it 'opens correctly' do
94
+ expect { csv }.not_to raise_error
95
+ end
96
+
97
+ it 'contains required and optional headers' do
98
+ required_headers.each do |header|
99
+ expect(csv.headers).to include header
100
+ end
101
+ optional_headers.each do |header|
102
+ expect(csv.headers).to include header
103
+ end
104
+ expect(csv.headers).to eq %w'FirstName LastName address'
105
+ end
106
+
107
+ it '#shift returns Row object' do
108
+ row = csv.shift
109
+ expect(row).to be_a CSV::Row
110
+ expect(row['FirstName']).to eq 'John'
111
+ expect(row['LastName']).to eq 'Smith'
112
+ expect(row['address']).to eq 'mystreet 1, myplace'
113
+ expect(row['phone']).to be_nil
114
+ end
115
+
116
+ end
117
+
118
+ context 'missing optional headers' do
119
+
120
+ let(:required_headers) { %w'FirstName LastName address' }
121
+ let(:optional_headers) { %w'phone' }
122
+
123
+ it 'opens correctly' do
124
+ expect { csv }.not_to raise_error
125
+ end
126
+
127
+ it 'contains only required headers' do
128
+ required_headers.each do |header|
129
+ expect(csv.headers).to include header
130
+ end
131
+ optional_headers.each do |header|
132
+ expect(csv.headers).not_to include header
133
+ end
134
+ expect(csv.headers).to eq %w'FirstName LastName address'
135
+ end
136
+
137
+ it '#shift returns Row object' do
138
+ row = csv.shift
139
+ expect(row).to be_a CSV::Row
140
+ expect(row['FirstName']).to eq 'John'
141
+ expect(row['LastName']).to eq 'Smith'
142
+ expect(row['address']).to eq 'mystreet 1, myplace'
143
+ expect(row['phone']).to be_nil
144
+ end
145
+
146
+ end
147
+
148
+ context 'missing required header' do
149
+ let(:required_headers) { %w'FirstName LastName address phone'}
150
+
151
+ it 'throws error when opened' do
152
+ expect { csv }.to raise_error(RuntimeError, 'CSV does not contain enough columns')
153
+ end
154
+
155
+ end
156
+
157
+ end
158
+
159
+ end
@@ -0,0 +1,2 @@
1
+ FirstName,LastName,address
2
+ John,Smith,"mystreet 1, myplace"
@@ -0,0 +1,2 @@
1
+ FirstName LastName address
2
+ John Smith mystreet 1, myplace
@@ -0,0 +1 @@
1
+ John,Smith,"mystreet 1, myplace"
@@ -0,0 +1 @@
1
+ John Smith mystreet 1, myplace
@@ -0,0 +1,9 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultricies condimentum suscipit. Sed nec suscipit sapien. Nullam eget magna fringilla, dignissim justo quis, eleifend sapien. Maecenas quis euismod nunc. Etiam aliquam tellus quis urna pretium ornare. Cras placerat, magna imperdiet vestibulum molestie, sem ante bibendum tortor, nec dapibus augue ligula dictum mauris. In nibh lacus, pellentesque nec posuere non, lacinia et diam. Aliquam dictum, augue sed finibus feugiat, lorem arcu ullamcorper metus, non commodo metus neque sit amet elit. Suspendisse id arcu consequat, euismod leo id, tempus velit. Ut diam leo, pulvinar sed nulla nec, volutpat suscipit ligula. Vestibulum ac erat mauris. Quisque posuere lacus a rutrum faucibus. Sed convallis risus vel congue scelerisque. Vestibulum nec nunc eu massa imperdiet sagittis.
2
+
3
+ Praesent quis felis congue, consequat odio vitae, rhoncus turpis. Suspendisse potenti. Donec rutrum leo vitae ex imperdiet molestie. Vivamus efficitur mi vitae sem porta, vel pretium lacus auctor. Maecenas ac finibus quam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum magna metus, commodo ac ligula vestibulum, aliquet volutpat lacus. Curabitur faucibus nec erat et laoreet. Suspendisse bibendum a tortor non mattis.
4
+
5
+ Curabitur odio turpis, tempus in accumsan aliquet, convallis in elit. Nullam in iaculis turpis, nec pulvinar urna. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Integer mattis erat id auctor ultrices. In placerat euismod elit maximus accumsan. Nullam et enim consectetur, interdum libero sit amet, rutrum risus. Donec eleifend nec erat vel tincidunt. Maecenas pellentesque malesuada fermentum. Cras nisi dolor, dictum eu sagittis quis, consectetur suscipit mi. Cras metus ipsum, porttitor sit amet dignissim id, condimentum eget nunc. Suspendisse potenti.
6
+
7
+ Fusce ante ipsum, tincidunt eget mollis sagittis, consectetur ut ligula. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam augue felis, dictum eget felis non, euismod pharetra libero. Nunc bibendum sollicitudin est vel vulputate. Maecenas et convallis erat. Nullam rutrum molestie justo, sit amet vulputate ligula commodo a. Quisque quis neque id ex sodales aliquam ac id nulla. Nunc ut ligula ut augue placerat vulputate. Donec sed volutpat nibh, et aliquam sapien. Quisque scelerisque et augue faucibus venenatis. Sed viverra, mi ut vestibulum egestas, ante metus pulvinar justo, at aliquet enim nulla eu elit. Aliquam malesuada lectus in tellus euismod, id semper metus tristique.
8
+
9
+ Pellentesque tincidunt nisl ac dolor ornare feugiat. Vivamus dignissim iaculis nunc. Suspendisse et odio velit. Vivamus urna odio, tincidunt id elementum sit amet, dictum vel tortor. Vivamus rutrum magna at nibh sodales, eu venenatis lorem malesuada. Sed bibendum eros eros, vitae aliquam nunc iaculis ac. Maecenas facilisis ipsum in tellus ultricies ornare. Integer finibus eget ante eu consectetur. Nullam rutrum nunc quis sollicitudin pellentesque.
Binary file
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <patron>
3
+ <name>Harry Potter</name>
4
+ <barcode library="Hogwarts Library">1234567890</barcode>
5
+ <access_level>student</access_level>
6
+ <email>harry.potter@hogwarts.edu</email>
7
+ <email>hpotter@JKRowling.com</email>
8
+ </patron>
@@ -0,0 +1,2 @@
1
+ process: 'Test Configuration'
2
+
@@ -0,0 +1,15 @@
1
+ :a:
2
+ :x: 0
3
+ :y: 0
4
+ :z: 0
5
+ :b:
6
+ :x: 10
7
+ :y: -5
8
+ :z: 2.5
9
+ :c:
10
+ -
11
+ -
12
+ :a:
13
+ -
14
+ :a1: 1
15
+ :a2: 2
@@ -0,0 +1,138 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'libis/tools/deep_struct'
4
+
5
+ describe 'DeepStruct' do
6
+
7
+ context 'default contructor' do
8
+
9
+ subject(:ds) { Libis::Tools::DeepStruct.new }
10
+
11
+ it 'should initialize' do
12
+ is_expected.not_to be_nil
13
+ # noinspection RubyResolve
14
+ expect(ds.to_hash).to be_empty
15
+ end
16
+
17
+ end
18
+
19
+ context 'contructed with hash' do
20
+
21
+ let(:hash) { {a: 1, 'b' => '2', c: 3.0} }
22
+ subject(:ds) { Libis::Tools::DeepStruct.new(hash)}
23
+
24
+ it 'has Hash values initialized' do
25
+ expect(ds[:a]).to eq 1
26
+ expect(ds[:b]).to eq '2'
27
+ expect(ds[:c]).to eq 3.0
28
+ expect(ds.to_hash).to eq hash
29
+ end
30
+
31
+ it 'allows access through methods' do
32
+ expect(ds.a).to eq 1
33
+ expect(ds.b).to eq '2'
34
+ expect(ds.c).to eq 3.0
35
+
36
+ ds.a = 5
37
+ expect(ds.a).to be 5
38
+ expect(ds[:a]).to be 5
39
+ expect(ds['a']).to be 5
40
+ end
41
+
42
+ it 'allows access through key strings' do
43
+ expect(ds['a']).to eq 1
44
+ expect(ds['b']).to eq '2'
45
+ expect(ds['c']).to eq 3.0
46
+
47
+ ds['a'] = 5
48
+ expect(ds.a).to be 5
49
+ expect(ds[:a]).to be 5
50
+ expect(ds['a']).to be 5
51
+ end
52
+
53
+ it 'allows access through key symbols' do
54
+ expect(ds[:a]).to eq 1
55
+ expect(ds[:b]).to eq '2'
56
+ expect(ds[:c]).to eq 3.0
57
+
58
+ ds[:a] = 5
59
+ expect(ds.a).to be 5
60
+ expect(ds[:a]).to be 5
61
+ expect(ds['a']).to be 5
62
+ end
63
+
64
+ end
65
+
66
+ context 'initialized with non-hash' do
67
+
68
+ subject(:ds) { Libis::Tools::DeepStruct.new 'abc' }
69
+
70
+ it 'stores value in hash with :default key' do
71
+ expect(ds[:default]).to eq 'abc'
72
+ end
73
+
74
+ end
75
+
76
+ context 'initialized with nil value' do
77
+
78
+ subject(:ds) { Libis::Tools::DeepStruct.new nil }
79
+
80
+ it 'has no data' do
81
+ # noinspection RubyResolve
82
+ expect(ds.to_hash).to be_empty
83
+ end
84
+
85
+ end
86
+
87
+ context 'initialized with recursive hash' do
88
+
89
+ let(:recursive_hash) { {
90
+ a: {x: 0, y: 0, z: 0},
91
+ b: {x: 10, y: -5, z: 2.5},
92
+ c: [
93
+ [
94
+ {a: [ {a1: 1, a2: 2}] },
95
+ ]
96
+ ]
97
+ } }
98
+
99
+ subject(:ds) { Libis::Tools::DeepStruct.new(recursive_hash) }
100
+
101
+ it 'stores recursive Hashes as DeepStructs' do
102
+ expect(ds[:a]).to be_a Libis::Tools::DeepStruct
103
+ expect(ds.b).to be_a Libis::Tools::DeepStruct
104
+ end
105
+
106
+ it 'recurses over arrays' do
107
+ expect(ds.c[0][0]).to be_a Libis::Tools::DeepStruct
108
+ expect(ds.c.first.first.a.first.a1).to eq 1
109
+ expect(ds.c.first.first.a.first.a2).to eq 2
110
+ end
111
+
112
+ it 'can reproduce original hash' do
113
+ expect(ds.to_hash).to eq recursive_hash
114
+ expect(ds.b.to_hash).to eq recursive_hash[:b]
115
+ end
116
+
117
+ it 'clears data and methods' do
118
+ expect(ds).to respond_to 'a'
119
+ expect(ds).to respond_to 'b'
120
+ expect(ds).to respond_to 'c'
121
+ expect(ds).to respond_to 'a='
122
+ expect(ds).to respond_to 'b='
123
+ expect(ds).to respond_to 'c='
124
+
125
+ ds.clear!
126
+ expect(ds.a).to be_nil
127
+ expect(ds.b).to be_nil
128
+ expect(ds.c).to be_nil
129
+ expect(ds).not_to respond_to 'a'
130
+ expect(ds).not_to respond_to 'b'
131
+ expect(ds).not_to respond_to 'c'
132
+ expect(ds).not_to respond_to 'a='
133
+ expect(ds).not_to respond_to 'b='
134
+ expect(ds).not_to respond_to 'c='
135
+ end
136
+
137
+ end
138
+ end
@@ -0,0 +1,165 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'libis/tools/config'
4
+ require 'libis/tools/logger'
5
+
6
+ describe 'Logger' do
7
+
8
+ class TestLogger
9
+ include ::Libis::Tools::Logger
10
+ end
11
+
12
+ before :each do
13
+ ::Libis::Tools::Config.logger.appenders =
14
+ ::Logging::Appenders.string_io('StringIO', layout: ::Libis::Tools::Config.get_log_formatter)
15
+ ::Libis::Tools::Config.logger.level = :all
16
+ end
17
+
18
+ let(:test_logger) { TestLogger.new }
19
+ let(:logoutput) { ::Libis::Tools::Config.logger.appenders.last.sio }
20
+
21
+ let(:timestamp_regex) { '\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3} #\d+\.\d+\]' }
22
+
23
+ context 'with default log configuration' do
24
+
25
+ it 'should log debug output' do
26
+ test_logger.debug 'Debug message'
27
+ output = logoutput.string.lines.map(&:chomp)
28
+ expect(output.size).to eq 1
29
+ expect(output.last).to match /^D, #{timestamp_regex} DEBUG : Debug message$/
30
+ end
31
+
32
+ it 'should log info output' do
33
+ test_logger.info 'Info message'
34
+ output = logoutput.string.lines.map(&:chomp)
35
+ expect(output.size).to eq 1
36
+ expect(output.last).to match /^I, #{timestamp_regex} INFO : Info message$/
37
+ end
38
+
39
+ it 'should log warning output' do
40
+ test_logger.warn 'Warning message'
41
+ output = logoutput.string.lines.map(&:chomp)
42
+ expect(output.size).to eq 1
43
+ expect(output.last).to match /^W, #{timestamp_regex} WARN : Warning message$/
44
+ end
45
+
46
+ it 'should log error output' do
47
+ test_logger.error 'Error message'
48
+ output = logoutput.string.lines.map(&:chomp)
49
+ expect(output.size).to eq 1
50
+ expect(output.last).to match /^E, #{timestamp_regex} ERROR : Error message$/
51
+ end
52
+
53
+ it 'should log fatal output' do
54
+ test_logger.fatal_error 'Fatal message'
55
+ output = logoutput.string.lines.map(&:chomp)
56
+ expect(output.size).to eq 1
57
+ expect(output.last).to match /^F, #{timestamp_regex} FATAL : Fatal message$/
58
+ end
59
+
60
+ it 'should be quiet when asked to' do
61
+ ::Libis::Tools::Config.logger.level = :error
62
+
63
+ test_logger.debug 'Debug message'
64
+ output = logoutput.string.lines.map(&:chomp)
65
+ # noinspection RubyResolve
66
+ expect(output).to be_empty
67
+
68
+ test_logger.info 'Info message'
69
+ output = logoutput.string.lines.map(&:chomp)
70
+ # noinspection RubyResolve
71
+ expect(output).to be_empty
72
+
73
+ test_logger.warn 'Warn message'
74
+ output = logoutput.string.lines.map(&:chomp)
75
+ # noinspection RubyResolve
76
+ expect(output).to be_empty
77
+
78
+ test_logger.error 'Error message'
79
+ output = logoutput.string.lines.map(&:chomp)
80
+ # noinspection RubyResolve
81
+ expect(output).not_to be_empty
82
+
83
+ test_logger.fatal_error 'Fatal message'
84
+ output = logoutput.string.lines.map(&:chomp)
85
+ # noinspection RubyResolve
86
+ expect(output).not_to be_empty
87
+ end
88
+
89
+ end
90
+
91
+ context 'with application configuration' do
92
+
93
+ it 'should print default application name' do
94
+ test_logger.set_application
95
+ test_logger.info 'Info message'
96
+ output = logoutput.string.lines.map(&:chomp)
97
+ expect(output.size).to eq 1
98
+ expect(output.last).to match /^I, #{timestamp_regex} INFO -- TestLogger : Info message$/
99
+ end
100
+
101
+ it 'should print custom application name' do
102
+ test_logger.set_application 'TestApplication'
103
+ test_logger.info 'Info message'
104
+ output = logoutput.string.lines.map(&:chomp)
105
+ expect(output.size).to eq 1
106
+ expect(output.last).to match /^I, #{timestamp_regex} INFO -- TestApplication : Info message$/
107
+ end
108
+
109
+ it 'should allow to turn of application name' do
110
+ test_logger.set_application 'TestApplication'
111
+ test_logger.info 'Info message'
112
+ output = logoutput.string.lines.map(&:chomp)
113
+ expect(output.size).to eq 1
114
+ expect(output.last).to match /^I, #{timestamp_regex} INFO -- TestApplication : Info message$/
115
+ # -- revert to default
116
+ test_logger.set_application
117
+ test_logger.info 'Info message'
118
+ output = logoutput.string.lines.map(&:chomp)
119
+ expect(output.size).to eq 2
120
+ expect(output.last).to match /^I, #{timestamp_regex} INFO -- TestLogger : Info message$/
121
+ # -- turn off
122
+ test_logger.set_application ''
123
+ test_logger.info 'Info message'
124
+ output = logoutput.string.lines.map(&:chomp)
125
+ expect(output.size).to eq 3
126
+ expect(output.last).to match /^I, #{timestamp_regex} INFO : Info message$/
127
+ end
128
+
129
+ end
130
+
131
+ context 'with subject configuration' do
132
+
133
+ it 'should print no subject by default' do
134
+ test_logger.set_subject
135
+ test_logger.info 'Info message'
136
+ output = logoutput.string.lines.map(&:chomp)
137
+ expect(output.size).to eq 1
138
+ expect(output.last).to match /^I, #{timestamp_regex} INFO : Info message$/
139
+ end
140
+
141
+ it 'should print custom subject name' do
142
+ test_logger.set_subject 'TestSubject'
143
+ test_logger.info 'Info message'
144
+ output = logoutput.string.lines.map(&:chomp)
145
+ expect(output.size).to eq 1
146
+ expect(output.last).to match /^I, #{timestamp_regex} INFO - TestSubject : Info message$/
147
+ end
148
+
149
+ it 'should allow to turn off subject name' do
150
+ test_logger.set_subject 'TestSubject'
151
+ test_logger.info 'Info message'
152
+ output = logoutput.string.lines.map(&:chomp)
153
+ expect(output.size).to eq 1
154
+ expect(output.last).to match /^I, #{timestamp_regex} INFO - TestSubject : Info message$/
155
+ # -- turn off
156
+ test_logger.set_subject
157
+ test_logger.info 'Info message'
158
+ output = logoutput.string.lines.map(&:chomp)
159
+ expect(output.size).to eq 2
160
+ expect(output.last).to match /^I, #{timestamp_regex} INFO : Info message$/
161
+ end
162
+
163
+ end
164
+
165
+ end