sub_diff 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/sub_diff/builder.rb +15 -11
- data/lib/sub_diff/differ.rb +10 -1
- data/lib/sub_diff/sub.rb +7 -1
- data/lib/sub_diff/version.rb +1 -1
- 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: 00af3c2d98b709d67f09613790843c055aa6e0ac
|
4
|
+
data.tar.gz: b22a8f236b3c94147cf11cb32b6a57432df5a950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619fce2ea0266f758a6136bde2ca11e6f5130cd27f82487dae99963eeca2670e9cdde6b92bda802770f533d5ba92126ad50f683f1b2b36c72047614abd8de70c
|
7
|
+
data.tar.gz: f2338bcd91dfaae6f19b4bb8378202e47c39abf087cd0cc268a662d7b2788e030b4384d239e985332d84789910a9aca723c02b95b43e877daff82f3c22cba6cb
|
data/README.md
CHANGED
data/lib/sub_diff/builder.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
module SubDiff
|
2
|
-
class Builder
|
2
|
+
class Builder
|
3
|
+
def initialize(string, type)
|
4
|
+
@string = string
|
5
|
+
@type = type
|
6
|
+
end
|
7
|
+
|
3
8
|
def diff(*args, &block)
|
4
|
-
|
9
|
+
@collection = Collection.new(string)
|
10
|
+
adapter.diff(*args, &block)
|
5
11
|
collection
|
6
12
|
end
|
7
13
|
|
@@ -15,24 +21,22 @@ module SubDiff
|
|
15
21
|
|
16
22
|
private
|
17
23
|
|
18
|
-
|
19
|
-
|
24
|
+
attr_reader :collection, :string, :type
|
25
|
+
|
26
|
+
def adapter
|
27
|
+
adapter_class.new(differ)
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
23
|
-
Module.nesting.last.const_get(
|
30
|
+
def adapter_class
|
31
|
+
Module.nesting.last.const_get(adapter_name)
|
24
32
|
end
|
25
33
|
|
26
|
-
def
|
34
|
+
def adapter_name
|
27
35
|
type.to_s.capitalize
|
28
36
|
end
|
29
37
|
|
30
38
|
def differ
|
31
39
|
Differ.new(self, type)
|
32
40
|
end
|
33
|
-
|
34
|
-
def collection
|
35
|
-
@collection ||= Collection.new(string)
|
36
|
-
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/sub_diff/differ.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module SubDiff
|
2
|
-
class Differ
|
2
|
+
class Differ
|
3
3
|
extend Forwardable
|
4
4
|
|
5
5
|
def_delegators :builder, :string
|
6
6
|
|
7
|
+
def initialize(builder, type)
|
8
|
+
@builder = builder
|
9
|
+
@type = type
|
10
|
+
end
|
11
|
+
|
7
12
|
def each_diff(*args)
|
8
13
|
# Ruby 1.8.7 does not support additional args after * (splat)
|
9
14
|
block = args.pop
|
@@ -14,5 +19,9 @@ module SubDiff
|
|
14
19
|
yield(builder, diff)
|
15
20
|
end
|
16
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :builder, :type
|
17
26
|
end
|
18
27
|
end
|
data/lib/sub_diff/sub.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module SubDiff
|
2
|
-
class Sub
|
2
|
+
class Sub
|
3
|
+
def initialize(differ)
|
4
|
+
@differ = differ
|
5
|
+
end
|
6
|
+
|
3
7
|
def diff(*args, &block)
|
4
8
|
# Ruby 1.8.7 does not support additional args after * (splat)
|
5
9
|
args.push(block)
|
@@ -11,6 +15,8 @@ module SubDiff
|
|
11
15
|
|
12
16
|
private
|
13
17
|
|
18
|
+
attr_reader :differ
|
19
|
+
|
14
20
|
def process(builder, diff, search)
|
15
21
|
builder << prefix(diff)
|
16
22
|
builder.push(diff[:replacement], diff[:match])
|
data/lib/sub_diff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sub_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|