spectrerun 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/spectrerun +13 -0
- data/lib/spectrerun.rb +64 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bac19ae8ed6bddb8bce72634038b454b1c6ac27a
|
4
|
+
data.tar.gz: 3b80cf1f45df7aee7ab11244add86d2a29f22e0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96c8450c1f388550c9839423abd097e24b99372d8dfaaf9a3b3efd76cdbcdd9db936c877207e4373f35d675df6380261b9e495d7e784f4f2d7d8f367f5241748
|
7
|
+
data.tar.gz: ae16924e856ccc36c9522255fe28d78842c2ee9316875d2f28eb550ddc175e9409455d14bbbffd0ecfca1cc1d8f3c2e86ad26caab0ee4a48dc2084eca32f7eae
|
data/bin/spectrerun
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spectrerun'
|
4
|
+
|
5
|
+
if $stdin.tty?
|
6
|
+
changed_files = `git diff --name-only`.split("\n").map(&:chomp)
|
7
|
+
else
|
8
|
+
changed_files = $stdin.readlines.map(&:chomp)
|
9
|
+
end
|
10
|
+
|
11
|
+
files_to_check = find_specs_to_run(changed_files)
|
12
|
+
|
13
|
+
puts files_to_check
|
data/lib/spectrerun.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
def ruby_files
|
4
|
+
@file_names ||= Dir.glob('**/*.rb')
|
5
|
+
end
|
6
|
+
|
7
|
+
def declared_constants(file_name)
|
8
|
+
[
|
9
|
+
file_name,
|
10
|
+
|
11
|
+
File
|
12
|
+
.readlines(file_name)
|
13
|
+
.select { |line| line.start_with? 'class' }
|
14
|
+
.map(&:chomp)
|
15
|
+
.map { |declaration| declaration.split[1] }
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def constants_used_in_file(file_name)
|
20
|
+
[
|
21
|
+
file_name,
|
22
|
+
|
23
|
+
File
|
24
|
+
.readlines(file_name)
|
25
|
+
.map { |line| line.match(/.*\W([A-Z]\w+)/) }
|
26
|
+
.compact
|
27
|
+
.map { |match| match[1] }
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
def files_impacted(constants_used_in_files, constant)
|
32
|
+
constants_used_in_files.select do |_, constants|
|
33
|
+
constants.include? constant
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def spec_path(file_name)
|
38
|
+
return file_name if file_name.end_with? '_spec.rb'
|
39
|
+
|
40
|
+
file_name
|
41
|
+
.gsub('app', 'spec')
|
42
|
+
.gsub('.rb', '_spec.rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_specs_to_run(changed_files)
|
46
|
+
constants_in_files = Hash[
|
47
|
+
ruby_files.map { |filename| declared_constants(filename) }
|
48
|
+
]
|
49
|
+
|
50
|
+
constants_used_in_files = Hash[
|
51
|
+
ruby_files.map { |file_name| constants_used_in_file(file_name) }
|
52
|
+
]
|
53
|
+
|
54
|
+
constants_impacted = changed_files
|
55
|
+
.flat_map { |file_name| constants_in_files[file_name] }
|
56
|
+
.map { |constant| constant.split('::').last }
|
57
|
+
|
58
|
+
files_to_check = constants_impacted
|
59
|
+
.flat_map { |constant| files_impacted(constants_used_in_files, constant) }
|
60
|
+
.flat_map(&:keys)
|
61
|
+
.map { |file_name| spec_path(file_name) }
|
62
|
+
.uniq
|
63
|
+
.select { |file_name| File.exist? file_name }
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spectrerun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Johnstone
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Given a list of files that have change, find all the specs that should
|
14
|
+
be run
|
15
|
+
email: ncwjohnstone@gmail.com
|
16
|
+
executables:
|
17
|
+
- spectrerun
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/spectrerun
|
22
|
+
- lib/spectrerun.rb
|
23
|
+
homepage: https://github.com/Widdershin/spectrerun
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.2.5
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Find all the specs you need to run
|
47
|
+
test_files: []
|