rspeed 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: 27a64c0a7ba3f1c113bbdf8f060be44dad913a684d234663b342a537937ac7f2
4
- data.tar.gz: 47d3a190302b361c6bb76279094a7c04982492e59d099d6acdbe92fcbd26d648
3
+ metadata.gz: 19e3b06a0f6189661598a3db76e740b99b5ab658b3e08119fa6f8a74efb74552
4
+ data.tar.gz: 813bd8934d23e84bcb0facf56da0bf53c4017d5af03337989a42ffff2dac679d
5
5
  SHA512:
6
- metadata.gz: ac35df999459a32e06989e84d0e703f52a61b896e3a68ef7993c6eaf70952dd05826dffdf36f01fe5843b3916e57b24112708cbcadd19b83eb018c990f2bda4c
7
- data.tar.gz: '09feaa28dc6a306f8ba039bcfbf02b500450b6f117160a726f326daae76c9584524825ffd693a4f3a84a61cb181fef7c00216557ce04ccaea736f42d3e9370d8'
6
+ metadata.gz: '004081032114288e16f23c176ca49c03e85274ed6b91272144643452ec5f2a648c829dae5539c94215897f67482a6f0cf1e5253acabeafc6cdf5a6e2fe2681e9'
7
+ data.tar.gz: 2ec7f4991a5702f4bd24000e71eb5426969f0abd3a77cabd521887ad72dac3e3ec5f28f0165193ca806f8e9a9e8fce712ac9923f899c9e8767c8808320400ab4
@@ -1,3 +1,7 @@
1
+ ## v0.3.0
2
+
3
+ - Removed and added files now is considered on run;
4
+
1
5
  ## v0.2.0
2
6
 
3
7
  - Splits specs by examples over files;
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
 
3
2
  module RSpeed
4
3
  class Splitter
@@ -6,7 +5,7 @@ module RSpeed
6
5
 
7
6
  def append(files = file_data)
8
7
  files.each do |time, file|
9
- redis.lpush 'rspeed_tmp', { file: file, time: time.to_f }.to_json
8
+ redis.lpush('rspeed_tmp', { file: file, time: time.to_f }.to_json)
10
9
  end
11
10
  end
12
11
 
@@ -15,9 +14,7 @@ module RSpeed
15
14
  end
16
15
 
17
16
  def diff
18
- (actual_files + added_files).sort_by { |item| item[:time].to_f }.map do |item|
19
- [item[:time], item[:file]]
20
- end
17
+ actual_data + added_data
21
18
  end
22
19
 
23
20
  def first_pipe?
@@ -28,7 +25,7 @@ module RSpeed
28
25
  @get ||= begin
29
26
  return redis.lrange(pattern, 0, -1) if %w[rspeed rspeed_tmp].include?(pattern)
30
27
 
31
- keys(pattern).map { |key| JSON.parse redis.get(key) }
28
+ keys(pattern).map { |key| JSON.parse(redis.get(key)) }
32
29
  end
33
30
  end
34
31
 
@@ -59,17 +56,15 @@ module RSpeed
59
56
  end
60
57
 
61
58
  def rename
62
- redis.rename 'rspeed_tmp', 'rspeed'
59
+ redis.rename('rspeed_tmp', 'rspeed')
63
60
  end
64
61
 
65
62
  def result?
66
63
  !keys('rspeed').empty?
67
64
  end
68
65
 
69
- def save(data = rspeed_data)
70
- split(data).each do |key, value|
71
- redis.set key, value.to_json
72
- end
66
+ def save(data = diff)
67
+ split(data).each { |key, value| redis.set(key, value.to_json) }
73
68
  end
74
69
 
75
70
  def split(data)
@@ -96,32 +91,36 @@ module RSpeed
96
91
 
97
92
  private
98
93
 
99
- def actual_files
100
- rspeed_data.select { |item| actual_specs.include?(item[:file]) }
94
+ def actual_data
95
+ rspeed_data.select { |item| actual_files.include?(item[:file]) }
101
96
  end
102
97
 
103
- def actual_specs
104
- Dir['./spec/**/*_spec.rb']
98
+ def actual_files
99
+ @actual_files ||= Dir['./spec/**/*_spec.rb']
105
100
  end
106
101
 
107
- def added_files
102
+ def added_data
108
103
  added_specs.map { |item| { file: item, time: 0 } }
109
104
  end
110
105
 
111
106
  def added_specs
112
- actual_specs - saved_specs
107
+ actual_files - old_files
113
108
  end
114
109
 
115
110
  def file_data
116
111
  CSV.read('rspeed.csv')
117
112
  end
118
113
 
114
+ def old_files
115
+ rspeed_data.map { |item| item[:file] }
116
+ end
117
+
119
118
  def redis
120
119
  @redis ||= ::Redis.new(db: ENV['RSPEED_DB'], host: ENV['RSPEED_HOST'], port: ENV.fetch('RSPEED_PORT') { 6379 })
121
120
  end
122
121
 
123
122
  def removed_specs
124
- saved_specs - actual_specs
123
+ old_files - actual_files
125
124
  end
126
125
 
127
126
  def removed_time
@@ -129,11 +128,7 @@ module RSpeed
129
128
  end
130
129
 
131
130
  def rspeed_data
132
- get('rspeed').map { |item| JSON.parse item, symbolize_names: true }
133
- end
134
-
135
- def saved_specs
136
- rspeed_data.map { |item| item[:file] }
131
+ @rspeed_data ||= get('rspeed').map { |item| JSON.parse(item, symbolize_names: true) }
137
132
  end
138
133
  end
139
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpeed
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -21,9 +21,9 @@ RSpec.describe RSpeed::Splitter, '#diff' do
21
21
 
22
22
  it 'removes removed specs and adds new spec and keeps keeped specs based on rspeed key values' do
23
23
  expect(splitter.diff).to eq [
24
- [0, '4_spec.rb'],
25
- [2, '2_spec.rb'],
26
- [3, '3_spec.rb']
24
+ { file: '3_spec.rb', time: 3 },
25
+ { file: '2_spec.rb', time: 2 },
26
+ { file: '4_spec.rb', time: 0 },
27
27
  ]
28
28
  end
29
29
  end
@@ -10,19 +10,21 @@ RSpec.describe RSpeed::Splitter, '.save' do
10
10
  before do
11
11
  allow(splitter).to receive(:pipes).and_return(3)
12
12
 
13
- redis.lpush 'rspeed', { file: "./spec/0_2_spec.rb", time: '0.2' }.to_json
14
- redis.lpush 'rspeed', { file: "./spec/0_3_spec.rb", time: '0.3' }.to_json
15
- redis.lpush 'rspeed', { file: "./spec/0_4_spec.rb", time: '0.4' }.to_json
16
- redis.lpush 'rspeed', { file: "./spec/0_7_spec.rb", time: '0.7' }.to_json
17
- redis.lpush 'rspeed', { file: "./spec/1_1_spec.rb", time: '1.1' }.to_json
18
- redis.lpush 'rspeed', { file: "./spec/1_5_spec.rb", time: '1.5' }.to_json
19
- redis.lpush 'rspeed', { file: "./spec/2_0_spec.rb", time: '2.0' }.to_json
13
+ allow(splitter).to receive(:diff).and_return([
14
+ { file: "./spec/0_2_spec.rb", time: '0.2' },
15
+ { file: "./spec/0_3_spec.rb", time: '0.3' },
16
+ { file: "./spec/0_4_spec.rb", time: '0.4' },
17
+ { file: "./spec/0_7_spec.rb", time: '0.7' },
18
+ { file: "./spec/1_1_spec.rb", time: '1.1' },
19
+ { file: "./spec/1_5_spec.rb", time: '1.5' },
20
+ { file: "./spec/2_0_spec.rb", time: '2.0' },
21
+ ])
20
22
  end
21
23
 
22
24
  it 'saves the data on redis' do
23
25
  splitter.save
24
26
 
25
- expect(redis.keys('*')).to eq %w[rspeed rspeed_1 rspeed_2 rspeed_3]
27
+ expect(redis.keys('*')).to eq %w[rspeed_1 rspeed_2 rspeed_3]
26
28
 
27
29
  expect(JSON.parse(redis.get('rspeed_1'), symbolize_names: true)).to eq(
28
30
  files: [{ file: './spec/2_0_spec.rb', time: 2.0 }],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-19 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis