kagu 0.4.1 → 0.4.2

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: cae3122292d1e1b8124cfca0f906ded001e79672
4
- data.tar.gz: ecff70776c0412b2ff50bc9fe3a08af35b121931
3
+ metadata.gz: 11de437c9cd5363ca290c0ca520000cfe7bc1886
4
+ data.tar.gz: b14401606f398c291fcc913d320c219ce3e9a6d0
5
5
  SHA512:
6
- metadata.gz: 2b28616ef357f90bfccc6552ae4a07078ee4f639c5d331d8d471c7cca2f59177cc6ac2f7502f204728d7a7bdaeab39ef0a517e62bcc11e31e334306400557aec
7
- data.tar.gz: 2a9b9c2c46a8d590cc74f65f31ca49868dbeb132088322c1f3fedceff691342a15b9a80710a2fc550f06d2f637ead1bfa60718be864a428d6e8b70742da1517b
6
+ metadata.gz: 5323f84e00b4fb489cca07373ba27cd7d8ee9453a5450d9370f7c9cc718768a458846b530d865e6c6d8d5eabb2c3329be22ccf96473814239ea383b9fb8b43e1
7
+ data.tar.gz: fa27da16fbc5fb658e8b5baf1b1d626d958eeefb714dcc4150cb5821eeddf6826462838aa9bff131d6c8d5349cd52b86231ed1fa346bd738629fb32c5e37a4ef
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -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
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kagu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte