sub_diff 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/Gemfile +1 -3
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/README.md +4 -2
- data/lib/sub_diff/collection.rb +0 -1
- data/lib/sub_diff/differ.rb +4 -7
- data/lib/sub_diff/sub.rb +3 -6
- data/lib/sub_diff/version.rb +1 -1
- data/spec/sub_diff/collection_spec.rb +4 -4
- data/spec/sub_diff_spec.rb +10 -14
- data/sub_diff.gemspec +13 -12
- 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: 21eca8a2613f2283e8b2ef108dd26fcc8fff6b97
|
4
|
+
data.tar.gz: 28b9f6a0700801ddcdc7968dad2c881554216697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dcd408aae1f8d2feee698eaf84cd0e447d7fc8fd11a91e10147dcf96714fff538eca8dfe8b397e7c916722fe78dd6b8c3813b9b574f0be2bdb66b550b4f0e7f
|
7
|
+
data.tar.gz: 18145f531b6e8e73fec399c49db871ac410b5b5e1b648da6c0fa80cb061e5013663899eb72e572069269830201b4f53a2947997e5bf367403898ea8751295674
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,9 @@ gem install sub_diff
|
|
16
16
|
|
17
17
|
## Requirements
|
18
18
|
|
19
|
-
Ruby
|
19
|
+
Ruby 2.0+
|
20
|
+
|
21
|
+
For older Ruby versions (1.8+), use the [1.0.7](https://github.com/shuber/sub_diff/tree/1.0.7) tag.
|
20
22
|
|
21
23
|
|
22
24
|
## Usage
|
@@ -118,4 +120,4 @@ bundle exec rspec
|
|
118
120
|
|
119
121
|
## License
|
120
122
|
|
121
|
-
[MIT](https://github.com/shuber/sub_diff/blob/master/LICENSE) - Copyright © 2011 Sean Huber
|
123
|
+
[MIT](https://github.com/shuber/sub_diff/blob/master/LICENSE) - Copyright © 2011-2015 Sean Huber
|
data/lib/sub_diff/collection.rb
CHANGED
data/lib/sub_diff/differ.rb
CHANGED
@@ -10,13 +10,10 @@ module SubDiff
|
|
10
10
|
@builder = builder
|
11
11
|
end
|
12
12
|
|
13
|
-
def each_diff(*args)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
string.send(diff_method, args.first) do |match|
|
18
|
-
diff = { :match => match, :prefix => $`, :suffix => $' }
|
19
|
-
diff[:replacement] = match.sub(*args, &block)
|
13
|
+
def each_diff(search, *args, block)
|
14
|
+
string.send(diff_method, search) do |match|
|
15
|
+
diff = { match: match, prefix: $`, suffix: $' }
|
16
|
+
diff[:replacement] = match.sub(search, *args, &block)
|
20
17
|
yield(builder, diff)
|
21
18
|
end
|
22
19
|
end
|
data/lib/sub_diff/sub.rb
CHANGED
@@ -6,12 +6,9 @@ module SubDiff
|
|
6
6
|
@differ = differ
|
7
7
|
end
|
8
8
|
|
9
|
-
def diff(*args, &block)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
differ.each_diff(*args) do |builder, diff|
|
14
|
-
process(builder, diff, args.first)
|
9
|
+
def diff(search, *args, &block)
|
10
|
+
differ.each_diff(search, *args, block) do |builder, diff|
|
11
|
+
process(builder, diff, search)
|
15
12
|
end
|
16
13
|
end
|
17
14
|
|
data/lib/sub_diff/version.rb
CHANGED
@@ -5,13 +5,13 @@ RSpec.describe SubDiff::Collection do
|
|
5
5
|
|
6
6
|
describe '#changed?' do
|
7
7
|
it 'should return true if any diffs have changed' do
|
8
|
-
diff = double('diff',
|
8
|
+
diff = double('diff', changed?: true, empty?: false)
|
9
9
|
subject.push(diff)
|
10
10
|
expect(subject).to be_changed
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should return false if no diffs have changed' do
|
14
|
-
diff = double('diff',
|
14
|
+
diff = double('diff', changed?: false, empty?: false)
|
15
15
|
subject.push(diff)
|
16
16
|
expect(subject).not_to be_changed
|
17
17
|
end
|
@@ -48,13 +48,13 @@ RSpec.describe SubDiff::Collection do
|
|
48
48
|
|
49
49
|
describe '#push' do
|
50
50
|
it 'should append a diff' do
|
51
|
-
diff = double('diff',
|
51
|
+
diff = double('diff', empty?: false)
|
52
52
|
block = proc { subject.push(diff) }
|
53
53
|
expect(block).to change(subject.diffs, :size)
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should not append an empty diff' do
|
57
|
-
diff = double('diff',
|
57
|
+
diff = double('diff', empty?: true)
|
58
58
|
block = proc { subject.push(diff) }
|
59
59
|
expect(block).not_to change(subject.diffs, :size)
|
60
60
|
end
|
data/spec/sub_diff_spec.rb
CHANGED
@@ -46,13 +46,11 @@ RSpec.describe SubDiff do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
expect(result.size).to eq(3)
|
55
|
-
end
|
49
|
+
context 'with a hash' do
|
50
|
+
it 'should process arguments correctly' do
|
51
|
+
result = subject.sub_diff(/simple/, 'simple' => 'harder')
|
52
|
+
expect(result.to_s).to eq('this is a harder test')
|
53
|
+
expect(result.size).to eq(3)
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end
|
@@ -102,13 +100,11 @@ RSpec.describe SubDiff do
|
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
expect(result.size).to eq(4)
|
111
|
-
end
|
103
|
+
context 'with a hash' do
|
104
|
+
it 'should process arguments correctly' do
|
105
|
+
result = subject.gsub_diff(/(\S*is)/, 'is' => 'IS', 'this' => 'THIS')
|
106
|
+
expect(result.to_s).to eq('THIS IS a simple test')
|
107
|
+
expect(result.size).to eq(4)
|
112
108
|
end
|
113
109
|
end
|
114
110
|
end
|
data/sub_diff.gemspec
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require File.expand_path('../lib/sub_diff/version', __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.author
|
5
|
-
s.email
|
6
|
-
s.extra_rdoc_files
|
7
|
-
s.files
|
8
|
-
s.homepage
|
9
|
-
s.license
|
10
|
-
s.name
|
11
|
-
s.rdoc_options
|
12
|
-
s.require_paths
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
4
|
+
s.author = 'Sean Huber'
|
5
|
+
s.email = 'github@shuber.io'
|
6
|
+
s.extra_rdoc_files = %w(LICENSE)
|
7
|
+
s.files = `git ls-files`.split("\n")
|
8
|
+
s.homepage = 'https://github.com/shuber/sub_diff'
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.name = 'sub_diff'
|
11
|
+
s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.md)
|
12
|
+
s.require_paths = %w(lib)
|
13
|
+
s.required_ruby_version = '>= 2.0.0'
|
14
|
+
s.summary = 'Inspect the changes of your `String#sub` and `String#gsub` replacements'
|
15
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
|
+
s.version = SubDiff::VERSION
|
16
17
|
|
17
18
|
s.add_development_dependency 'rspec'
|
18
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
73
|
+
version: 2.0.0
|
74
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|