rspeck 0.1.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.
- data/bin/rspeck +5 -0
- data/lib/colors.rb +22 -0
- data/lib/finder.rb +25 -0
- data/lib/parsor.rb +26 -0
- data/lib/runner.rb +32 -0
- metadata +50 -0
data/bin/rspeck
ADDED
data/lib/colors.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def colorize(color_code)
|
4
|
+
"\e[#{color_code}m#{self}\e[0m"
|
5
|
+
end
|
6
|
+
|
7
|
+
def red
|
8
|
+
colorize(31)
|
9
|
+
end
|
10
|
+
|
11
|
+
def green
|
12
|
+
colorize(32)
|
13
|
+
end
|
14
|
+
|
15
|
+
def yellow
|
16
|
+
colorize(33)
|
17
|
+
end
|
18
|
+
|
19
|
+
def pink
|
20
|
+
colorize(35)
|
21
|
+
end
|
22
|
+
end
|
data/lib/finder.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spectr
|
2
|
+
module Finder
|
3
|
+
|
4
|
+
def detect_finder
|
5
|
+
return 'ack' if /^\/\w+/ === `which ack`
|
6
|
+
return 'ack-grep' if /^\/\w+/ === `which ack-grep`
|
7
|
+
raise 'ack[-grep] not found!'
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(pattern)
|
11
|
+
results = `#{detect_finder} \"#{pattern}\" spec/ --ruby`
|
12
|
+
|
13
|
+
results.split(/\n/).inject([]) do |acc, line|
|
14
|
+
match = line.split(/:/).map(&:strip).map(&:chomp)
|
15
|
+
/"(.+)"/ =~ match[2]
|
16
|
+
|
17
|
+
acc.push({
|
18
|
+
:file => match[0],
|
19
|
+
:line => match[1],
|
20
|
+
:spec => $1 })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/parsor.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'getoptlong'
|
2
|
+
|
3
|
+
module Spectr
|
4
|
+
module ArgsHelper
|
5
|
+
|
6
|
+
ARGUMENTS = ['--help', '-h', GetoptLong::NO_ARGUMENT]
|
7
|
+
|
8
|
+
def print_help
|
9
|
+
puts 'spectr "test filter"'
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse(args)
|
13
|
+
opts = GetoptLong.new(ARGUMENTS)
|
14
|
+
|
15
|
+
opts.each do |opt, arg|
|
16
|
+
case opt
|
17
|
+
when '--help'
|
18
|
+
print_help
|
19
|
+
exit 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
args
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/runner.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'parsor.rb'
|
2
|
+
require_relative 'finder.rb'
|
3
|
+
require_relative 'colors.rb'
|
4
|
+
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
module Spectr
|
8
|
+
class Runner
|
9
|
+
include Finder, ArgsHelper
|
10
|
+
|
11
|
+
def run(arguments)
|
12
|
+
args = parse(arguments)
|
13
|
+
|
14
|
+
if args.empty?
|
15
|
+
puts 'No spec pattern given!'
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
matches = find(args.first)
|
20
|
+
|
21
|
+
matches.each do |match|
|
22
|
+
puts "## testing #{match[:file]}:#{match[:line]} ##".yellow
|
23
|
+
puts match[:spec].green
|
24
|
+
|
25
|
+
cmd = "bundle exec rake spec SPEC=#{match[:file]}:#{match[:line]}"
|
26
|
+
|
27
|
+
o, _, _ = Open3.capture3(cmd)
|
28
|
+
puts o.pink
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspeck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jan Kischkel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: rspec + ack = <3
|
15
|
+
email: jk@soundcloud.com
|
16
|
+
executables:
|
17
|
+
- rspeck
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/rspeck
|
22
|
+
- lib/colors.rb
|
23
|
+
- lib/finder.rb
|
24
|
+
- lib/parsor.rb
|
25
|
+
- lib/runner.rb
|
26
|
+
homepage: https://github.com/jkischkel/rspeck
|
27
|
+
licenses: []
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 1.8.25
|
47
|
+
signing_key:
|
48
|
+
specification_version: 3
|
49
|
+
summary: simple rspec running
|
50
|
+
test_files: []
|