devloop 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/devloop +5 -0
- 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: 41dcab2a2c737d831c773f69df17a5b3f940bf3afd17a7b28aa43d0d2babff28
|
4
|
+
data.tar.gz: 959cab9d951a675abead4c652b2265140b32536d76bd69beaaf123fd5d06a06e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 185b68859cb4a1b50f0b532a63922f9ada0cbae2b14cfb0f39c5ae045f10adeac219a15e11bc71a483b91e40b458146c42cd3c53da61b4094506db71a7f488f8
|
7
|
+
data.tar.gz: 7d1f59eff8df744568ad744d5812749e543d41ef4156eeb9d87bdc7afa47b84866b16be469aea3fb4dff6140c860690cc7f804966fc8ec7567ab2c2847959323
|
data/bin/devloop
CHANGED
@@ -3,9 +3,14 @@
|
|
3
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") unless $LOAD_PATH.include?(File.dirname(__FILE__) + "/../lib")
|
4
4
|
|
5
5
|
require "devloop"
|
6
|
+
require "devloop/version"
|
6
7
|
require "listen"
|
7
8
|
|
8
9
|
begin
|
10
|
+
if %w[--version -v].include?(ARGV[0])
|
11
|
+
puts "Devloop version #{Devloop::VERSION}"
|
12
|
+
end
|
13
|
+
|
9
14
|
system("bundle exec spring > /dev/null 2>&1")
|
10
15
|
is_bundled = `bundle list`.include?("devloop")
|
11
16
|
run_command = is_bundled ? "bundle exec devloop_run" : "devloop_run"
|
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.4
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|