rake-funnel 0.9.0.pre → 0.9.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a24c43a1a9f0170bc60541024af1b0c7fba00bbe
4
- data.tar.gz: 6781d9f355a322c4aa2a317466345d31e6c1df7c
3
+ metadata.gz: 654127b97949b02eee869ea2a09be66f9f2a310d
4
+ data.tar.gz: 612b33cf3287735aa3a0cf5454188dae4266f299
5
5
  SHA512:
6
- metadata.gz: 16ee74bb0cefd902f980df81fb4e685ae6446d8fb67e8e6f28d6677c4551f224919f9e9775d9e641e6633a7e12bb5df83a6cc9240dee07d438ba960a093054b9
7
- data.tar.gz: a812455493c6c84e4187ae4376559f81834a1fd2a7f3de66e11f5c445ca5f587908b62dbe4bb7d54f16b87081e27e4ba2ec34281c7762c2cbc6eaba0252196f2
6
+ metadata.gz: 4551b61164ed3a434664ae5a81c975397617783407e0bcef7e937fe2822331299e79161fee40744c26833976111f3540a748bdcf7c302fd286c41c0fc164a3eb
7
+ data.tar.gz: a8ee0e0085f6f8bd9109669340ae4257919f97e906175190b977d507fd0641d141ad276b452e2a91a18b55ba0102f114be97ed03a7190e01791f79d0154d3301
@@ -14,18 +14,26 @@ module Rake
14
14
  end
15
15
 
16
16
  def to_s
17
- msg = []
18
- (msg << description) if description
19
- (msg << "Search pattern used: #{@search_pattern}") if @search_pattern
20
- unless (@candidates || []).empty?
21
- msg << 'Candidates:'
22
- msg << @candidates.map { |c| " - #{c}" }
23
- end
24
-
17
+ msg = [] << inspect_description << inspect_search_pattern << inspect_candidates
18
+ msg = msg.flatten.compact
25
19
  msg = [super.to_s] if msg.empty?
26
20
 
27
21
  msg.join("\n")
28
22
  end
23
+
24
+ private
25
+ def inspect_description
26
+ [description] if description
27
+ end
28
+
29
+ def inspect_search_pattern
30
+ ["Search pattern used: #{search_pattern}"] if search_pattern
31
+ end
32
+
33
+ def inspect_candidates
34
+ return if (candidates || []).empty?
35
+ ['Candidates:', candidates.map { |c| " - #{c}" }]
36
+ end
29
37
  end
30
38
  end
31
39
  end
@@ -13,16 +13,29 @@ module Rake
13
13
  end
14
14
 
15
15
  def to_s
16
- msg = []
17
- (msg << description << nil) if description
18
- (msg << 'Error executing:' << command << nil) if command
19
- (msg << "Exit code: #{exit_code}" << nil) if exit_code
20
- (msg << 'Command output (last 10 lines):' << output.split("\n").last(10) << nil) if output
21
-
16
+ msg = [] << inspect_description << inspect_command << inspect_exit_code << last_output
17
+ msg = msg.flatten.compact
22
18
  msg = [super.to_s] if msg.empty?
23
19
 
24
20
  msg.join("\n")
25
21
  end
22
+
23
+ private
24
+ def inspect_description
25
+ [description] if description
26
+ end
27
+
28
+ def inspect_command
29
+ ['Error executing:', command] if command
30
+ end
31
+
32
+ def inspect_exit_code
33
+ ["Exit code: #{exit_code}"] if exit_code
34
+ end
35
+
36
+ def last_output
37
+ ['Command output (last 10 lines):', output.encode('UTF-8').split("\n").last(10)] if output
38
+ end
26
39
  end
27
40
  end
28
41
  end
@@ -69,14 +69,14 @@ module Rake
69
69
  end
70
70
 
71
71
  def to_stdout(line)
72
- $stdout.puts line.sub(/\n$/, '').green
72
+ $stdout.puts line.rstrip.green
73
73
  :success
74
74
  end
75
75
 
76
76
  def to_stderr(line, error_lines)
77
77
  return unless error_lines && line =~ error_lines
78
78
 
79
- $stderr.puts line.sub(/\n$/, '').bold.red
79
+ $stderr.puts line.rstrip.bold.red
80
80
  :error
81
81
  end
82
82
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.9.0.pre'
3
+ VERSION = '0.9.1.pre'
4
4
  end
5
5
  end
@@ -8,60 +8,66 @@ describe Rake::Funnel::ExecutionError do
8
8
  its(:exit_code) { should be_nil }
9
9
  its(:output) { should be_nil }
10
10
  its(:description) { should be_nil }
11
- its(:to_s) { should =~ /^Error executing:\scommand/ }
12
- end
11
+ its(:to_s) { should =~ /^Error executing:\ncommand/ }
13
12
 
14
- context 'with command and exit code' do
15
- subject { described_class.new('command', 127) }
13
+ context 'and exit code' do
14
+ subject { described_class.new('command', 127) }
16
15
 
17
- its(:command) { should == 'command' }
18
- its(:exit_code) { should == 127 }
19
- its(:output) { should be_nil }
20
- its(:description) { should be_nil }
21
- its(:to_s) { should =~ /^Error executing:\scommand/ }
22
- its(:to_s) { should =~ /^Exit code: 127/ }
23
- end
16
+ its(:command) { should == 'command' }
17
+ its(:exit_code) { should == 127 }
18
+ its(:output) { should be_nil }
19
+ its(:description) { should be_nil }
20
+ its(:to_s) { should =~ /^Error executing:\ncommand/ }
21
+ its(:to_s) { should =~ /^Exit code: 127/ }
24
22
 
25
- context 'with command and exit code and output' do
26
- subject { described_class.new('command', 127, 'output') }
23
+ context 'and output' do
24
+ subject { described_class.new('command', 127, 'output') }
27
25
 
28
- its(:command) { should == 'command' }
29
- its(:exit_code) { should == 127 }
30
- its(:output) { should == 'output' }
31
- its(:description) { should be_nil }
32
- its(:to_s) { should =~ /^Error executing:\scommand/ }
33
- its(:to_s) { should =~ /^Exit code: 127/ }
34
- its(:to_s) { should =~ /^Command output \(last 10 lines\):\soutput/ }
35
- end
26
+ its(:command) { should == 'command' }
27
+ its(:exit_code) { should == 127 }
28
+ its(:output) { should == 'output' }
29
+ its(:description) { should be_nil }
30
+ its(:to_s) { should =~ /^Error executing:\ncommand/ }
31
+ its(:to_s) { should =~ /^Exit code: 127/ }
32
+ its(:to_s) { should =~ /^Command output \(last 10 lines\):\noutput/ }
36
33
 
37
- context 'with command and exit code and output and message' do
38
- subject { described_class.new('command', 127, 'output', 'description') }
34
+ context 'encoded output' do
35
+ subject { described_class.new('command', 127, 'output äöüß'.encode('CP850')) }
39
36
 
40
- its(:command) { should == 'command' }
41
- its(:exit_code) { should == 127 }
42
- its(:output) { should == 'output' }
43
- its(:description) { should == 'description' }
44
- its(:to_s) { should =~ /^description/ }
45
- its(:to_s) { should =~ /^Error executing:\scommand/ }
46
- its(:to_s) { should =~ /^Exit code: 127/ }
47
- its(:to_s) { should =~ /^Command output \(last 10 lines\):\soutput/ }
48
- end
37
+ its(:to_s) { should =~ /^Command output \(last 10 lines\):\noutput/ }
38
+ end
49
39
 
50
- context 'with output longer than 10 lines' do
51
- let(:output) {
52
- output = []
40
+ context 'longer than 10 lines' do
41
+ let(:output) {
42
+ output = []
53
43
 
54
- 11.times.each do |i|
55
- output << "output #{i}"
56
- end
44
+ 11.times.each do |i|
45
+ output << "output #{i}"
46
+ end
57
47
 
58
- output.join("\n")
59
- }
48
+ output.join("\n")
49
+ }
60
50
 
61
- subject { described_class.new(nil, nil, output) }
51
+ subject { described_class.new(nil, nil, output) }
62
52
 
63
- it 'should display the last 10 lines of output' do
64
- expect(subject.to_s).not_to match(/^output 0/)
53
+ it 'should display the last 10 lines of output' do
54
+ expect(subject.to_s).not_to match(/^output 0/)
55
+ end
56
+ end
57
+
58
+ context 'and description' do
59
+ subject { described_class.new('command', 127, 'output', 'description') }
60
+
61
+ its(:command) { should == 'command' }
62
+ its(:exit_code) { should == 127 }
63
+ its(:output) { should == 'output' }
64
+ its(:description) { should == 'description' }
65
+ its(:to_s) { should =~ /^description/ }
66
+ its(:to_s) { should =~ /^Error executing:\ncommand/ }
67
+ its(:to_s) { should =~ /^Exit code: 127/ }
68
+ its(:to_s) { should =~ /^Command output \(last 10 lines\):\noutput/ }
69
+ end
70
+ end
65
71
  end
66
72
  end
67
73
  end
@@ -159,6 +159,14 @@ describe Rake::Funnel::Extensions::Shell do
159
159
  expect($stdout).to have_received(:puts).with(/output 2/)
160
160
  end
161
161
  end
162
+
163
+ context 'lines with different encoding' do
164
+ let(:stdout_and_stderr) { StringIO.new('error äöüß'.encode('CP850')) }
165
+
166
+ it 'should log to stdout before error' do
167
+ expect($stderr).to have_received(:puts).with(/error/)
168
+ end
169
+ end
162
170
  end
163
171
 
164
172
  describe 'callback block' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-funnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.pre
4
+ version: 0.9.1.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Groß
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-19 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake