kagu 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/kagu/finder.rb +1 -1
- data/spec/kagu/finder_spec.rb +11 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11de437c9cd5363ca290c0ca520000cfe7bc1886
|
4
|
+
data.tar.gz: b14401606f398c291fcc913d320c219ce3e9a6d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5323f84e00b4fb489cca07373ba27cd7d8ee9453a5450d9370f7c9cc718768a458846b530d865e6c6d8d5eabb2c3329be22ccf96473814239ea383b9fb8b43e1
|
7
|
+
data.tar.gz: fa27da16fbc5fb658e8b5baf1b1d626d958eeefb714dcc4150cb5821eeddf6826462838aa9bff131d6c8d5349cd52b86231ed1fa346bd738629fb32c5e37a4ef
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/kagu/finder.rb
CHANGED
@@ -104,7 +104,7 @@ module Kagu
|
|
104
104
|
raise("Replacements must be an array or a hash, #{value.inspect} given")
|
105
105
|
end
|
106
106
|
replacements.each do |item|
|
107
|
-
raise('Replacements must contain only hashes') unless item.is_a?(Hash)
|
107
|
+
raise('Replacements must contain only hashes or arrays') unless item.is_a?(Hash) || item.is_a?(Array)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
data/spec/kagu/finder_spec.rb
CHANGED
@@ -23,6 +23,10 @@ describe Kagu::Finder do
|
|
23
23
|
expect(Kagu::Finder.replace(' ', 'world' => 'John', 'Hello' => 'Bye')).to be_nil
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'accepts arrays as replacements' do
|
27
|
+
expect(Kagu::Finder.replace('Hello World!', [['World', 'John'], ['Hello', 'Bye']])).to eq('Bye John!')
|
28
|
+
end
|
29
|
+
|
26
30
|
end
|
27
31
|
|
28
32
|
describe '.transliterate' do
|
@@ -244,7 +248,7 @@ describe Kagu::Finder do
|
|
244
248
|
end
|
245
249
|
|
246
250
|
it 'can be specified as regexp' do
|
247
|
-
expect(finder.reload(replacements: { /bar/ => 'foo' }).replacements).to eq(/bar/ => 'foo')
|
251
|
+
expect(finder.reload(replacements: { /bar/ => 'foo' }).replacements).to eq([/bar/ => 'foo'])
|
248
252
|
end
|
249
253
|
|
250
254
|
it 'can be specified with a string as key' do
|
@@ -259,16 +263,20 @@ describe Kagu::Finder do
|
|
259
263
|
expect(finder.reload(replacements: [{ 'foo' => 'bar' }, { 'titi' => 'toto' }]).replacements).to eq([{ 'foo' => 'bar' }, { 'titi' => 'toto' }])
|
260
264
|
end
|
261
265
|
|
266
|
+
it 'can be specified as array of array' do
|
267
|
+
expect(finder.reload(replacements: [['foo', 'bar' ], ['titi' => 'toto']]).replacements).to eq([['foo', 'bar' ], ['titi' => 'toto']])
|
268
|
+
end
|
269
|
+
|
262
270
|
it 'raise an error if a string is given' do
|
263
271
|
expect {
|
264
272
|
finder.reload(replacements: 'foo')
|
265
273
|
}.to raise_error('Replacements must be an array or a hash, "foo" given')
|
266
274
|
end
|
267
275
|
|
268
|
-
it 'raise an error if it contains something else than an hash' do
|
276
|
+
it 'raise an error if it contains something else than an hash or array' do
|
269
277
|
expect {
|
270
278
|
finder.reload(replacements: [{ 'foo' => 'bar' }, 'titi'])
|
271
|
-
}.to raise_error('Replacements must contain only hashes')
|
279
|
+
}.to raise_error('Replacements must contain only hashes or arrays')
|
272
280
|
end
|
273
281
|
|
274
282
|
end
|