rspec-rainbow 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: 49ad1ad6aee4e7bffe52e490e0a1ee8d97d8c5f8
4
- data.tar.gz: 85266145f4c3ed884e26566e492939c064d37fc8
5
2
  SHA512:
6
- metadata.gz: 8c42c26cbe6fa2a714d63064726f62ff3e123c3686a50d8140b9fd8214a5e3b262c7a6fa7a32f21735b1f1722175179c0404d792552468926785461c2ae855c5
7
- data.tar.gz: d5c0f94841b2d7ac8fdc47df098c2d76443e9432e57b55c9762eb6280f226d458934757fe27a0b0c1d0da2ea9fa26f84b38c3b25ff6f020d0f7436950d895da4
3
+ data.tar.gz: 3f459826b3f09cb453733ac7955bf1cd72940f8ff73a9fc590381ab4d5c56e26915de8af20cad0bef17ef104b4e3a7a3caa794f5730ad684ebb4d764741c2afb
4
+ metadata.gz: 58c62accc8703178c988e7d72d7388f55466f53182c9444dfd0f02254e279e7b11cb534eec0d1d4998c6842f9a19a96b60833382b16267b4186decf104557442
5
+ SHA1:
6
+ data.tar.gz: 6d84c449069d648f058d7d8925aedd8618c43db9
7
+ metadata.gz: a202dad71d250869a657cefdbf9149ea9d7769d5
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # rspec-rainbow
2
2
 
3
- Add some color to your rspec tests!
3
+ Adds some color to your rspec tests!
4
+
5
+ Created because I was jealous of how beautiful [Minitest's](https://github.com/seattlerb/minitest) output is.
4
6
 
5
7
  ## Installation
6
8
 
@@ -10,7 +12,7 @@ Add this line to your application's Gemfile:
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ $ bundle install
14
16
 
15
17
  Or install it yourself as:
16
18
 
@@ -31,3 +33,7 @@ If you want to use Rainbow by default, add it to your ```.rspec``` file.
31
33
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
34
  4. Push to the branch (`git push origin my-new-feature`)
33
35
  5. Create new Pull Request
36
+
37
+ ## Attribution
38
+
39
+ Based on [Minitest's](https://github.com/seattlerb/minitest) Pride plugin
@@ -1,9 +1,19 @@
1
1
  require 'rspec/core/formatters/progress_formatter'
2
2
 
3
3
  class Rainbow < ::RSpec::Core::Formatters::ProgressFormatter
4
-
4
+ PI_3 = Math::PI / 3
5
+
5
6
  def initialize(options)
6
- @colors = (31..36).to_a
7
+ # colors calculation stolen from Minitest's Pride Plugin
8
+ # https://github.com/seattlerb/minitest
9
+ @colors = (0...(6 * 7)).map { |n|
10
+ n *= 1.0 / 6
11
+ r = (3 * Math.sin(n ) + 3).to_i
12
+ g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
13
+ b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
14
+
15
+ 36 * r + 6 * g + b + 16
16
+ }
7
17
  @color_index = 0
8
18
  super(options)
9
19
  end
@@ -14,11 +24,12 @@ class Rainbow < ::RSpec::Core::Formatters::ProgressFormatter
14
24
  end
15
25
 
16
26
  def color(text, color_code)
17
- colorize(text, rainbow)
27
+ color_code = rainbow if text == '.'
28
+ super
18
29
  end
19
30
 
20
31
  def color_code_for(code_or_symbol)
21
- return code_or_symbol if code_or_symbol.is_a?(Integer)
32
+ return "38;5;#{code_or_symbol}" if code_or_symbol.is_a?(Integer)
22
33
  super
23
34
  end
24
35
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rspec-rainbow"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Mike Coutermarsh"]
9
9
  spec.email = ["coutermarsh.mike@gmail.com"]
10
10
  spec.description = %q{the rainbow formatter for RSpec}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rainbow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Coutermarsh