devloop 0.1.2 → 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 +18 -13
- data/lib/devloop/version.rb +1 -1
- data/spec/diff_parser_spec.rb +33 -3
- 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,30 +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
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
27
|
else
|
28
|
-
|
28
|
+
lines_range = (line_numbers.min..line_numbers.max).to_a.join(":")
|
29
|
+
|
30
|
+
"#{key}:#{lines_range}"
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
# Remove filenames with line number if filename without line number is present
|
35
|
+
res = results.reject { |result| results.include?(result.split(":").first) && result.include?(":") }
|
31
36
|
end
|
32
37
|
|
33
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,7 @@ 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
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -142,7 +142,37 @@ describe Devloop::DiffParser do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
it "parses the diff correctly" do
|
145
|
-
expect(Devloop::DiffParser.call(diff)).to eq(["spec/config_spec.rb:5
|
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"])
|
146
176
|
end
|
147
177
|
end
|
148
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
|