rainbow_documentation 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa58903a3711010f6212d27aadb0b7b64a1d942a
4
+ data.tar.gz: 006311a6bd1c919457e3b6db6653070c43379c05
5
+ SHA512:
6
+ metadata.gz: 34d783590e41596ee9189f557b4d46ea657e425d9b005448724652c5b4817bc1037445bf364285bc5f43866144458bf1f2bd320314788f41105b05ddcd11078d
7
+ data.tar.gz: 39e588bca4aa2866f079c04f7c22028630096c047e817c9449a91a0f2b9ccd0e3548081b56d6085f8ef4b33942ab7c59afeff8ba9bbd8c0d66dba593499e30f1
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+
2
+ Permission is hereby granted, free of charge, to any person obtaining
3
+ a copy of this software and associated documentation files (the
4
+ "Software"), to deal in the Software without restriction, including
5
+ without limitation the rights to use, copy, modify, merge, publish,
6
+ distribute, sublicense, and/or sell copies of the Software, and to
7
+ permit persons to whom the Software is furnished to do so, subject to
8
+ the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be
11
+ included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
17
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # rainbow_documentation
2
+ A documentation for RSpec that keeps things colourful
3
+
4
+ Simply add it to your Gemfile using
5
+
6
+ ```ruby
7
+ gem 'rainbow_documentation', git: 'https://github.com/andrea-capri/rainbow_documentation'
8
+ ```
9
+
10
+ and add the following to RSpec through the .rspec file
11
+
12
+ ```
13
+ --color
14
+ --format RainbowDocumentation
15
+ ```
@@ -0,0 +1,4 @@
1
+ class RainbowDocumentation
2
+ VERSION = '0.0.1'.freeze
3
+ RELEASE_DATE = '2016-04-26'.freeze
4
+ end
@@ -0,0 +1,83 @@
1
+ require 'rspec'
2
+ require 'rspec/core/formatters/base_text_formatter'
3
+
4
+ class RainbowDocumentation < RSpec::Core::Formatters::BaseTextFormatter
5
+ RSpec::Core::Formatters.register self,
6
+ :example_group_started,
7
+ :example_group_finished,
8
+ :example_passed,
9
+ :example_pending,
10
+ :example_failed
11
+
12
+ COLOR = [
13
+ 34, #:blue,
14
+ 94, #:light_blue,
15
+ 36, #:cyan
16
+ 96, #:light_cyan
17
+ 35, #:magenta
18
+ 95, #:light_magenta
19
+ 37 #:light_white]
20
+ ].freeze
21
+
22
+ def initialize(output)
23
+ super
24
+ @output = output
25
+ @group_level = 0
26
+ end
27
+
28
+ def example_group_started(notification)
29
+ @output.puts wrap("#{current_indentation}#{notification.group.description.strip}", @group_level)
30
+ @group_level += 1
31
+ end
32
+
33
+ def example_group_finished(_notification)
34
+ @group_level -= 1
35
+ end
36
+
37
+ def example_passed(passed)
38
+ @output.puts passed_output(passed.example)
39
+ end
40
+
41
+ def example_pending(pending)
42
+ @output.puts pending_output(pending.example, pending.example.execution_result.pending_message)
43
+ end
44
+
45
+ def example_failed(failure)
46
+ @output.puts failure_output(failure.example, failure.example.execution_result.exception)
47
+ end
48
+
49
+ private
50
+
51
+ def passed_output(example)
52
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation} -> #{example.description.strip}",
53
+ :success)
54
+ end
55
+
56
+ def pending_output(example, message)
57
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation} -> #{example.description.strip} (PENDING: #{message})",
58
+ :pending)
59
+ end
60
+
61
+ def failure_output(example, _exception)
62
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation} -> #{example.description.strip} " \
63
+ "(FAILED - #{next_failure_index})",
64
+ :failure)
65
+ end
66
+
67
+ def next_failure_index
68
+ @next_failure_index ||= 0
69
+ @next_failure_index += 1
70
+ end
71
+
72
+ def current_indentation
73
+ ' ' * @group_level
74
+ end
75
+
76
+ def wrap(text, code)
77
+ if RSpec.configuration.color_enabled?
78
+ "\e[#{COLOR[code]}m#{text}\e[0m"
79
+ else
80
+ text
81
+ end
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rainbow_documentation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrea Capri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: "\n Colorizes the example output strings without changing the color
42
+ of pending and error output\n See https://github.com/andrea-capri/rainbow_wrapper
43
+ for more details.\n "
44
+ email:
45
+ - andrea.a.capri@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - LICENSE
51
+ - README.md
52
+ - lib/rainbow_documentation/version.rb
53
+ - lib/rainbow_documentation.rb
54
+ homepage:
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.0.14.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A wrapper for RSpec that keeps things colourful
78
+ test_files: []