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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 752cac400652db441bd35020203e6ab107dd11a6
4
- data.tar.gz: 4f2ec9341e8f352dbf3df9f447d6865e655e1ffe
3
+ metadata.gz: 21eca8a2613f2283e8b2ef108dd26fcc8fff6b97
4
+ data.tar.gz: 28b9f6a0700801ddcdc7968dad2c881554216697
5
5
  SHA512:
6
- metadata.gz: cd95af17191c1b86ed572c8115b32f673beea23c16a15f4d87adb50b94a9b62bdca391054b2ab9e623792d67b6770932a310e759ee0c931ac46c12b1788f2082
7
- data.tar.gz: 39aa674adade0b204e99a553531cd736214a629593b0b5c5c053880c038d0113947fb1bc6f21729cb9b02a93291b80cdec74c08f0f9a466c2ec55010e2ba4a32
6
+ metadata.gz: 3dcd408aae1f8d2feee698eaf84cd0e447d7fc8fd11a91e10147dcf96714fff538eca8dfe8b397e7c916722fe78dd6b8c3813b9b574f0be2bdb66b550b4f0e7f
7
+ data.tar.gz: 18145f531b6e8e73fec399c49db871ac410b5b5e1b648da6c0fa80cb061e5013663899eb72e572069269830201b4f53a2947997e5bf367403898ea8751295674
@@ -5,8 +5,6 @@ addons:
5
5
  install: bundle install --jobs 3 --retry 3
6
6
 
7
7
  rvm:
8
- - 1.8.7
9
- - 1.9.3
10
8
  - 2.0.0
11
9
  - ruby-head
12
10
 
data/Gemfile CHANGED
@@ -2,6 +2,4 @@ source 'https://www.rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- unless RUBY_VERSION =~ /1\.8\./
6
- gem 'codeclimate-test-reporter'
7
- end
5
+ gem 'codeclimate-test-reporter'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sub_diff (1.0.7)
4
+ sub_diff (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Sean Huber - github@shuber.io
1
+ Copyright (c) 2011-2015 Sean Huber - github@shuber.io
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -16,7 +16,9 @@ gem install sub_diff
16
16
 
17
17
  ## Requirements
18
18
 
19
- Ruby 1.8.7+
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
@@ -4,7 +4,6 @@ module SubDiff
4
4
  include Enumerable
5
5
 
6
6
  def_delegators :diffs, :each, :size
7
- def_delegators :__getobj__, :to_s
8
7
 
9
8
  attr_reader :string, :diffs
10
9
 
@@ -10,13 +10,10 @@ module SubDiff
10
10
  @builder = builder
11
11
  end
12
12
 
13
- def each_diff(*args)
14
- # Ruby 1.8.7 does not support additional args after * (splat)
15
- block = args.pop
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
@@ -6,12 +6,9 @@ module SubDiff
6
6
  @differ = differ
7
7
  end
8
8
 
9
- def diff(*args, &block)
10
- # Ruby 1.8.7 does not support additional args after * (splat)
11
- args.push(block)
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
 
@@ -1,3 +1,3 @@
1
1
  module SubDiff
2
- VERSION = '1.0.7'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -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', :changed? => true, :empty? => false)
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', :changed? => false, :empty? => false)
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', :empty? => false)
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', :empty? => true)
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
@@ -46,13 +46,11 @@ RSpec.describe SubDiff do
46
46
  end
47
47
  end
48
48
 
49
- if RUBY_VERSION > '1.8.7'
50
- context 'with a hash' do
51
- it 'should process arguments correctly' do
52
- result = subject.sub_diff(/simple/, 'simple' => 'harder')
53
- expect(result.to_s).to eq('this is a harder test')
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
- if RUBY_VERSION > '1.8.7'
106
- context 'with a hash' do
107
- it 'should process arguments correctly' do
108
- result = subject.gsub_diff(/(\S*is)/, 'is' => 'IS', 'this' => 'THIS')
109
- expect(result.to_s).to eq('THIS IS a simple test')
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
@@ -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 = '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.summary = 'Inspect the changes of your `String#sub` and `String#gsub` replacements'
14
- s.test_files = `git ls-files -- spec/*`.split("\n")
15
- s.version = SubDiff::VERSION
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.7
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: '0'
73
+ version: 2.0.0
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="