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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rspeed/splitter.rb +18 -23
- data/lib/rspeed/version.rb +1 -1
- data/spec/models/rspeed/splitter/diff_spec.rb +3 -3
- data/spec/models/rspeed/splitter/save_spec.rb +10 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e3b06a0f6189661598a3db76e740b99b5ab658b3e08119fa6f8a74efb74552
|
4
|
+
data.tar.gz: 813bd8934d23e84bcb0facf56da0bf53c4017d5af03337989a42ffff2dac679d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '004081032114288e16f23c176ca49c03e85274ed6b91272144643452ec5f2a648c829dae5539c94215897f67482a6f0cf1e5253acabeafc6cdf5a6e2fe2681e9'
|
7
|
+
data.tar.gz: 2ec7f4991a5702f4bd24000e71eb5426969f0abd3a77cabd521887ad72dac3e3ec5f28f0165193ca806f8e9a9e8fce712ac9923f899c9e8767c8808320400ab4
|
data/CHANGELOG.md
CHANGED
data/lib/rspeed/splitter.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
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
|
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 =
|
70
|
-
split(data).each
|
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
|
100
|
-
rspeed_data.select { |item|
|
94
|
+
def actual_data
|
95
|
+
rspeed_data.select { |item| actual_files.include?(item[:file]) }
|
101
96
|
end
|
102
97
|
|
103
|
-
def
|
104
|
-
Dir['./spec/**/*_spec.rb']
|
98
|
+
def actual_files
|
99
|
+
@actual_files ||= Dir['./spec/**/*_spec.rb']
|
105
100
|
end
|
106
101
|
|
107
|
-
def
|
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
|
-
|
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
|
-
|
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
|
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
|
data/lib/rspeed/version.rb
CHANGED
@@ -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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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[
|
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.
|
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-
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|