devloop 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/devloop/diff_parser.rb +20 -9
- data/lib/devloop/version.rb +1 -1
- data/spec/diff_parser_spec.rb +81 -2
- 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: 4c05521d9743b10962d9a0fb72bdbe848684923192ad72b4dccb5cf577481a93
|
4
|
+
data.tar.gz: 850d44822f193f71a61f75846bef409b52e5f9782f1b73a083694a18c0c9610a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f9a620c03e1a48ca1e22eb247789b75f828f1991215d2abcc9331bb68b496849b69db06c80968fea0dda6b3d8515022576b7e7ce417083a88fd73862e3032a3
|
7
|
+
data.tar.gz: 0f34eb18349d10c0bf37e08726c1892e56e5d52c70762b7f0405f3839ed3396fda4fbb951a3f1badff3142b2e66734cf2381fa4c4609c13b56002965600fba27
|
data/lib/devloop/diff_parser.rb
CHANGED
@@ -4,24 +4,35 @@ module Devloop
|
|
4
4
|
new.call(diff)
|
5
5
|
end
|
6
6
|
|
7
|
+
Diff = Struct.new(:filename, :line_number)
|
8
|
+
|
7
9
|
def call(diff)
|
8
|
-
_,
|
10
|
+
_, diffs_data = diff.split("\n").reduce(["", []]) do |(file, diffs_data), line|
|
9
11
|
if line.start_with?("+++ b/")
|
10
|
-
[line[6..-1],
|
12
|
+
[line[6..-1], diffs_data]
|
11
13
|
elsif line.start_with?("@@ -")
|
12
14
|
line_number = line.match(/@@ -(\d+)/)[1]
|
13
|
-
|
14
|
-
[file, results << "#{relative_path(file)}"]
|
15
|
-
else
|
16
|
-
[file, results << "#{relative_path(file)}:#{line_number}"]
|
17
|
-
end
|
15
|
+
[file, diffs_data << Diff.new(relative_path(file), line_number)]
|
18
16
|
else
|
19
|
-
[file,
|
17
|
+
[file, diffs_data]
|
20
18
|
end
|
21
19
|
end.uniq
|
22
20
|
|
21
|
+
results = diffs_data.group_by do |el|
|
22
|
+
el.filename
|
23
|
+
end.map do |key, value|
|
24
|
+
line_numbers = value.map(&:line_number).map(&:to_i)
|
25
|
+
if line_numbers.include?(0) || line_numbers.include?(1)
|
26
|
+
key
|
27
|
+
else
|
28
|
+
lines_range = (line_numbers.min..line_numbers.max).to_a.join(":")
|
29
|
+
|
30
|
+
"#{key}:#{lines_range}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
# Remove filenames with line number if filename without line number is present
|
24
|
-
results.reject { |result| results.include?(result.split(":").first) && result.include?(":") }
|
35
|
+
res = results.reject { |result| results.include?(result.split(":").first) && result.include?(":") }
|
25
36
|
end
|
26
37
|
|
27
38
|
private
|
data/lib/devloop/version.rb
CHANGED
data/spec/diff_parser_spec.rb
CHANGED
@@ -68,7 +68,7 @@ describe Devloop::DiffParser do
|
|
68
68
|
|
69
69
|
it "parses the diff correctly" do
|
70
70
|
expect(Devloop::DiffParser.call(diff1)).to eq(["spec/models/team_spec.rb:10", "spec/models/user_spec.rb:167"])
|
71
|
-
expect(Devloop::DiffParser.call(diff2)).to eq(["spec/models/team_spec.rb:19
|
71
|
+
expect(Devloop::DiffParser.call(diff2)).to eq(["spec/models/team_spec.rb:19:20:21:22:23:24"])
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -93,7 +93,86 @@ describe Devloop::DiffParser do
|
|
93
93
|
it "parses the diff correctly" do
|
94
94
|
allow_any_instance_of(Devloop::DiffParser).to receive(:git_root_path).and_return("/Users/username/projects/")
|
95
95
|
allow_any_instance_of(Devloop::DiffParser).to receive(:project_path).and_return("src/")
|
96
|
-
expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/team_spec.rb:19
|
96
|
+
expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/team_spec.rb:19:20:21:22:23:24"])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "removes 0 line numbers" do
|
101
|
+
let(:diff) do
|
102
|
+
<<~DIFF
|
103
|
+
diff --git a/spec/config_spec.rb b/spec/config_spec.rb
|
104
|
+
index d9716e7..b470ec2 100644
|
105
|
+
--- a/spec/config_spec.rb
|
106
|
+
+++ b/spec/config_spec.rb
|
107
|
+
@@ -5 +5 @@ require "spec_helper"
|
108
|
+
-describe "PgLocksMonitor::Confiuration" do
|
109
|
+
+describe "PgLocksMonitor::Configuration" do
|
110
|
+
@@ -8,2 +8,5 @@ describe "PgLocksMonitor::Confiuration" do
|
111
|
+
- expect(config.notify_locks).to eq true
|
112
|
+
- expect(config.notify_blocking).to eq true
|
113
|
+
+ expect(config.monitor_locks).to eq true
|
114
|
+
+ expect(config.monitor_blocking).to eq true
|
115
|
+
+ expect(config.locks_min_duration_ms).to eq 200
|
116
|
+
+ expect(config.blocking_min_duration_ms).to eq 100
|
117
|
+
+ expect(config.notifier_class).to eq PgLocksMonitor::DefaultNotifier
|
118
|
+
@@ -14 +17 @@ describe "PgLocksMonitor::Confiuration" do
|
119
|
+
- config.notify_locks = false
|
120
|
+
+ config.monitor_locks = false
|
121
|
+
@@ -17 +20 @@ describe "PgLocksMonitor::Confiuration" do
|
122
|
+
- expect(PgLocksMonitor.configuration.notify_locks).to eq false
|
123
|
+
+ expect(PgLocksMonitor.configuration.monitor_locks).to eq false
|
124
|
+
diff --git a/spec/default_notifier_spec.rb b/spec/default_notifier_spec.rb
|
125
|
+
new file mode 100644
|
126
|
+
index 0000000..d99d3a1
|
127
|
+
--- /dev/null
|
128
|
+
+++ b/spec/default_notifier_spec.rb
|
129
|
+
@@ -0,0 +1,11 @@
|
130
|
+
+# frozen_string_literal: true
|
131
|
+
+
|
132
|
+
+require "spec_helper"
|
133
|
+
+
|
134
|
+
+describe PgLocksMonitor::DefaultNotifier do
|
135
|
+
+ it "requires correct config if Slack notifications enabled" do
|
136
|
+
+ expect {
|
137
|
+
+ PgLocksMonitor::DefaultNotifier.call({})
|
138
|
+
+ }.not_to raise_error
|
139
|
+
+ end
|
140
|
+
+end
|
141
|
+
DIFF
|
142
|
+
end
|
143
|
+
|
144
|
+
it "parses the diff correctly" do
|
145
|
+
expect(Devloop::DiffParser.call(diff)).to eq(["spec/config_spec.rb:5:6:7:8:9:10:11:12:13:14:15:16:17", "spec/default_notifier_spec.rb"])
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "executes each matching spec" do
|
150
|
+
let(:diff) do
|
151
|
+
<<~DIFF
|
152
|
+
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
|
153
|
+
index 410ffa8c..0266ea38 100644
|
154
|
+
--- a/spec/models/user_spec.rb
|
155
|
+
+++ b/spec/models/user_spec.rb
|
156
|
+
@@ -10,3 +10,3 @@ describe User do
|
157
|
+
- it "has a valid factory" do
|
158
|
+
- expect(user).to be_valid
|
159
|
+
- end
|
160
|
+
+ it "has a valid factory" do #
|
161
|
+
+ expect(user).to be_valid #
|
162
|
+
+ end #
|
163
|
+
@@ -14,2 +14,2 @@ describe User do
|
164
|
+
- it "has pending_feedbacks" do
|
165
|
+
- expect(create(:user).pending_feedbacks).to eq []
|
166
|
+
+ it "has pending_feedbacks" do#
|
167
|
+
+ expect(create(:user).pending_feedbacks).to eq [] #
|
168
|
+
@@ -17 +17 @@ describe User do
|
169
|
+
-
|
170
|
+
+#
|
171
|
+
DIFF
|
172
|
+
end
|
173
|
+
|
174
|
+
it "parses the diff correctly" do
|
175
|
+
expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/user_spec.rb:10:11:12:13:14:15:16:17"])
|
97
176
|
end
|
98
177
|
end
|
99
178
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devloop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|