sub_diff 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68d94bfc8c4cdd97c0ad2830274f3e62aac1703f
4
- data.tar.gz: 9e3d83376c646399983352017abd0ed848d5c8ff
3
+ metadata.gz: db20a712d5a1c4827ecdb355b8bf7908014acf55
4
+ data.tar.gz: 2e0fada841e581713251b66ead8df9dad486d3cd
5
5
  SHA512:
6
- metadata.gz: 3326572008e2952db12ea5c5701c35bf9acdf8d2d0c54b304d722d727e1ec01a46933259d0c0c27756098f6e09fceef811b182ba2acd75d053214f8bbb22ab09
7
- data.tar.gz: a45b5a88dbf77f7ae0667f9a0864b00fc2dffa8db331e2ca03435af66c2d0432f99d9be97edb3875d839cd7d4bc7a1d5c40810f758fd4a8fabf126b49cf12285
6
+ metadata.gz: 210f157fb1dd0ec4da7384d888ed07399507372a8afd0f11bfdc5583935012dc736c947c1f528aabe86386030570e29f5976fc1057f0c95e2c3064a0e79b0520
7
+ data.tar.gz: 3f4c90c216981bb97c04edb43785e5a1cabc5376858e8b82f0c5b36f853ed02da542addfab1f491eab301622505601962d2f07eff137877ffc46af6ae70bee45
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sub_diff (1.0.0)
4
+ sub_diff (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
@@ -1,10 +1,10 @@
1
1
  require 'forwardable'
2
- require 'sub_diff/diff_collection'
2
+ require 'sub_diff/collection'
3
3
  require 'sub_diff/differ'
4
4
  require 'sub_diff/gsub'
5
5
 
6
6
  module SubDiff
7
- class DiffBuilder < Struct.new(:string, :type)
7
+ class Builder < Struct.new(:string, :type)
8
8
  extend Forwardable
9
9
 
10
10
  def_delegators :instance, :diff
@@ -28,7 +28,7 @@ module SubDiff
28
28
  end
29
29
 
30
30
  def collection
31
- DiffCollection.new(string)
31
+ Collection.new(string)
32
32
  end
33
33
  end
34
34
  end
@@ -3,7 +3,7 @@ require 'forwardable'
3
3
  require 'sub_diff/diff'
4
4
 
5
5
  module SubDiff
6
- class DiffCollection < SimpleDelegator
6
+ class Collection < SimpleDelegator
7
7
  extend Forwardable
8
8
  include Enumerable
9
9
 
@@ -1,14 +1,14 @@
1
- require 'sub_diff/diff_builder'
1
+ require 'sub_diff/builder'
2
2
 
3
3
  module SubDiff
4
4
  module CoreExt
5
5
  module String
6
6
  def sub_diff(*args, &block)
7
- DiffBuilder.new(self, :sub).diff(*args, &block)
7
+ Builder.new(self, :sub).diff(*args, &block)
8
8
  end
9
9
 
10
10
  def gsub_diff(*args, &block)
11
- DiffBuilder.new(self, :gsub).diff(*args, &block)
11
+ Builder.new(self, :gsub).diff(*args, &block)
12
12
  end
13
13
  end
14
14
  end
@@ -1,22 +1,22 @@
1
+ require 'forwardable'
2
+
1
3
  module SubDiff
2
- class Differ < Struct.new(:diff_collection, :diff_method)
4
+ class Differ < Struct.new(:collection, :type)
5
+ extend Forwardable
6
+
7
+ def_delegators :collection, :string
8
+
3
9
  def diff(*args)
4
10
  # Ruby 1.8.7 does not support additional args after * (splat)
5
11
  block = args.pop
6
12
 
7
- differ.call(args.first) do |match|
13
+ string.send(type, args.first) do |match|
8
14
  diff = { :match => match, :prefix => $`, :suffix => $' }
9
15
  diff[:replacement] = match.sub(*args, &block)
10
- yield(diff_collection, diff)
16
+ yield(collection, diff)
11
17
  end
12
18
 
13
- diff_collection
14
- end
15
-
16
- private
17
-
18
- def differ
19
- diff_collection.string.method(diff_method)
19
+ collection
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module SubDiff
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -1,6 +1,6 @@
1
- require File.expand_path('../../../lib/sub_diff/diff_collection', __FILE__)
1
+ require File.expand_path('../../../lib/sub_diff/collection', __FILE__)
2
2
 
3
- RSpec.describe SubDiff::DiffCollection do
3
+ RSpec.describe SubDiff::Collection do
4
4
  subject { described_class.new(diffable) }
5
5
 
6
6
  let(:diffable) { 'this is a simple test' }
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
@@ -39,16 +39,16 @@ files:
39
39
  - LICENSE
40
40
  - README.md
41
41
  - lib/sub_diff.rb
42
+ - lib/sub_diff/builder.rb
43
+ - lib/sub_diff/collection.rb
42
44
  - lib/sub_diff/core_ext/string.rb
43
45
  - lib/sub_diff/diff.rb
44
- - lib/sub_diff/diff_builder.rb
45
- - lib/sub_diff/diff_collection.rb
46
46
  - lib/sub_diff/differ.rb
47
47
  - lib/sub_diff/gsub.rb
48
48
  - lib/sub_diff/sub.rb
49
49
  - lib/sub_diff/version.rb
50
50
  - spec/spec_helper.rb
51
- - spec/sub_diff/diff_collection_spec.rb
51
+ - spec/sub_diff/collection_spec.rb
52
52
  - spec/sub_diff/diff_spec.rb
53
53
  - spec/sub_diff_spec.rb
54
54
  - sub_diff.gemspec
@@ -83,6 +83,6 @@ specification_version: 4
83
83
  summary: Inspect the changes of your `String#sub` and `String#gsub` replacements
84
84
  test_files:
85
85
  - spec/spec_helper.rb
86
- - spec/sub_diff/diff_collection_spec.rb
86
+ - spec/sub_diff/collection_spec.rb
87
87
  - spec/sub_diff/diff_spec.rb
88
88
  - spec/sub_diff_spec.rb