luna-rspec-formatters 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 +7 -0
- data/Gemfile +2 -0
- data/License +11 -0
- data/Readme.md +5 -0
- data/lib/luna/rspec/formatters/checks.rb +22 -0
- data/lib/luna/rspec/formatters/doc2.rb +53 -0
- data/lib/luna/rspec/formatters/shared/base.rb +36 -0
- data/lib/luna/rspec/formatters/version.rb +7 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7dce51a6c4957a0614d172acabaeafa787cf50e
|
4
|
+
data.tar.gz: e12926b98922917e95796c8301929363ed087d15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a01ce51ae2280c6c694e77581d8f50bb0594785dbfce62becab6b30b68a130c1ef5d22d108f4ff758e6d19f95e07c1678f2f6b63cec21faed708bfea9840b38
|
7
|
+
data.tar.gz: ccadac5a590caa2305969473989c1317dbe594e171e02154a2b2fed2ef1a3ec61f512d4e9f02c1cd960875b0dd67dd8fd9651e67a0f78f6cd74093c2785422eb
|
data/Gemfile
ADDED
data/License
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Copyright 2013 Jordon Bedwell.
|
2
|
+
Apache License.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
5
|
+
this file except in compliance with the License. You may obtain a copy of the
|
6
|
+
License at: http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
9
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
11
|
+
specific language governing permissions and limitations under the License.
|
data/Readme.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
## RSpec Formatters Luna
|
2
|
+
|
3
|
+
A set of `rspec` formatters that design things the way I like them. `Doc2` is a formatter
|
4
|
+
that outputs the full description as a single line rather than nesting like documentation and
|
5
|
+
`Checks` displays checkmark's and other UTF characters rather than dots.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative "shared/base"
|
2
|
+
|
3
|
+
module Luna
|
4
|
+
module RSpec
|
5
|
+
module Formatters
|
6
|
+
class Checks < Shared::Base
|
7
|
+
|
8
|
+
###
|
9
|
+
# Checkmark, x and ?! with the colors green, red and yellow.
|
10
|
+
# @return [String] ANSI colored string.
|
11
|
+
|
12
|
+
MethodMap.each do |m, u|
|
13
|
+
define_method("example_#{m}") do |e|
|
14
|
+
super(e)
|
15
|
+
blank_line?
|
16
|
+
output.print " #{u.first}".send(u.last)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative "shared/base"
|
2
|
+
|
3
|
+
module Luna
|
4
|
+
module RSpec
|
5
|
+
module Formatters
|
6
|
+
class Doc2 < Shared::Base
|
7
|
+
MethodMap.each do |m, u|
|
8
|
+
define_method("example_#{m}") do |e|
|
9
|
+
super(e)
|
10
|
+
blank_line?
|
11
|
+
print_description(e)
|
12
|
+
output.puts " #{u.first}".send(u.last)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
###
|
17
|
+
# A simple wrapper for CodeRay and syntax highlighting.
|
18
|
+
# @return [String] ANSI colored string.
|
19
|
+
|
20
|
+
def syntax_highlight(text)
|
21
|
+
CodeRay.scan(text, :ruby).term
|
22
|
+
end
|
23
|
+
|
24
|
+
###
|
25
|
+
# Searches for `` inside of "it" and "context" and highlights it with CodeRay.
|
26
|
+
# @return [String] ANSI colored string.
|
27
|
+
|
28
|
+
def highlight_graves(text)
|
29
|
+
text.gsub(/`([^`]+)`/) { syntax_highlight($1) }
|
30
|
+
end
|
31
|
+
|
32
|
+
###
|
33
|
+
# Searches for anything that starts with \. or # and colors it.
|
34
|
+
# @return [String] ANSI colored string.
|
35
|
+
|
36
|
+
def highlight_methods(text)
|
37
|
+
text.gsub(/(#|\.)([a-z0-9_]+)/) { $1.white + $2.magenta }
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Strips apart the full_description to attempt to gather information on the constant and
|
42
|
+
# method and then highlights and outputs everything.
|
43
|
+
# @return [String] ANSI colored string.
|
44
|
+
|
45
|
+
def print_description(example)
|
46
|
+
constant = example.full_description.chomp(example.description)
|
47
|
+
output.print " " + highlight_methods(syntax_highlight(constant))
|
48
|
+
output.print highlight_graves(example.description) + ":"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rspec/core/formatters/base_text_formatter"
|
2
|
+
require "colorize"
|
3
|
+
require "coderay"
|
4
|
+
|
5
|
+
module Luna
|
6
|
+
module RSpec
|
7
|
+
module Formatters
|
8
|
+
MethodMap = {
|
9
|
+
:passed => ["\u2713", :green],
|
10
|
+
:failed => ["\u2718", :red],
|
11
|
+
:pending => ["\u203D", :yellow]
|
12
|
+
}
|
13
|
+
|
14
|
+
module Shared
|
15
|
+
class Base < ::RSpec::Core::Formatters::BaseTextFormatter
|
16
|
+
def initialize(*args)
|
17
|
+
super(*args)
|
18
|
+
@lunas_first_output = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def start_dump
|
22
|
+
super
|
23
|
+
output.puts
|
24
|
+
end
|
25
|
+
|
26
|
+
def blank_line?
|
27
|
+
if @lunas_first_output
|
28
|
+
output.puts
|
29
|
+
@lunas_first_output = false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: luna-rspec-formatters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordon Bedwell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: coderay
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A couple of RSpec formatters.
|
70
|
+
email:
|
71
|
+
- envygeeks@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/luna/rspec/formatters/doc2.rb
|
77
|
+
- lib/luna/rspec/formatters/checks.rb
|
78
|
+
- lib/luna/rspec/formatters/version.rb
|
79
|
+
- lib/luna/rspec/formatters/shared/base.rb
|
80
|
+
- License
|
81
|
+
- Readme.md
|
82
|
+
- Gemfile
|
83
|
+
homepage: https://github.com/envygeeks/luna-rspec-formatters
|
84
|
+
licenses:
|
85
|
+
- Apache 2.0
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.0.3
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A couple of RSpec formatters the way I like them.
|
107
|
+
test_files: []
|