kagu 0.4.0 → 0.4.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: dc8ff8418f368b1c12f3d2f8b01d6af8e7d7a3a6
4
- data.tar.gz: e7be4e6197998c38421f7208d0c84a898c83b6e9
3
+ metadata.gz: cae3122292d1e1b8124cfca0f906ded001e79672
4
+ data.tar.gz: ecff70776c0412b2ff50bc9fe3a08af35b121931
5
5
  SHA512:
6
- metadata.gz: c7a69aeed895d34f70b4cda33304f48cd284a81105b79d772c7c1e3e1fe3d472110aad768241edbe2c651486f494d851e7380d60cc5b7c70ad2e9ecabfbc8bdb
7
- data.tar.gz: eb07e916b94813b67ed2872bc94897bacaf06873b25df46b71bdeddebcca8c586dc22d335833d71222e5c7b0678e375cd0dc445334ff8690a563965fe3479def
6
+ metadata.gz: 2b28616ef357f90bfccc6552ae4a07078ee4f639c5d331d8d471c7cca2f59177cc6ac2f7502f204728d7a7bdaeab39ef0a517e62bcc11e31e334306400557aec
7
+ data.tar.gz: 2a9b9c2c46a8d590cc74f65f31ca49868dbeb132088322c1f3fedceff691342a15b9a80710a2fc550f06d2f637ead1bfa60718be864a428d6e8b70742da1517b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/lib/kagu/finder.rb CHANGED
@@ -58,6 +58,11 @@ module Kagu
58
58
  self
59
59
  end
60
60
 
61
+ def reload!(options = {})
62
+ @tracks = nil
63
+ reload(options)
64
+ end
65
+
61
66
  def replacements
62
67
  @replacements ||= []
63
68
  end
@@ -103,10 +108,14 @@ module Kagu
103
108
  end
104
109
  end
105
110
 
111
+ def tracks
112
+ @tracks ||= library.tracks.to_a
113
+ end
114
+
106
115
  def tracks_digests
107
116
  @tracks_digests ||= begin
108
117
  [].tap do |tracks_digests|
109
- library.tracks.each do |track|
118
+ tracks.each do |track|
110
119
  digests(artist: track.artist, title: track.title).each_with_index do |digest, index|
111
120
  next if ignored.include?(digest)
112
121
  tracks_digests[index] ||= {}
@@ -110,6 +110,13 @@ describe Kagu::Finder do
110
110
  expect(finder.find(artist: 'korn', title: 'ball tongue')).not_to be_empty
111
111
  end
112
112
 
113
+ it 'finds for some tracks with replacements as regexp' do
114
+ finder.reload(replacements: { /subsonik (\d+)/ => "subsonik podcast \\1" })
115
+ results = finder.find(artist: 'subsonik', title: '002')
116
+ expect(results.size).to eq(1)
117
+ expect(results.first.first.title).to match(/podcast 002/i)
118
+ end
119
+
113
120
  end
114
121
 
115
122
  describe '#ignored' do
@@ -204,6 +211,30 @@ describe Kagu::Finder do
204
211
  }.to change { finder.find(artist: 'korn', title: 'adidas').present? }.from(false).to(true)
205
212
  end
206
213
 
214
+ it 'returns finder' do
215
+ expect(finder.reload).to be(finder)
216
+ end
217
+
218
+ end
219
+
220
+ describe '#reload!' do
221
+
222
+ it 'invokes reload' do
223
+ expect(finder).to receive(:reload).with('foo' => 'bar')
224
+ finder.reload!('foo' => 'bar')
225
+ end
226
+
227
+ it 'removes tracks cache' do
228
+ finder.find(artist: 'korn', title: 'blind')
229
+ expect {
230
+ finder.reload!
231
+ }.to change { finder.instance_variable_get(:@tracks) }.to(nil)
232
+ end
233
+
234
+ it 'returns finder' do
235
+ expect(finder.reload!).to be(finder)
236
+ end
237
+
207
238
  end
208
239
 
209
240
  describe '#replacements' do
@@ -212,6 +243,10 @@ describe Kagu::Finder do
212
243
  expect(finder.reload.replacements).to eq([])
213
244
  end
214
245
 
246
+ it 'can be specified as regexp' do
247
+ expect(finder.reload(replacements: { /bar/ => 'foo' }).replacements).to eq(/bar/ => 'foo')
248
+ end
249
+
215
250
  it 'can be specified with a string as key' do
216
251
  expect(finder.reload('replacements' => { 'foo' => 'bar' }).replacements).to eq([{ 'foo' => 'bar' }])
217
252
  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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte