sixarm_ruby_string_replace_between 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d10d8d84dfd43cff1a02a4e333b804ed8fbc62488fecbb19059501fa3e533f8d
4
+ data.tar.gz: bf35e5f41ca026e217707b8e0575cd5415861b7a505819af4380e4a94ee76b98
5
+ SHA512:
6
+ metadata.gz: 7a9226d608b9910cf2899ce69d5be94544aaf0ec11cb609ea964c891152cc3ea08ecf4d10057432c7fbbdaf3a4129ffe2cd499639d90cdda80f4e1b93bf806af
7
+ data.tar.gz: b5329c9b73bc3665efc65512615c518de73951c27ac9cecde8e95e1f93f7a901c8260d22ce47ff24fcc29fc6c4374e0d9e92cef6141846f3b362d91c166ea729
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "rake"
3
+ require "rake/testtask"
4
+
5
+ task :default => [:test]
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs.push("lib", "test")
9
+ t.pattern = "test/**/*.rb"
10
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+ require "sixarm_ruby_string_index_after"
7
+
8
+ require_relative "sixarm_ruby_string_replace_between/string/replace_between"
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ String#replace_between
4
+ =end
5
+
6
+ class String
7
+
8
+ # Replace the contents and taintedness of a string subsection
9
+ # with the corresponding values in `other_string`.
10
+ #
11
+ # The params `start_target` and `stop_target` can each be
12
+ # a substring or pattern regexp.
13
+ #
14
+ # Examples:
15
+ #
16
+ # "hello".replace_between("r", "e", "o") => "hero"
17
+ #
18
+ # "hello".replace_between("r", /[eo]/, /[eo]/) => "hero"
19
+ #
20
+ def replace_between(other_string, start_target, stop_target, offset = 0)
21
+ inner_index = index_after(start_target, offset)
22
+ return self if nil == inner_index
23
+ stop_index = index(stop_target, inner_index)
24
+ return self if nil == stop_index
25
+ return slice(0...inner_index) + other_string + slice(stop_index..-1)
26
+ end
27
+
28
+ end
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "sixarm_ruby_string_replace_between"
3
+
4
+ describe String do
5
+
6
+ describe "#replace_between" do
7
+
8
+ describe "with targets that are strings" do
9
+
10
+ it "find" do
11
+ expect("foogoohoo".replace_between("xxx", "oo", "oo")).must_equal "fooxxxoohoo"
12
+ end
13
+
14
+ end
15
+
16
+ describe "with targets that are strings, and an offset" do
17
+
18
+ it "finds" do
19
+ expect("foogoohoo".replace_between("xxx", "oo", "oo", 3)).must_equal "foogooxxxoo"
20
+ end
21
+
22
+ end
23
+
24
+ describe "with targets that are regexps" do
25
+
26
+ it "finds" do
27
+ expect("foogoohoo".replace_between("xxx", /oo/, /oo/)).must_equal "fooxxxoohoo"
28
+ end
29
+
30
+ end
31
+
32
+ describe "with a targets that are regexps, and an offset" do
33
+
34
+ it "finds" do
35
+ expect("foogoohoo".replace_between("xxx", /oo/, /oo/, 3)).must_equal "foogooxxxoo"
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_string_replace_between
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - SixArm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIFPDCCAyQCCQDx7Y5LWGuPPzANBgkqhkiG9w0BAQsFADBgMQswCQYDVQQGEwJV
14
+ UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEP
15
+ MA0GA1UECgwGU2l4QXJtMRMwEQYDVQQDDApzaXhhcm0uY29tMB4XDTE4MDExMzIy
16
+ NDYyM1oXDTIwMTAwOTIyNDYyM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A823Rl35WVSMqiyoxwsrGFwMtayNrrlpdhB8Ny8CMA2NfKyEJkh4+xlE72a
33
+ D8Eu8NFr9Tt5lHWXdZBI5BhzhQxPPxeIuw0wZ3+kiwxRie7K4XhKsOIrPmu2i6QV
34
+ Yl/663wZgWpqrroSnc3PE3lsuTW7quUvayjtqMTU2qrh7i21oB+/Nn+I6gcxYJZb
35
+ UlK+tvsqoM94U6sFTjw9mDt62MLQGrJtHShS+ZZiGmWj1sKreuwGJnCVDoBk15xa
36
+ oqlvfvLAMBCqlfrHhvGUfbIMgzb9uXNmCjzYMsQxuIgF6IMis6Kq02NBAR91HPMe
37
+ 2RoY7CdBHMxW+O0tgS2xoQbOwb+ti1j4MbsWpCqS9Mteck0Z7jZpRRrUDjXU+/7Z
38
+ RmW9HX0oLIoCBDChCcEKG0Ma4IvHUgjv47f5iYpkXuhifiK4xMG/s+T5Euw3Wg9J
39
+ tzpk/VnZXj7Ek/earx+N/Z+Wtnl2xENm5IF8SFPeI1HFa9NH47pqtxF1YKpNIEVc
40
+ 2xa2BNHSePe7tys/2hbmZuyMu8X5ERmovsabSXB3a+YwtJh5c2jhA21wF7986s0q
41
+ -----END CERTIFICATE-----
42
+ date: 2018-02-06 00:00:00.000000000 Z
43
+ dependencies:
44
+ - !ruby/object:Gem::Dependency
45
+ name: sixarm_ruby_string_index_after
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.0.0
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.0.0
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '2'
64
+ - !ruby/object:Gem::Dependency
65
+ name: minitest
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 5.11.1
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '6'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 5.11.1
81
+ - - "<"
82
+ - !ruby/object:Gem::Version
83
+ version: '6'
84
+ - !ruby/object:Gem::Dependency
85
+ name: sixarm_ruby_minitest_extensions
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.8
91
+ - - "<"
92
+ - !ruby/object:Gem::Version
93
+ version: '2'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.0.8
101
+ - - "<"
102
+ - !ruby/object:Gem::Version
103
+ version: '2'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rake
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 12.3.0
111
+ - - "<"
112
+ - !ruby/object:Gem::Version
113
+ version: '13'
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 12.3.0
121
+ - - "<"
122
+ - !ruby/object:Gem::Version
123
+ version: '13'
124
+ - !ruby/object:Gem::Dependency
125
+ name: simplecov
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 0.10.2
131
+ - - "<"
132
+ - !ruby/object:Gem::Version
133
+ version: '2'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 0.10.2
141
+ - - "<"
142
+ - !ruby/object:Gem::Version
143
+ version: '2'
144
+ - !ruby/object:Gem::Dependency
145
+ name: coveralls
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 0.8.21
151
+ - - "<"
152
+ - !ruby/object:Gem::Version
153
+ version: '2'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 0.8.21
161
+ - - "<"
162
+ - !ruby/object:Gem::Version
163
+ version: '2'
164
+ description: String#replace_between method to find the index positon after a match
165
+ email: sixarm@sixarm.com
166
+ executables: []
167
+ extensions: []
168
+ extra_rdoc_files: []
169
+ files:
170
+ - Rakefile
171
+ - lib/sixarm_ruby_string_replace_between.rb
172
+ - lib/sixarm_ruby_string_replace_between/string/replace_between.rb
173
+ - test/sixarm_ruby_string_replace_between_test/string/replace_between_test.rb
174
+ homepage: http://sixarm.com/
175
+ licenses:
176
+ - Apache-2.0
177
+ - Artistic-2.0
178
+ - BSD-3-Clause
179
+ - CC-BY-NC-SA-4.0
180
+ - AGPL-3.0
181
+ - GPL-2.0
182
+ - GPL-3.0
183
+ - LGPL-3.0
184
+ - MIT
185
+ - MPL-2.0
186
+ - Ruby
187
+ metadata: {}
188
+ post_install_message:
189
+ rdoc_options: []
190
+ require_paths:
191
+ - lib
192
+ required_ruby_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ requirements: []
203
+ rubyforge_project:
204
+ rubygems_version: 2.7.3
205
+ signing_key:
206
+ specification_version: 4
207
+ summary: SixArm.com → Ruby → String#replace_between
208
+ test_files:
209
+ - test/sixarm_ruby_string_replace_between_test/string/replace_between_test.rb
@@ -0,0 +1,3 @@
1
+ ��� /��ԝ��z=I�
2
+ ��P@ ŀC�����\��)�Tn�B�̧H�u�/n G_�]
3
+ %�Y�����p5[�?4 @x%=���̑_QMNY����1�����|y�^N��a�3��vO{�T�j��vE`h�[��pwǩz`�ު�L�LI��'�:#�z�t��"�˘Ha�-rB؟�~��Wz�;L��-�̭Hم"է�OK���&���`���b�>��ݼ�2*(k��.�|�T`�y�