prettybacon 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: 19d7a5280fdbac6cbe678cd81a8821f4dcb722af
4
+ data.tar.gz: 24857e7d54a066de358835230bc52a65cc64b5f5
5
+ SHA512:
6
+ metadata.gz: 09161aa6927b1710aa37f5a81fdc640c00848c90bdfb3761bbe1ab69603f705221e5ad353f75c420d0b01a11f56051d4cf9965d4cf84fdba118ee5ea0d503340
7
+ data.tar.gz: 3a89df33d9f5d67f33da568d58bb591f0fbd69c62a465fb13ed9865bbd2409812d774b34a3a49942dcf48e61ad3d6461c871227b53dfa2cb8a116e45c4121fda
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fabio A. Pelosin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pretty_bacon/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prettybacon"
8
+ spec.version = PrettyBacon::VERSION
9
+ spec.authors = ["Fabio A. Pelosin"]
10
+ spec.email = ["fabiopelosin@gmail.com"]
11
+ spec.description = %q{Prettifies Bacon output.}
12
+ spec.summary = %q{Prettifies Bacon output.}
13
+ spec.homepage = "https://github.com/irrationalfab/PrettyBacon"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "bacon", "~> 1.2"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # PrettyBacon
2
+
3
+ Prettifies Bacon output.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'prettybacon', :git => 'https://github.com/irrationalfab/PrettyBacon.git'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ Add the following line to your spec helper:
18
+
19
+ require 'pretty_bacon'
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,42 @@
1
+ require 'bacon'
2
+ require 'pretty_bacon/version'
3
+
4
+ require 'pretty_bacon/spec_dox_output.rb'
5
+ require 'pretty_bacon/test_unit_output.rb'
6
+ require 'pretty_bacon/context.rb'
7
+
8
+ module PrettyBacon
9
+
10
+ def self.color(color, string)
11
+ case color
12
+ when :red
13
+ "\e[31m#{string}\e[0m"
14
+ when :green
15
+ "\e[32m#{string}\e[0m"
16
+ when :yellow
17
+ "\e[33m#{string}\e[0m"
18
+ when :none
19
+ string
20
+ else
21
+ "\e[0m#{string}\e[0m"
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ module Bacon
28
+ summary_at_exit
29
+
30
+ @needs_first_put = true
31
+
32
+ module FilterBacktraces
33
+ def handle_summary
34
+ ErrorLog.replace(ErrorLog.split("\n").reject do |line|
35
+ line =~ %r{(gems/mocha|ruby_noexec_wrapper|pretty_bacon)}
36
+ end.join("\n").lstrip << "\n\n")
37
+ super
38
+ end
39
+ end
40
+
41
+ extend FilterBacktraces
42
+ end
@@ -0,0 +1,41 @@
1
+ module Bacon
2
+
3
+ class Context
4
+
5
+ # Add support for disabled specs
6
+ #
7
+ def xit(description, &block)
8
+ Counter[:disabled] += 1
9
+ Bacon.handle_requirement(description, true) {[]}
10
+ end
11
+
12
+ # Add support for running only focused specs
13
+ #
14
+ # @note The implementation is a hack because bacon evaluates Context#it
15
+ # immediately. Therefore this method is intended to be **temporary**.
16
+ #
17
+ # @example
18
+ #
19
+ # module BaconFocusedMode; end
20
+ #
21
+ # describe "A Context" do
22
+ # it "will *not* runt" do; end
23
+ # fit "will runt" do; end
24
+ # end
25
+ #
26
+ #
27
+ def fit(description, &block)
28
+ origina_it(description, &block)
29
+ end
30
+
31
+ # Add support for focused specs
32
+ #
33
+ alias :origina_it :it
34
+ def it(description, &block)
35
+ unless defined?(::BaconFocusedMode)
36
+ origina_it(description, &block)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,76 @@
1
+ # coding: utf-8
2
+
3
+ module Bacon
4
+
5
+ # Overrides the SpecDoxzRtput to provide colored output by default
6
+ #
7
+ # Based on https://github.com/zen-cms/Zen-Core and subsequently modified
8
+ # which is available under the MIT License. Thanks YorickPeterse!
9
+ #
10
+ module SpecDoxOutput
11
+
12
+ def handle_specification(name)
13
+ if @needs_first_put
14
+ @needs_first_put = false
15
+ puts
16
+ end
17
+ @specs_depth = @specs_depth || 0
18
+ puts spaces + name
19
+ @specs_depth += 1
20
+
21
+ yield
22
+
23
+ @specs_depth -= 1
24
+ puts if @specs_depth.zero?
25
+ end
26
+
27
+ #:nodoc:
28
+ def handle_requirement(description, disabled = false)
29
+ start_time = Time.now.to_f
30
+ error = yield
31
+ elapsed_time = ((Time.now.to_f - start_time) * 1000).round
32
+
33
+ if !error.empty?
34
+ puts PrettyBacon.color(:red, "#{spaces}- #{description} [FAILED]")
35
+ elsif disabled
36
+ puts PrettyBacon.color(:yellow, "#{spaces}- #{description} [DISABLED]")
37
+ else
38
+ time_color = case elapsed_time
39
+ when 0..200
40
+ :none
41
+ when 200..500
42
+ :yellow
43
+ else
44
+ :red
45
+ end
46
+
47
+ if elapsed_time <= 1
48
+ elapsed_time_string = ''
49
+ elsif elapsed_time >= 1000
50
+ elapsed_time_string = "(#{elapsed_time/1000} s)"
51
+ else
52
+ elapsed_time_string = "(#{elapsed_time} ms)"
53
+ end
54
+
55
+ elapsed_time_string = PrettyBacon.color(time_color, " #{elapsed_time_string}") unless elapsed_time_string == ''
56
+
57
+ puts PrettyBacon.color(:green, "#{spaces}✓ ") + "#{description}" + elapsed_time_string
58
+ end
59
+ end
60
+
61
+ #:nodoc:
62
+ def handle_summary
63
+ print ErrorLog if Backtraces
64
+ unless Counter[:disabled].zero?
65
+ puts PrettyBacon.color(:yellow, "#{Counter[:disabled]} disabled specifications\n")
66
+ end
67
+ puts "%d specifications (%d requirements), %d failures, %d errors" %
68
+ Counter.values_at(:specifications, :requirements, :failed, :errors)
69
+ end
70
+
71
+ #:nodoc:
72
+ def spaces
73
+ return ' ' * @specs_depth
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,72 @@
1
+ module Bacon
2
+
3
+ # Overrides the TestUnitOutput to provide colored result output.
4
+ #
5
+ module TestUnitOutput
6
+
7
+ # Represents the specifications as `:`.
8
+ #
9
+ def handle_specification(name)
10
+ indicator = PrettyBacon.color(nil, ':')
11
+ print indicator
12
+ @indicators||=''
13
+ @indicators << indicator
14
+ yield
15
+ end
16
+
17
+ # Represents the requirements as:
18
+ #
19
+ # - [.] successful
20
+ # - [E] error
21
+ # - [F] failure
22
+ # - [_] skipped
23
+ #
24
+ # After the first failure or error all the other requirements are skipped.
25
+ #
26
+ def handle_requirement(description, disabled = false)
27
+ if @first_error
28
+ indicator = PrettyBacon.color(nil, '_')
29
+ else
30
+ error = yield
31
+ if !error.empty?
32
+ @first_error = true
33
+ m = error[0..0]
34
+ c = (m == "E" ? :red : :yellow)
35
+ indicator = PrettyBacon.color(c, m)
36
+ elsif disabled
37
+ indicator = "D"
38
+ else
39
+ indicator = PrettyBacon.color(nil, '.')
40
+ end
41
+ end
42
+ print indicator
43
+ @indicators||=''
44
+ @indicators << indicator
45
+ end
46
+
47
+ def handle_summary
48
+ first_error = ''
49
+ error_count = 0
50
+ ErrorLog.lines.each do |s|
51
+ error_count += 1 if s.include?('Error:') || s.include?('Informative')
52
+ first_error << s if error_count <= 1
53
+ end
54
+ first_error = first_error.gsub(Dir.pwd + '/', '')
55
+ first_error = first_error.gsub(/lib\//, PrettyBacon.color(:yellow, 'lib') + '/')
56
+ first_error = first_error.gsub(/:([0-9]+):/, ':' + PrettyBacon.color(:yellow, '\1') + ':')
57
+ puts "\n#{first_error}" if Backtraces
58
+ unless Counter[:disabled].zero?
59
+ puts PrettyBacon.color(:yellow, "#{Counter[:disabled]} disabled specifications")
60
+ end
61
+ result = "%d specifications (%d requirements), %d failures, %d errors" %
62
+ Counter.values_at(:specifications, :requirements, :failed, :errors)
63
+ if Counter[:failed].zero?
64
+ puts PrettyBacon.color(:green, result)
65
+ else
66
+ puts PrettyBacon.color(:red, result)
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,3 @@
1
+ module PrettyBacon
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prettybacon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fabio A. Pelosin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bacon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Prettifies Bacon output.
56
+ email:
57
+ - fabiopelosin@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - PrettyBacon.gemspec
66
+ - README.md
67
+ - Rakefile
68
+ - lib/pretty_bacon.rb
69
+ - lib/pretty_bacon/context.rb
70
+ - lib/pretty_bacon/spec_dox_output.rb
71
+ - lib/pretty_bacon/test_unit_output.rb
72
+ - lib/pretty_bacon/version.rb
73
+ homepage: https://github.com/irrationalfab/PrettyBacon
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Prettifies Bacon output.
97
+ test_files: []
98
+ has_rdoc: