dotpretty 0.2.0 → 0.3.0
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 +4 -4
- data/bin/dotpretty +12 -9
- data/lib/dotpretty/colorers/bash.rb +19 -0
- data/lib/dotpretty/colorers/null.rb +15 -0
- data/lib/dotpretty/reporters/basic.rb +4 -3
- data/lib/dotpretty/reporters/factory.rb +11 -4
- data/lib/dotpretty/reporters/progress.rb +5 -4
- data/lib/dotpretty/runner.rb +24 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 118060871c73b59f4441f099609601fade671fa6c2108dd6b89fbcb89f3afdb5
|
4
|
+
data.tar.gz: 8b48b1cf1a5fa2f75c97c2a15d7e521f7b6e185405218485ae5620fce51e8b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ab50c49fa52d122e2565deaf511ea14f41d9950013892216200c778e6bd64bde6e38895243ffe7173a84e93a07bad3f77d821c10a27581e829a32eaf5b8f28
|
7
|
+
data.tar.gz: a6ea6a7570a2dd888c58b0d10e7aad35da2ef80f69fab7c5e159b01b3f7d734a7c85730efb042cbc4994f0a0662407210866c8d0dc17bd30500cab0e9e12d90b
|
data/bin/dotpretty
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require "dotpretty/
|
4
|
-
require "dotpretty/reporters/factory"
|
3
|
+
require "dotpretty/colorers/null"
|
5
4
|
require "dotpretty/reporters/names"
|
5
|
+
require "dotpretty/runner"
|
6
6
|
require "optparse"
|
7
7
|
|
8
8
|
options = {}
|
@@ -10,6 +10,10 @@ OptionParser.new do |opts|
|
|
10
10
|
|
11
11
|
opts.banner = "Usage: dotnet test -v=normal Test.Project/ | dotnet [options]"
|
12
12
|
|
13
|
+
opts.on("-c", "--color", "Enable color output") do |color|
|
14
|
+
options[:color] = color
|
15
|
+
end
|
16
|
+
|
13
17
|
opts.on("-h", "--help", "Display this help") do
|
14
18
|
puts opts
|
15
19
|
exit
|
@@ -28,10 +32,9 @@ OptionParser.new do |opts|
|
|
28
32
|
|
29
33
|
end.parse!
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
35
|
+
runner = Dotpretty::Runner.new({
|
36
|
+
colorer: Dotpretty::Colorers::Null,
|
37
|
+
output: STDOUT,
|
38
|
+
reporter_name: options[:reporter_name]
|
39
|
+
})
|
40
|
+
STDIN.each_line { |line| runner.parse_line(line) }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Dotpretty
|
2
|
+
module Colorers
|
3
|
+
module Bash
|
4
|
+
|
5
|
+
RESET="\e[0m"
|
6
|
+
START_GREEN="\033[32m"
|
7
|
+
START_RED="\033[31m"
|
8
|
+
|
9
|
+
def green(text)
|
10
|
+
return "#{START_GREEN}#{text}#{RESET}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def red(text)
|
14
|
+
return "#{START_RED}#{text}#{RESET}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,7 +2,8 @@ module Dotpretty
|
|
2
2
|
module Reporters
|
3
3
|
class Basic
|
4
4
|
|
5
|
-
def initialize(output)
|
5
|
+
def initialize(colorer:, output:)
|
6
|
+
self.extend(colorer)
|
6
7
|
self.output = output
|
7
8
|
end
|
8
9
|
|
@@ -20,11 +21,11 @@ module Dotpretty
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_passed(test_name)
|
23
|
-
output.puts("Passed #{test_name}")
|
24
|
+
output.puts(green("Passed #{test_name}"))
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_failed(failing_test)
|
27
|
-
output.puts("Failed #{failing_test[:name]}")
|
28
|
+
output.puts(red("Failed #{failing_test[:name]}"))
|
28
29
|
failing_test[:details].each do |line|
|
29
30
|
output.puts(line)
|
30
31
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "dotpretty/colorers/null"
|
1
2
|
require "dotpretty/reporters/basic"
|
2
3
|
require "dotpretty/reporters/json"
|
3
4
|
require "dotpretty/reporters/names"
|
@@ -7,14 +8,20 @@ module Dotpretty
|
|
7
8
|
module Reporters
|
8
9
|
class Factory
|
9
10
|
|
10
|
-
def self.build_reporter(name,
|
11
|
+
def self.build_reporter(name, options = {})
|
11
12
|
case name
|
12
13
|
when Dotpretty::Reporters::Names::JSON
|
13
|
-
return Dotpretty::Reporters::Json.new(output)
|
14
|
+
return Dotpretty::Reporters::Json.new(options.fetch(:output))
|
14
15
|
when Dotpretty::Reporters::Names::PROGRESS
|
15
|
-
return Dotpretty::Reporters::Progress.new(
|
16
|
+
return Dotpretty::Reporters::Progress.new({
|
17
|
+
colorer: options.fetch(:colorer),
|
18
|
+
output: options.fetch(:output)
|
19
|
+
})
|
16
20
|
else
|
17
|
-
return Dotpretty::Reporters::Basic.new(
|
21
|
+
return Dotpretty::Reporters::Basic.new({
|
22
|
+
colorer: options.fetch(:colorer),
|
23
|
+
output: options.fetch(:output)
|
24
|
+
})
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
@@ -2,7 +2,8 @@ module Dotpretty
|
|
2
2
|
module Reporters
|
3
3
|
class Progress
|
4
4
|
|
5
|
-
def initialize(output)
|
5
|
+
def initialize(colorer:, output:)
|
6
|
+
self.extend(colorer)
|
6
7
|
self.failing_tests = []
|
7
8
|
self.output = output
|
8
9
|
end
|
@@ -29,11 +30,11 @@ module Dotpretty
|
|
29
30
|
|
30
31
|
def test_failed(failing_test)
|
31
32
|
failing_tests << failing_test
|
32
|
-
output.print("F")
|
33
|
+
output.print(red("F"))
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_passed(passing_test)
|
36
|
-
output.print(".")
|
37
|
+
output.print(green("."))
|
37
38
|
end
|
38
39
|
|
39
40
|
private
|
@@ -42,7 +43,7 @@ module Dotpretty
|
|
42
43
|
output.puts("Failures:")
|
43
44
|
output.puts("")
|
44
45
|
failing_tests.each_with_index do |failing_test, index|
|
45
|
-
output.puts(" #{index + 1}) #{failing_test[:name]}")
|
46
|
+
output.puts(red(" #{index + 1}) #{failing_test[:name]}"))
|
46
47
|
output.puts("")
|
47
48
|
failing_test[:details].each do |detail|
|
48
49
|
output.puts(" #{detail}")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "dotpretty/parser"
|
2
|
+
require "dotpretty/reporters/factory"
|
3
|
+
|
4
|
+
module Dotpretty
|
5
|
+
class Runner
|
6
|
+
|
7
|
+
def initialize(colorer:, output:, reporter_name:)
|
8
|
+
reporter = Dotpretty::Reporters::Factory.build_reporter(reporter_name, {
|
9
|
+
output: output,
|
10
|
+
colorer: colorer
|
11
|
+
})
|
12
|
+
self.parser = Dotpretty::Parser.new({ reporter: reporter })
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_line(line)
|
16
|
+
parser.parse_line(line)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_accessor :parser
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotpretty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Meyer
|
@@ -20,12 +20,15 @@ files:
|
|
20
20
|
- bin/dotpretty
|
21
21
|
- lib/dotpretty.rb
|
22
22
|
- lib/dotpretty/aggregator.rb
|
23
|
+
- lib/dotpretty/colorers/bash.rb
|
24
|
+
- lib/dotpretty/colorers/null.rb
|
23
25
|
- lib/dotpretty/parser.rb
|
24
26
|
- lib/dotpretty/reporters/basic.rb
|
25
27
|
- lib/dotpretty/reporters/factory.rb
|
26
28
|
- lib/dotpretty/reporters/json.rb
|
27
29
|
- lib/dotpretty/reporters/names.rb
|
28
30
|
- lib/dotpretty/reporters/progress.rb
|
31
|
+
- lib/dotpretty/runner.rb
|
29
32
|
- lib/dotpretty/state_details.rb
|
30
33
|
- lib/dotpretty/state_machine.rb
|
31
34
|
- lib/dotpretty/state_machine_builder.rb
|