luna-rspec-formatters 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb75e1a08b92660aa145de699b8ebae578ae70b8
4
- data.tar.gz: a95322897dbef02274a6621bdd33ce1561395976
3
+ metadata.gz: f37f1c8c77c2b0d5801301cbba9572e2453dcb48
4
+ data.tar.gz: '0905b2ce3b3690f6e3a9e0ba5b3919d47f784480'
5
5
  SHA512:
6
- metadata.gz: 8836bca51153a8746021c8a51a8dfb85e1e5bdf2ff16f251ddbf755a41086513b70adcf97bc970535c0957acc99d5ba6a951d4462ccc796dd7aeea6fd42fb970
7
- data.tar.gz: 10508f5d90c3fc61c7b6ccd51bcd6376dbd71129a8957453ee8a1f6042df3187ceb64bb4f7e3235ad154c6da3f670cc5dc7c82a2d315a4294f62b5fcd126f19a
6
+ metadata.gz: f03a16c4a4fea01a014fe9a9337ece0a3f1bd7143f4a6a00fcea5492492a4cba29c6d77bfd9753c72cd96eb907d672c1eed311a82cc360dbd483e1338f708272
7
+ data.tar.gz: 7c690be80289174ad40db7067ed9ea3946a072bb66f63206d416b630f1ec4842c4be8ec0be9ec2602a556005c3176d88039e7cd31c6398b87e918a4c5bfc30fc
@@ -15,8 +15,8 @@ module Luna
15
15
  # --
16
16
  def example_passed(_)
17
17
  newline_or_addup
18
- output.print " ", success_color(
19
- "\u1F63B")
18
+ output.print " ",
19
+ success_color("\u1F63B")
20
20
  end
21
21
 
22
22
  # --
@@ -24,8 +24,8 @@ module Luna
24
24
  # --
25
25
  def example_failed(_)
26
26
  newline_or_addup
27
- output.print " ", failure_color(
28
- "\u1F63E")
27
+ output.print " ",
28
+ failure_color("\u1F63E")
29
29
  end
30
30
 
31
31
  # --
@@ -33,8 +33,8 @@ module Luna
33
33
  # --
34
34
  def example_pending(_)
35
35
  newline_or_addup
36
- output.print " ", pending_color(
37
- "\u1F63F")
36
+ output.print " ",
37
+ pending_color("\u1F63F")
38
38
  end
39
39
  end
40
40
  end
@@ -15,9 +15,8 @@ module Luna
15
15
  # --
16
16
  def example_passed(_)
17
17
  newline_or_addup
18
- output.print " ".freeze, success_color(
19
- "\u2714"
20
- )
18
+ output.print " ",
19
+ success_color("\u2714")
21
20
  end
22
21
 
23
22
  # --
@@ -25,9 +24,8 @@ module Luna
25
24
  # --
26
25
  def example_failed(_)
27
26
  newline_or_addup
28
- output.print " ".freeze, failure_color(
29
- "\u2718"
30
- )
27
+ output.print " ",
28
+ failure_color("\u2718")
31
29
  end
32
30
 
33
31
  # --
@@ -35,9 +33,8 @@ module Luna
35
33
  # --
36
34
  def example_pending(_)
37
35
  newline_or_addup
38
- output.print " ".freeze, pending_color(
39
- "\u203D"
40
- )
36
+ output.print " ",
37
+ pending_color("\u203D")
41
38
  end
42
39
  end
43
40
  end
@@ -16,11 +16,11 @@ module Luna
16
16
  :example_pending, :example_failed, :dump_profile
17
17
 
18
18
  # --
19
- [:success, :failure, :pending].each do |m|
19
+ %i(success failure pending).each do |m|
20
20
  define_method "#{m}_color" do |v|
21
21
  return super(v) if defined?(super)
22
- RSpec::Core::Formatters::ConsoleCodes.
23
- wrap(v, m)
22
+ RSpec::Core::Formatters::ConsoleCodes
23
+ .wrap(v, m)
24
24
  end
25
25
  end
26
26
 
@@ -43,9 +43,8 @@ module Luna
43
43
  # --
44
44
  def example_passed(struct)
45
45
  output.print "\s"
46
- print_description(
47
- get_example(struct), :success
48
- )
46
+ print_description(get_example(struct),
47
+ :success)
49
48
  end
50
49
 
51
50
  # --
@@ -53,9 +52,8 @@ module Luna
53
52
  # --
54
53
  def example_failed(struct)
55
54
  output.print "\s"
56
- print_description(
57
- get_example(struct), :failure
58
- )
55
+ print_description(get_example(struct),
56
+ :failure)
59
57
  end
60
58
 
61
59
  # --
@@ -63,16 +61,18 @@ module Luna
63
61
  # --
64
62
  def example_pending(struct)
65
63
  output.print "\s"
66
- print_description(
67
- get_example(struct), :pending
68
- )
64
+ print_description(get_example(struct),
65
+ :pending)
69
66
  end
70
67
 
71
68
  # --
72
69
  # Pull.
73
70
  # --
74
71
  def get_example(struct)
75
- return struct unless struct.respond_to?(:example)
72
+ unless struct.respond_to?(:example)
73
+ return struct
74
+ end
75
+
76
76
  struct.example
77
77
  end
78
78
 
@@ -80,14 +80,13 @@ module Luna
80
80
  # Description.
81
81
  # --
82
82
  def print_description(example, type)
83
- output.print send(
84
- :"#{type}_color", " " + example.full_description + "\n"
85
- )
83
+ output.print send(:"#{type}_color", " " +
84
+ example.full_description + "\n")
86
85
  end
87
86
  end
88
87
  end
89
88
  end
90
89
 
91
90
  RSpec.configure do |c|
92
- config.formatter = "Luna::Formatters::Documentation"
91
+ c.formatter = "Luna::Formatters::Documentation"
93
92
  end
@@ -13,7 +13,7 @@ module Luna
13
13
  include Profiling
14
14
 
15
15
  # --
16
- [:success, :failure, :pending].each do |m|
16
+ %i(success failure pending).each do |m|
17
17
  define_method "#{m}_color" do |v|
18
18
  return super(v) if defined?(super)
19
19
  Formatters::ConsoleCodes.wrap(v, m)
@@ -25,10 +25,7 @@ module Luna
25
25
  # The total columns we allow.
26
26
  # --
27
27
  def allowed_cols
28
- @cols ||= begin
29
- (val = IO.console.winsize.last / 4) >= 24 ? val.floor :
30
- Float::INFINITY
31
- end
28
+ @cols ||= (IO.console.winsize.last / 6)
32
29
  end
33
30
 
34
31
  # --
@@ -54,7 +51,7 @@ module Luna
54
51
  private
55
52
  def newline_or_addup
56
53
  unless @lines == allowed_cols
57
- return @lines+= 1
54
+ return @lines += 1
58
55
  end
59
56
 
60
57
  output.puts
@@ -15,9 +15,8 @@ module Luna
15
15
  # --
16
16
  def example_passed(_)
17
17
  newline_or_addup
18
- output.print " ".freeze, success_color(
19
- "\u2764"
20
- )
18
+ output.print " ",
19
+ success_color("\u2764")
21
20
  end
22
21
 
23
22
  # --
@@ -25,9 +24,8 @@ module Luna
25
24
  # --
26
25
  def example_failed(_)
27
26
  newline_or_addup
28
- output.print " ".freeze, failure_color(
29
- "\u1F494"
30
- )
27
+ output.print " ",
28
+ failure_color("\u1F494")
31
29
  end
32
30
 
33
31
  # --
@@ -35,14 +33,13 @@ module Luna
35
33
  # --
36
34
  def example_pending(_)
37
35
  newline_or_addup
38
- output.print " ".freeze, pending_color(
39
- "\u2764"
40
- )
36
+ output.print " ",
37
+ pending_color("\u2764")
41
38
  end
42
39
  end
43
40
  end
44
41
  end
45
42
 
46
- RSpec.configure do |config|
47
- config.formatter = "Luna::Formatters::Hearts"
43
+ RSpec.configure do |c|
44
+ c.formatter = "Luna::Formatters::Hearts"
48
45
  end
@@ -5,10 +5,11 @@
5
5
  module Luna
6
6
  module Formatters
7
7
  module Profiling
8
- GROUPS = " %{l} \u2910 %{c} for %{t}"
9
- EXAMPLES_HEADER = "\nTop %{s} slowest examples (%{t}s), %{p}%% of total time:\n"
10
- GROUPS_HEADER = "\nTop %{s} slowest example groups:"
11
- EXAMPLES = " %{l} \u2910 %{s}"
8
+ EXP = " %<loc>s \u2910 %<sec>s"
9
+ GROUPS = " %<loc>s \u2910 %<count>g for %<sec>s"
10
+ GROUPS_HEADER = "\nTop %<count>g slowest example groups:"
11
+ EXP_HEADER = "\nTop %<count>g slowest examples (%<sec>gs), "\
12
+ "%<percent>g%% of total time:\n"
12
13
 
13
14
  # --
14
15
  # Help.
@@ -38,11 +39,11 @@ module Luna
38
39
  sec = helpers.format_seconds(e.execution_result.run_time)
39
40
  sec = sec + " seconds"
40
41
 
41
- @output.puts EXAMPLES % {
42
- :l => format_caller(e.location),
43
- :s => sec.to_f < 1 ? success_color(sec) : failure_color(sec),
44
- :d => e.full_description
45
- }
42
+ @output.puts format(EXP, {
43
+ loc: format_caller(e.location),
44
+ sec: sec.to_f < 1 ? success_color(sec) : failure_color(sec),
45
+ desc: e.full_description,
46
+ })
46
47
  end
47
48
  end
48
49
 
@@ -57,12 +58,12 @@ module Luna
57
58
  sec = helpers.format_seconds(h[:total_time])
58
59
  sec = sec + " seconds"
59
60
 
60
- @output.puts color_blue(GROUPS % {
61
- :d => h[:description],
62
- :t => sec.to_f < 2 ? success_color(sec) : failure_color(sec),
63
- :l => color_blue(strip_relative(l)),
64
- :c => h[:count]
65
- })
61
+ @output.puts color_blue(format(GROUPS, {
62
+ desc: h[:description],
63
+ sec: sec.to_f < 2 ? success_color(sec) : failure_color(sec),
64
+ loc: color_blue(strip_relative(l)),
65
+ count: h[:count],
66
+ }))
66
67
  end
67
68
  end
68
69
 
@@ -71,9 +72,9 @@ module Luna
71
72
  # --
72
73
  private
73
74
  def groups_header(profile)
74
- @output.puts GROUPS_HEADER % {
75
- :s => profile.slowest_groups.size
76
- }
75
+ @output.puts format(GROUPS_HEADER, {
76
+ count: profile.slowest_groups.size,
77
+ })
77
78
  end
78
79
 
79
80
  # --
@@ -81,36 +82,31 @@ module Luna
81
82
  # --
82
83
  private
83
84
  def examples_header(profile)
84
- @output.puts EXAMPLES_HEADER % {
85
- :s => profile.slowest_examples.size,
86
- :t => helpers.format_seconds(profile.slow_duration),
87
- :p => profile.percentage
88
- }
85
+ @output.puts format(EXP_HEADER, {
86
+ count: profile.slowest_examples.size,
87
+ sec: helpers.format_seconds(profile.slow_duration),
88
+ percent: profile.percentage,
89
+ })
89
90
  end
90
91
 
91
92
  # --
92
93
  private
93
94
  def color_blue(str)
94
- Object::RSpec::Core::Formatters::ConsoleCodes.wrap(
95
- str, :cyan
96
- )
95
+ RSpec::Core::Formatters::ConsoleCodes
96
+ .wrap(str, :cyan)
97
97
  end
98
98
 
99
99
  # --
100
100
  private
101
101
  def strip_relative(path)
102
- path.gsub(
103
- /\A\.\//, ""
104
- )
102
+ path.gsub(%r!\A\./!, "")
105
103
  end
106
104
 
107
105
  # --
108
106
  private
109
107
  def format_caller(caller_info)
110
- color_blue strip_relative(::RSpec.configuration.backtrace_formatter.
111
- backtrace_line(
112
- caller_info.to_s.split(':in `block').first
113
- ))
108
+ color_blue strip_relative(::RSpec.configuration.backtrace_formatter
109
+ .backtrace_line(caller_info.to_s.split(":in `block'").first))
114
110
  end
115
111
  end
116
112
  end
@@ -15,9 +15,8 @@ module Luna
15
15
  # --
16
16
  def example_passed(_)
17
17
  newline_or_addup
18
- output.print " ".freeze, success_color(
19
- "\u263A"
20
- )
18
+ output.print " ",
19
+ success_color("\u263A")
21
20
  end
22
21
 
23
22
  # --
@@ -25,9 +24,8 @@ module Luna
25
24
  # --
26
25
  def example_failed(_)
27
26
  newline_or_addup
28
- output.print " ".freeze, failure_color(
29
- "\u2639"
30
- )
27
+ output.print " ",
28
+ failure_color("\u2639")
31
29
  end
32
30
 
33
31
  # --
@@ -35,9 +33,8 @@ module Luna
35
33
  # --
36
34
  def example_pending(_)
37
35
  newline_or_addup
38
- output.print " ".freeze, pending_color(
39
- "\u2639"
40
- )
36
+ output.print " ",
37
+ pending_color("\u2639")
41
38
  end
42
39
  end
43
40
  end
@@ -4,6 +4,6 @@
4
4
 
5
5
  module Luna
6
6
  module Formatters
7
- VERSION = "3.9.0"
7
+ VERSION = "3.10.0"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luna-rspec-formatters
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec