quick-rspec 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c59dfc88645a56cb8df0beefc55100f90b71dac
4
- data.tar.gz: a01971a8adc9b7a409eb42b3ba7948167f3ea1a7
3
+ metadata.gz: a1543be30abba1ad1f47926a4c048a209f3c5a9b
4
+ data.tar.gz: 5761bb6ba885f7d46afb8c31d7db3744db95183c
5
5
  SHA512:
6
- metadata.gz: 1f760909519c88a15f62e08af92a56219847d8b90120dba755283477b457b2b952edf22ba4570b235f367bd942e42b5bcce6bb810cba0791fa79036d1bcfa96f
7
- data.tar.gz: dcd4885654a90200621da3458309ebc5d580f9c875cb2e1b1663ca1a1729b0a148f9b8a0f98aac0c67fe94689ab25ec306bb5ed129ad5ccaf375e8bce0823008
6
+ metadata.gz: e5ae715a5e53d8c5f461c9ca77bdc85b27e538a08d00b6acd1fd103ca4b6d469e4f0cb4c5e147146db9a655ecacb9bc55b122898b1dbafcf95df23a57f8c394c
7
+ data.tar.gz: 20db3089a64739cdfe88aa3c3b12804fbd4b86d64cc8b50c6ec632f79f135477c61603545717c18f44bd8bd20b98baccb38ca0ee0f28829eb881ea78515bbf4e
data/lib/quick-rspec.rb CHANGED
@@ -8,8 +8,10 @@ class QuickRspec < Rails::Railtie
8
8
  end
9
9
 
10
10
  class << self
11
+ @@threads = []
11
12
  @@coverage = {}
12
13
  @@last_cover = {}
14
+ @@mutex = Mutex.new
13
15
 
14
16
  def start
15
17
  Coverage.start
@@ -20,21 +22,25 @@ class QuickRspec < Rails::Railtie
20
22
  root = Rails.root.to_s
21
23
  result = {}
22
24
  cover = Coverage.peek_result
23
- cover.each do |path, coverage|
24
- next unless path =~ %r{^#{Regexp.escape(root)}}i
25
- next if path =~ %r{^#{Regexp.escape(root)}\/spec\/}i
26
- last_cover = @@last_cover[path]
27
- path = QuickRspec.relevant_path(path)
28
- coverage = coverage.each_with_index.map.map do |count, index|
29
- count -= last_cover[index] if count.present? && last_cover.present? && last_cover[index].present?
30
- index if count&.positive?
25
+ prev_cover = @@last_cover
26
+ @@last_cover = cover
27
+ @@threads << Thread.new do
28
+ cover.each do |path, coverage|
29
+ next unless path =~ %r{^#{Regexp.escape(root)}}i
30
+ next if path =~ %r{^#{Regexp.escape(root)}\/spec\/}i
31
+ last_cover = prev_cover[path]
32
+ path = QuickRspec.relevant_path(path)
33
+ coverage = coverage.each_with_index.map.map do |count, index|
34
+ index unless last_cover.present? && count == last_cover[index]
35
+ end
36
+ coverage.compact!
37
+ next unless coverage.any?
38
+ result[path] = coverage
39
+ end
40
+ @@mutex.synchronize do
41
+ @@coverage[spec] = result
31
42
  end
32
- coverage.compact!
33
- next unless coverage.any?
34
- result[path] = coverage
35
43
  end
36
- @@coverage[spec] = result
37
- @@last_cover = cover
38
44
  end
39
45
 
40
46
  def relevant_path(path)
@@ -55,6 +61,11 @@ class QuickRspec < Rails::Railtie
55
61
  end
56
62
 
57
63
  def save_stats
64
+ new_coverage = @@coverage
65
+ load_stats()
66
+ new_coverage.each do |spec, coverage|
67
+ @@coverage[spec] = coverage
68
+ end
58
69
  File.open(Rails.root.join('tmp/quick_rspec.new.json'), 'w+') do |f|
59
70
  f.write @@coverage.to_json
60
71
  end
@@ -75,12 +86,15 @@ class QuickRspec < Rails::Railtie
75
86
  spec
76
87
  end.compact
77
88
  end
89
+
90
+ def on_exit
91
+ @@threads.map(&:join)
92
+ QuickRspec.save_stats
93
+ end
78
94
  end
79
95
  end
80
96
 
81
97
  if Rails.env.test?
82
- QuickRspec.load_stats
83
-
84
98
  QuickRspec.start
85
99
 
86
100
  RSpec.configure do |config|
@@ -89,5 +103,5 @@ if Rails.env.test?
89
103
  end
90
104
  end
91
105
 
92
- at_exit { QuickRspec.save_stats }
106
+ at_exit { QuickRspec.on_exit }
93
107
  end
@@ -9,10 +9,9 @@ task quick_rspec: :environment do
9
9
  specs = []
10
10
 
11
11
  files = `git diff --name-only`.split("\n")
12
- files.reject! { |file| file =~ %r{^tmp\/}i }
12
+ files.select! { |file| file =~ %r{^(app|lib|config|spec)\/}i }
13
13
 
14
14
  files.each do |file|
15
- next if file =~ %r{^tmp\/}i
16
15
  if file =~ %r{^spec\/}i
17
16
  specs << file
18
17
  else
data/quick-rspec.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.required_ruby_version = '>= 2.3'
7
7
  spec.name = "quick-rspec"
8
- spec.version = "0.1.4"
8
+ spec.version = "0.1.5"
9
9
  spec.authors = ["Dmitry Silchenko"]
10
10
  spec.email = ["dmitry@desofto.com"]
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Silchenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler