rbar 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 35d09592964f0af050811c95ed8ff215110bbad5c7bfe30604a94788a1af7062
4
- data.tar.gz: 0762335bc543a6ee3b2cc46b00f3b6c2a393d42277aa858a31dfa7753c91fb58
3
+ metadata.gz: 1c04e34d9a9a90e11dd258f735af5506a4fc0c201bb653535009202cfbbb6eba
4
+ data.tar.gz: 2af7bcd2fc576bd4e645d337f1c8dc6d0452fd765bb42f0d1419271f95a06d16
5
5
  SHA512:
6
- metadata.gz: 788508c7b9a0f1a3674e9118d33fcaad1a5771b25d22911cf93e7f124887cba34dbb9b0b5621c050d7807b5ca3050a4c4f08ec9d7fd8761b7283190281f5c484
7
- data.tar.gz: 3895def2b3dbe0639fe4205c054be0a98756505b32a40272ae829089561b23cf65e8d9c5c4a1235676940788646b945790d6f7348f75943ecc85395232e8cd38
6
+ metadata.gz: 175d2619c7cb97429f31db59129baac918bc3bb455e52c1180d7f852f0dc5d4f67e21fc358b26afb53ad072a6a642b1fa5841c93947055fcc5706bfda6f94b46
7
+ data.tar.gz: 250671cc6a00d843785ce59f9025ea677474048449e4f44497439b021e1d9c9f32eac8d84eb57566728f87744a2e9f3392b1037083d69006228af47ce4f85485
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ # Ignore Metrics/BlockLength for files in the spec/ directory
8
+ Metrics/BlockLength:
9
+ Enabled: true
10
+ Exclude:
11
+ - "spec/**/*"
12
+ - "rbar.gemspec"
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "standard", "~> 1.3"
13
+
14
+ gem "debug", "~> 1.0"
data/Gemfile.lock CHANGED
@@ -4,7 +4,10 @@ PATH
4
4
  rbar (0.0.1)
5
5
  pastel (~> 0.7.4)
6
6
  rspec-core (~> 3.10)
7
+ tty-box
7
8
  tty-progressbar (~> 0.18.2)
9
+ tty-table (~> 0.11.0)
10
+ tty-tree (~> 0.4.0)
8
11
 
9
12
  GEM
10
13
  remote: https://rubygems.org/
@@ -20,7 +23,7 @@ GEM
20
23
  reline (>= 0.3.0)
21
24
  json (2.6.3)
22
25
  language_server-protocol (3.17.0.3)
23
- lint_roller (1.0.0)
26
+ necromancer (0.7.0)
24
27
  parallel (1.23.0)
25
28
  parser (3.2.2.3)
26
29
  ast (~> 2.4.1)
@@ -48,34 +51,35 @@ GEM
48
51
  diff-lcs (>= 1.2.0, < 2.0)
49
52
  rspec-support (~> 3.12.0)
50
53
  rspec-support (3.12.0)
51
- rubocop (1.52.1)
54
+ rubocop (1.42.0)
52
55
  json (~> 2.3)
53
56
  parallel (~> 1.10)
54
- parser (>= 3.2.2.3)
57
+ parser (>= 3.1.2.1)
55
58
  rainbow (>= 2.2.2, < 4.0)
56
59
  regexp_parser (>= 1.8, < 3.0)
57
60
  rexml (>= 3.2.5, < 4.0)
58
- rubocop-ast (>= 1.28.0, < 2.0)
61
+ rubocop-ast (>= 1.24.1, < 2.0)
59
62
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 2.4.0, < 3.0)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
61
64
  rubocop-ast (1.29.0)
62
65
  parser (>= 3.2.1.0)
63
- rubocop-performance (1.18.0)
66
+ rubocop-performance (1.15.2)
64
67
  rubocop (>= 1.7.0, < 2.0)
65
68
  rubocop-ast (>= 0.4.0)
66
69
  ruby-progressbar (1.13.0)
67
- standard (1.29.0)
70
+ standard (1.22.1)
68
71
  language_server-protocol (~> 3.17.0.2)
69
- lint_roller (~> 1.0)
70
- rubocop (~> 1.52.0)
71
- standard-custom (~> 1.0.0)
72
- standard-performance (~> 1.1.0)
73
- standard-custom (1.0.1)
74
- lint_roller (~> 1.0)
75
- standard-performance (1.1.0)
76
- lint_roller (~> 1.0)
77
- rubocop-performance (~> 1.18.0)
72
+ rubocop (= 1.42.0)
73
+ rubocop-performance (= 1.15.2)
74
+ strings (0.1.8)
75
+ strings-ansi (~> 0.1)
76
+ unicode-display_width (~> 1.5)
77
+ unicode_utils (~> 1.4)
78
78
  strings-ansi (0.2.0)
79
+ tty-box (0.5.0)
80
+ pastel (~> 0.7.2)
81
+ strings (~> 0.1.6)
82
+ tty-cursor (~> 0.7)
79
83
  tty-color (0.6.0)
80
84
  tty-cursor (0.7.1)
81
85
  tty-progressbar (0.18.2)
@@ -84,10 +88,19 @@ GEM
84
88
  tty-screen (~> 0.8)
85
89
  unicode-display_width (>= 1.6, < 3.0)
86
90
  tty-screen (0.8.1)
87
- unicode-display_width (2.4.2)
91
+ tty-table (0.11.0)
92
+ equatable (~> 0.6)
93
+ necromancer (~> 0.5)
94
+ pastel (~> 0.7.2)
95
+ strings (~> 0.1.5)
96
+ tty-screen (~> 0.7)
97
+ tty-tree (0.4.0)
98
+ unicode-display_width (1.8.0)
99
+ unicode_utils (1.4.0)
88
100
 
89
101
  PLATFORMS
90
102
  arm64-darwin-22
103
+ x86_64-linux
91
104
 
92
105
  DEPENDENCIES
93
106
  debug (~> 1.0)
data/lib/rbar/bar.rb ADDED
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/formatters/base_text_formatter'
5
+ require 'tty-progressbar'
6
+ require 'tty-table'
7
+ require 'tty-tree'
8
+ require 'tty-box'
9
+ require 'debug'
10
+
11
+ require_relative '../rbar'
12
+ require_relative './bars/passing'
13
+ require_relative './bars/pending'
14
+ require_relative './bars/failed'
15
+
16
+ module Rbar
17
+ class Bar < ::RSpec::Core::Formatters::BaseTextFormatter
18
+ ::RSpec::Core::Formatters.register self,
19
+ :example_failed,
20
+ :example_passed,
21
+ :example_pending,
22
+ :dump_pending,
23
+ :dump_failures,
24
+ :dump_summary,
25
+ :start,
26
+ :stop
27
+
28
+ def start(notification)
29
+ super
30
+
31
+ self.total = notification.count
32
+ puts
33
+ register_sub_bars
34
+ end
35
+
36
+ def example_passed(_notification)
37
+ pass_bar.increment
38
+ print @string
39
+ end
40
+
41
+ def example_pending(_notification)
42
+ pending_bar.increment
43
+ print @string
44
+ end
45
+
46
+ def example_failed(_notification)
47
+ failed_bar.increment
48
+ print @string
49
+ end
50
+
51
+ def dump_failures(notifi)
52
+ @failed = notifi.fully_formatted_failed_examples
53
+ end
54
+
55
+ def dump_pending(_notifi); end
56
+
57
+ def print_pending(pending_examples)
58
+ pending = pending_examples.group_by { |pending| pending.example_group.description }
59
+
60
+ formatted_pending = pending.transform_values do |group_pending|
61
+ group_pending.map do |example|
62
+ { example.description =>
63
+ example.execution_result.pending_message }
64
+ end
65
+ end
66
+
67
+ tree = TTY::Tree.new(formatted_pending)
68
+ end
69
+
70
+ def print_failures(failed_examples)
71
+ failures = failed_examples.group_by { |failure| failure.example.example_group.description }
72
+
73
+ formatted_failures = failures.transform_values do |group_failures|
74
+ group_failures.map do |failure|
75
+ { failure.description =>
76
+ failure.message_lines.map(&:strip) }
77
+ end
78
+ end
79
+
80
+ TTY::Tree.new(formatted_failures)
81
+ end
82
+
83
+ def seed(notifi)
84
+ @seed = notifi.seed
85
+ end
86
+
87
+ def width
88
+ TTY::Screen.width * 0.75
89
+ end
90
+
91
+ def dump_summary(notifi)
92
+ box = TTY::Box.frame(title: { top_left: " Seed #{@seed}" }, width: TTY::Screen.width, padding: 1) do
93
+ string = @failed
94
+ string << print_summary(notifi)
95
+ end
96
+ puts
97
+ puts
98
+ puts box
99
+ end
100
+
101
+ def print_summary(notifi)
102
+ table = TTY::Table.new(orientation: :horizontal, padding: 2) do |t|
103
+ t << ['Examples', notifi.example_count]
104
+ t << ['Failed', notifi.failure_count]
105
+ t << ['Pending', notifi.pending_count]
106
+ end
107
+
108
+ table.render(:unicode, width: TTY::Screen.width) do |renderer|
109
+ renderer.border.style = result_color
110
+ renderer.border.separator = :each_row
111
+ renderer.padding = 1
112
+ renderer.render
113
+ end
114
+ end
115
+
116
+ def result_color
117
+ return :red if failed_bar.progress > 0
118
+ return :yellow if pending_bar.progress > 0
119
+
120
+ :green
121
+ end
122
+
123
+ def stop(notifi)
124
+ @failure_notifications = notifi.failure_notifications
125
+ end
126
+
127
+ def progress_bar
128
+ @progress_bar ||= TTY::ProgressBar::Multi.new(width: width, clear: true)
129
+ end
130
+
131
+ attr_accessor :failed_bar, :pass_bar, :pending_bar
132
+
133
+ private
134
+
135
+ attr_accessor :total
136
+
137
+ def register_sub_bars
138
+ self.pass_bar = Rbar::Bars::Passing.new(parent_bar: progress_bar, total: total)
139
+ self.pending_bar = Rbar::Bars::Pending.new(parent_bar: progress_bar, total: total)
140
+ self.failed_bar = Rbar::Bars::Failed.new(parent_bar: progress_bar, total: total)
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tty-progressbar"
4
+
5
+ module Rbar
6
+ module Bars
7
+ class BaseBar
8
+ def initialize(parent_bar:, total:, count: 0)
9
+ @total = total
10
+ @parent_bar = parent_bar
11
+ @count = count
12
+ @progress_bar = register_self
13
+ end
14
+
15
+ def increment
16
+ increment_count
17
+ increment_bar
18
+ end
19
+
20
+ def register_self
21
+ bar = parent_bar.register(format,
22
+ bar_format: :square,
23
+ total: total,
24
+ count: "0",
25
+ width: TTY::Screen.width * 0.75,
26
+ complete: color)
27
+ bar.start
28
+ bar
29
+ end
30
+
31
+ def progress
32
+ progress_bar.current
33
+ end
34
+
35
+ attr_reader :parent_bar, :count, :total, :progress_bar
36
+
37
+ private
38
+
39
+ def increment_count
40
+ @count += 1
41
+ end
42
+
43
+ def increment_bar
44
+ progress_bar.advance(1, count: (count + 1).to_s)
45
+ end
46
+
47
+ def marker
48
+ TTY::ProgressBar::Formats::FORMATS[:square][:complete]
49
+ end
50
+
51
+ def color
52
+ marker
53
+ end
54
+
55
+ def format
56
+ "[:bar :percent]"
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # frozen_string_literal: true
4
+
5
+ require "pastel"
6
+ require_relative "./base_bar"
7
+
8
+ module Rbar
9
+ module Bars
10
+ class Failed < BaseBar
11
+ def color
12
+ Pastel.new.red(marker)
13
+ end
14
+
15
+ def format
16
+ "Failed [:bar :percent] :current"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # frozen_string_literal: true
4
+
5
+ require "pastel"
6
+ require_relative "./base_bar"
7
+
8
+ module Rbar
9
+ module Bars
10
+ class Passing < BaseBar
11
+ def color
12
+ Pastel.new.green(marker)
13
+ end
14
+
15
+ def format
16
+ "Passed [:bar :percent] :current/:total"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # frozen_string_literal: true
4
+
5
+ require "pastel"
6
+ require_relative "./base_bar"
7
+
8
+ module Rbar
9
+ module Bars
10
+ class Pending < BaseBar
11
+ def color
12
+ Pastel.new.yellow(marker)
13
+ end
14
+
15
+ def format
16
+ "Pending [:bar :percent] :current"
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/rbar/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rbar
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/rbar.rb CHANGED
@@ -1,108 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rspec/core"
4
- require "rspec/core/formatters/base_text_formatter"
5
- require "tty-progressbar"
6
- require "pastel"
7
-
8
- class Rbar < ::RSpec::Core::Formatters::BaseTextFormatter
9
- ::RSpec::Core::Formatters.register self,
10
- :example_failed,
11
- :example_passed,
12
- :example_pending,
13
- :dump_pending,
14
- :dump_failed,
15
- :dump_summary,
16
- :start,
17
- :stop
18
-
19
- def initialize(*args)
20
- super
21
- end
22
-
23
- def start(notification)
24
- super
25
-
26
- self.total = notification.count
27
- self.failed_count = 0
28
- self.pending_count = 0
29
- self.pass_count = 0
30
- register_sub_bars
31
- initialize_bars
32
- end
33
-
34
- def stop(notification)
35
- end
36
-
37
- def example_passed(_notification)
38
- self.pass_count += 1
39
- pass_bar.advance(1, count: (pass_count + 1).to_s)
40
- end
41
-
42
- def example_pending(_notification)
43
- self.pending_count += 1
44
- pending_bar.advance(1, count: (pending_count + 1).to_s)
45
- end
46
-
47
- def example_failed(_notification)
48
- self.failed_count += 1
49
- failed_bar.advance(1, count: (failed_count + 1).to_s)
50
- end
51
-
52
- private
53
-
54
- attr_accessor :total, :pending_bar, :failed_bar, :failed_count, :pending_count, :pass_bar, :pass_count
55
-
56
- def progress_bar
57
- @progress_bar ||= TTY::ProgressBar::Multi.new(
58
- width: 40,
59
- )
60
- end
61
-
62
- def register_sub_bars
63
- self.pass_bar = progress_bar.register("Passed [:bar :percent] :count/:total",
64
- bar_format: :square,
65
- total: total,
66
- count: "0",
67
- width: 40,
68
- complete: green)
69
- self.pending_bar = progress_bar.register("Pending [:bar :percent] :count",
70
- bar_format: :square,
71
- total: total,
72
- count: "0",
73
- width: 40,
74
- complete: yellow)
75
- self.failed_bar = progress_bar.register("Failed [:bar :percent] :count",
76
- bar_format: :square,
77
- total: total,
78
- count: "0",
79
- width: 40,
80
- complete: red)
81
- end
82
-
83
- def initialize_bars
84
- pass_bar.advance(count: "0")
85
- pending_bar.advance(count: "0")
86
- failed_bar.advance(count: "0")
87
- end
88
-
89
- def marker
90
- TTY::ProgressBar::Formats::FORMATS[:square][:complete]
91
- end
92
-
93
- def green
94
- pastel.green(marker)
95
- end
96
-
97
- def red
98
- pastel.red(marker)
99
- end
100
-
101
- def yellow
102
- pastel.yellow(marker)
103
- end
104
-
105
- def pastel
106
- @pastel ||= Pastel.new
107
- end
3
+ module Rbar
4
+ VERSION = "0.0.1"
108
5
  end
data/rbar.gemspec CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Gem::Specification.new do |spec|
2
4
  spec.name = "rbar"
3
- spec.version = '0.0.1'
5
+ spec.version = "0.0.2"
4
6
  spec.authors = ["Patrick Shobe"]
5
7
  spec.email = ["patrick@shobe.dev"]
6
8
 
@@ -8,7 +10,7 @@ Gem::Specification.new do |spec|
8
10
  spec.description = "A progress bar with options"
9
11
  spec.homepage = "https://github.com/patrickshobe/rbar"
10
12
  spec.license = "MIT"
11
- spec.required_ruby_version = ">= 2.6.0"
13
+ spec.required_ruby_version = ">= 2.7.0"
12
14
 
13
15
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
14
16
 
@@ -32,10 +34,12 @@ Gem::Specification.new do |spec|
32
34
  # For more information and examples about making a new gem, check out our
33
35
  # guide at: https://bundler.io/guides/creating_gem.html
34
36
  #
37
+ spec.add_dependency "pastel", "~> 0.7.4"
35
38
  spec.add_dependency "rspec-core", ["~> 3.10"]
36
39
  spec.add_dependency "tty-progressbar", ["~> 0.18.2"]
37
- spec.add_dependency "pastel", "~> 0.7.4"
40
+ spec.add_dependency "tty-table", ["~> 0.11.0"]
41
+ spec.add_dependency "tty-box"
42
+ spec.add_dependency "tty-tree", ["~> 0.4.0"]
38
43
 
39
- spec.add_development_dependency "debug", ["~> 1.0"]
40
- spec.add_development_dependency "rspec", ["~> 3.12"]
44
+ spec.metadata["rubygems_mfa_required"] = "true"
41
45
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Shobe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-08 00:00:00.000000000 Z
11
+ date: 2023-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pastel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec-core
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,47 +53,47 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.18.2
41
55
  - !ruby/object:Gem::Dependency
42
- name: pastel
56
+ name: tty-table
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 0.7.4
61
+ version: 0.11.0
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 0.7.4
68
+ version: 0.11.0
55
69
  - !ruby/object:Gem::Dependency
56
- name: debug
70
+ name: tty-box
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :development
75
+ version: '0'
76
+ type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '1.0'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: tty-tree
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '3.12'
76
- type: :development
89
+ version: 0.4.0
90
+ type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '3.12'
96
+ version: 0.4.0
83
97
  description: A progress bar with options
84
98
  email:
85
99
  - patrick@shobe.dev
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".rspec"
105
+ - ".rubocop.yml"
91
106
  - ".standard.yml"
92
107
  - CODE_OF_CONDUCT.md
93
108
  - Gemfile
@@ -96,6 +111,11 @@ files:
96
111
  - README.md
97
112
  - Rakefile
98
113
  - lib/rbar.rb
114
+ - lib/rbar/bar.rb
115
+ - lib/rbar/bars/base_bar.rb
116
+ - lib/rbar/bars/failed.rb
117
+ - lib/rbar/bars/passing.rb
118
+ - lib/rbar/bars/pending.rb
99
119
  - lib/rbar/version.rb
100
120
  - rbar.gemspec
101
121
  - sig/rbar.rbs
@@ -106,6 +126,7 @@ metadata:
106
126
  allowed_push_host: https://rubygems.org
107
127
  homepage_uri: https://github.com/patrickshobe/rbar
108
128
  source_code_uri: https://github.com/patrickshobe/rbar
129
+ rubygems_mfa_required: 'true'
109
130
  post_install_message:
110
131
  rdoc_options: []
111
132
  require_paths:
@@ -114,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
135
  requirements:
115
136
  - - ">="
116
137
  - !ruby/object:Gem::Version
117
- version: 2.6.0
138
+ version: 2.7.0
118
139
  required_rubygems_version: !ruby/object:Gem::Requirement
119
140
  requirements:
120
141
  - - ">="