rspec-kungfuhamster 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 83e445d6b6f36abbdc071fa90fc752bbe001d090
4
- data.tar.gz: a6e0f962912f05dfa28af4069871ba5e004f9b7d
2
+ SHA256:
3
+ metadata.gz: cdeade8d8542b627204a981d63260b3ded4c3eb08258f66ea7f7e49e482b8f61
4
+ data.tar.gz: befdc3608a08866bc7d9c1556ee54283993a4068db106b607fd6a96c0a980a3d
5
5
  SHA512:
6
- metadata.gz: f768b438b5f6d2032b2d6006547755c6474a5960b373af949a42789e0ec1ab61cb287634ec506ccfdfd05da3f2b85178afa6e1217cf6ef7959013c4a48d0b80e
7
- data.tar.gz: 9be05a6034129734b493b0e5cb302abbb3be9f5cad59ed97e06d863c37bb4da826223d925b82fa673dd3a8608a57f2f48df13f18e2678b9b2bdaccf6c4f98404
6
+ metadata.gz: 6d9013150c705bb88c75067d9af425f4a65f7b5abed6779694f61fea85137bfc5d8b0ffa230fa06bb1fc888dcc40c3e4a02d91104ff957fed6d97b635a467c27
7
+ data.tar.gz: 99e1e684ffb1e0290ae84b8174a28f2d33d5cbe42461d5c21cec3f3d2617c834cb7ce7b0c2aa801ffbb7be8f7f34a05f26b6cc8c6ff8fda224ddd2758a085a6e
data/README.md CHANGED
@@ -2,3 +2,93 @@ rspec-kungfuhamster
2
2
  ======================
3
3
 
4
4
  Animated kung fu hamster formatter
5
+
6
+ # Sample Output
7
+
8
+ As your tests run, you'll see an animated kung fu hamster performing various martial arts moves:
9
+
10
+ ```
11
+ ()__()
12
+ / o o\
13
+ |' =Y=';----
14
+ { \ / }
15
+ mmm mmm
16
+ ```
17
+
18
+ The hamster is colorized based on your test results:
19
+ - **Green** portion: Passing tests
20
+ - **Yellow** portion: Pending tests
21
+ - **Red** portion: Failing tests
22
+
23
+ The hamster cycles through different kung fu poses as each test completes, creating an animated effect in your terminal!
24
+
25
+ # Installation
26
+
27
+ Add this to your Gemfile (in the test group) and run `bundle install`:
28
+
29
+ ``` ruby
30
+ gem 'rspec-kungfuhamster'
31
+ ```
32
+
33
+ # Usage
34
+
35
+ After installing the gem, you can use the formatter in several ways:
36
+
37
+ ## Command Line
38
+
39
+ Run RSpec with the formatter specified:
40
+
41
+ ```bash
42
+ rspec --format RspecKungFuHamster::Formatter
43
+ ```
44
+
45
+ ## Configuration File
46
+
47
+ Add to your `.rspec` file in your project root:
48
+
49
+ ```
50
+ --format RspecKungFuHamster::Formatter
51
+ ```
52
+
53
+ ## RSpec Configuration
54
+
55
+ Add to your `spec/spec_helper.rb` or `spec/rails_helper.rb`:
56
+
57
+ ```ruby
58
+ RSpec.configure do |config|
59
+ config.formatter = RspecKungFuHamster::Formatter
60
+ end
61
+ ```
62
+
63
+ Or if you want to use multiple formatters:
64
+
65
+ ```ruby
66
+ RSpec.configure do |config|
67
+ config.formatter = :progress # or :documentation
68
+ config.add_formatter RspecKungFuHamster::Formatter
69
+ end
70
+ ```
71
+
72
+ # Development
73
+
74
+ ## Automated Version Bumping
75
+
76
+ This gem uses automated version bumping on pull requests merged to `main` or `master`. The version bump type is determined by labels on the PR:
77
+
78
+ - **`major`** label: Bumps the major version (e.g., 1.2.3 → 2.0.0)
79
+ - **`minor`** label: Bumps the minor version (e.g., 1.2.3 → 1.3.0)
80
+ - **No label**: Defaults to patch bump (e.g., 1.2.3 → 1.2.4)
81
+
82
+ The workflow automatically:
83
+ 1. Detects the bump type from PR labels
84
+ 2. Updates the version in `lib/rspec_kung_fu_hamster/version.rb`
85
+ 3. Commits the version bump with message `[skip ci]`
86
+ 4. Creates and pushes a git tag (e.g., `v1.2.3`)
87
+
88
+ ### Manual Version Bumping
89
+
90
+ You can also manually bump the version using the script:
91
+
92
+ ```bash
93
+ ruby scripts/bump_version.rb [major|minor|patch]
94
+ ```
@@ -0,0 +1 @@
1
+ require 'rspec_kung_fu_hamster'
@@ -0,0 +1,3 @@
1
+ module RspecKungFuHamster
2
+ VERSION = '0.2.0'
3
+ end
@@ -1,29 +1,64 @@
1
1
  require 'rspec'
2
- require 'rspec/core/formatters/base_text_formatter'
2
+ require 'rspec/core/formatters/base_text_formatter'
3
+ require 'rspec_kung_fu_hamster/version'
3
4
 
4
5
  rspec_bin = $0.split('/').last
5
6
 
6
- class RspecKungFuHamster < RSpec::Core::Formatters::BaseTextFormatter
7
- RSpec::Core::Formatters.register self,
7
+ module RspecKungFuHamster
8
+ class Formatter < RSpec::Core::Formatters::BaseTextFormatter
9
+ RSpec::Core::Formatters.register self,
8
10
  # :start,
9
11
  # :example_start
10
12
  # :message,
11
- :example_passed
12
- # :example_pending,
13
- # :example_failed,
13
+ :example_passed,
14
+ :example_pending,
15
+ :example_failed
14
16
  # :dump_failures
15
17
 
16
18
  def initialize(output)
17
19
  @index = 0
20
+ @example_passed = 0
21
+ @example_pending = 0
22
+ @example_failed = 0
18
23
  super(output)
19
24
  end
20
25
 
26
+ def color_positions(length)
27
+ total = @example_passed + @example_pending + @example_failed
28
+ passed_percent = @example_passed * length / total
29
+ pending_percent = @example_pending * length / total
30
+
31
+ [passed_percent, passed_percent + pending_percent, length]
32
+ end
33
+
34
+ GREEN = "\e[32m"
35
+ YELLOW = "\e[33m"
36
+ RED = "\e[31m"
37
+ RESET = "\e[0m"
38
+
39
+ def colorize(string)
40
+ green, yellow, red = color_positions(string.length)
41
+ GREEN + string[0...green] + YELLOW + string[green...yellow] + RED + string[yellow...red] + RESET
42
+ end
43
+
44
+ def display(strings)
45
+ colorize(strings.join("\n"))
46
+ end
47
+
48
+ def output_hamster
49
+ output.puts "\e[2J\e[;H" + display(hamster_and_next)
50
+ end
21
51
  def example_passed(notification)
22
- output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
52
+ @example_passed += 1
53
+ output_hamster
54
+ end
55
+ def example_pending(notification)
56
+ @example_pending += 1
57
+ output_hamster
23
58
  end
24
59
  def example_failed(notification)
25
- output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
26
- sleep 0.1
60
+ @example_failed += 1
61
+ output_hamster
27
62
  end
28
63
 
29
64
  def hamster_and_next
@@ -76,4 +111,5 @@ class RspecKungFuHamster < RSpec::Core::Formatters::BaseTextFormatter
76
111
  " { \\ / } ",
77
112
  " mmm mmm "
78
113
  ]
114
+ end
79
115
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../lib/rspec_kung_fu_hamster.rb'
2
- describe RspecKungFuHamster do
2
+ describe RspecKungFuHamster::Formatter do
3
3
  100.times do |i|
4
4
  it { expect(i).to eq i }
5
5
  end
6
- it { expect(RspecKungFuHamster::KUNG_FU_HAMSTER.length).to eq 6 }
6
+ it { expect(RspecKungFuHamster::Formatter::KUNG_FU_HAMSTER.length).to eq 6 }
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-kungfuhamster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Powell
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec
@@ -30,18 +29,19 @@ email:
30
29
  executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files:
33
- - README.md
34
32
  - LICENSE
33
+ - README.md
35
34
  files:
36
35
  - LICENSE
37
36
  - README.md
38
37
  - lib/rspec_kung_fu_hamster.rb
38
+ - lib/rspec_kung_fu_hamster/formatter.rb
39
+ - lib/rspec_kung_fu_hamster/version.rb
39
40
  - spec/kungfuhamster_spec.rb
40
41
  homepage: https://github.com/stringsn88keys/rspec-kungfuhamster
41
42
  licenses:
42
43
  - MIT
43
44
  metadata: {}
44
- post_install_message:
45
45
  rdoc_options:
46
46
  - "--charset"
47
47
  - UTF-8
@@ -58,11 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.2.2
63
- signing_key:
61
+ rubygems_version: 3.6.9
64
62
  specification_version: 4
65
63
  summary: Rspec kung fu hamster formatter
66
64
  test_files:
67
65
  - spec/kungfuhamster_spec.rb
68
- has_rdoc: