riffdiff 1.0.19 → 1.0.20
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/refiner.rb +13 -9
- data/spec/refiner_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee5b9e6b9b78557a80e5b991f48673b90eeda880
|
4
|
+
data.tar.gz: 6a27e2bc22a0d7e47d9b414c1c9c1dbd7e2f0c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b340f654f8ad84c341fb462da5dcbada725f4b64dadbce12cf38ee916d8a410df8ebe02b91db1d52e30ef0aad0e7c1a652721408d9b028f164a22398310870c4
|
7
|
+
data.tar.gz: e57adfa78061e38b062909dd49d976debe48fa2b0b286652113ba5c92db2a797711d5df8dce0187eecd9cef6def40e1711718271c8aac1c324173bd4c8d972ae
|
data/lib/refiner.rb
CHANGED
@@ -115,16 +115,20 @@ class Refiner
|
|
115
115
|
#
|
116
116
|
# Returns false if the preconditions for using this method aren't fulfilled
|
117
117
|
def create_one_to_many_refinements(old, new, old_highlights, new_highlights)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
118
|
+
# If things have been removed from the first line, the specialized
|
119
|
+
# highlighting won't work
|
120
|
+
return false if old_highlights.count > 0
|
121
|
+
|
122
|
+
# If the first line was replaced rather than updated, the specialized
|
123
|
+
# highlighting won't work
|
124
|
+
return false if new_highlights.count == 0
|
125
|
+
|
126
|
+
# Specialized highlighting requires exactly one old line
|
127
|
+
return false if old.lines.count != 1
|
128
|
+
|
124
129
|
lines = new.lines
|
125
|
-
|
126
|
-
|
127
|
-
end
|
130
|
+
# Specialized highlighting requires two or more new lines
|
131
|
+
return false if lines.count < 2
|
128
132
|
|
129
133
|
@refined_old = ''
|
130
134
|
|
data/spec/refiner_spec.rb
CHANGED
@@ -148,6 +148,23 @@ RSpec.describe Refiner, '#new' do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
# From https://github.com/walles/riff/issues/5
|
152
|
+
context %(with one line being replaced with many, real world case) do
|
153
|
+
refiner = Refiner.new("THROTTLE_SECONDS = 51\n",
|
154
|
+
"\n" \
|
155
|
+
"Monkey\n" \
|
156
|
+
"THROTTLE_SECONDS = None\n")
|
157
|
+
|
158
|
+
it %(just colors the lines) do
|
159
|
+
expect(refiner.refined_old).to eq(
|
160
|
+
%(#{RED}-THROTTLE_SECONDS = 51#{RESET}\n))
|
161
|
+
expect(refiner.refined_new).to eq(
|
162
|
+
%(#{GREEN}+\n) +
|
163
|
+
%(#{GREEN}+Monkey\n) +
|
164
|
+
%(#{GREEN}+THROTTLE_SECONDS = None#{RESET}\n))
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
151
168
|
context %(with many lines turning into one) do
|
152
169
|
refiner = Refiner.new("abcde,\n" \
|
153
170
|
"fffff,\n" \
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riffdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan Walles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|