kagu 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/kagu/finder.rb +6 -1
- data/spec/kagu/finder_spec.rb +16 -0
- 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: d4b993fe54c9f0a4e84e09bb7cdb9fc5e9b9e971
|
4
|
+
data.tar.gz: 9aeff1f243ef81c1e15b439c4b086279b96a9b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f9fbe51d2f9fe6f1c8af9afee40f48f3a79e61d4b0b8e59db10b359c32dc1c31964449ba24246115ff723c55f6db6850fe51b72cbe7b0a25c91bd566bf361b2
|
7
|
+
data.tar.gz: d98d4576bdada6675ec6daecaf7268d94778569fdedeb8d35b0718cb530051caa6254ece2566e34ff235058d78ea257acac3b722d3f69cd3880f1b99553fea04
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.5
|
data/lib/kagu/finder.rb
CHANGED
@@ -48,6 +48,10 @@ module Kagu
|
|
48
48
|
@ignored ||= []
|
49
49
|
end
|
50
50
|
|
51
|
+
def ignored?(track)
|
52
|
+
track.present? && digests(track).any? { |digest| ignored.include?(digest) }
|
53
|
+
end
|
54
|
+
|
51
55
|
def reload(options = {})
|
52
56
|
@ignored = nil
|
53
57
|
@replacements = nil
|
@@ -70,6 +74,7 @@ module Kagu
|
|
70
74
|
private
|
71
75
|
|
72
76
|
def digests(attributes)
|
77
|
+
attributes = { 'artist' => attributes.artist, 'title' => attributes.title } unless attributes.is_a?(Hash)
|
73
78
|
attributes.stringify_keys!
|
74
79
|
return [] if attributes['artist'].blank? || attributes['title'].blank?
|
75
80
|
digests = [transliterate("#{attributes['artist']} #{attributes['title']}")]
|
@@ -116,7 +121,7 @@ module Kagu
|
|
116
121
|
@tracks_digests ||= begin
|
117
122
|
[].tap do |tracks_digests|
|
118
123
|
tracks.each do |track|
|
119
|
-
digests = digests(
|
124
|
+
digests = digests(track)
|
120
125
|
next if digests.any? { |digest| ignored.include?(digest) }
|
121
126
|
digests.each_with_index do |digest, index|
|
122
127
|
tracks_digests[index] ||= {}
|
data/spec/kagu/finder_spec.rb
CHANGED
@@ -183,6 +183,22 @@ describe Kagu::Finder do
|
|
183
183
|
|
184
184
|
end
|
185
185
|
|
186
|
+
describe '#ignored?' do
|
187
|
+
|
188
|
+
it 'is false if nil is given' do
|
189
|
+
expect(finder.ignored?(nil)).to be(false)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'is true if at least one digest is ignored' do
|
193
|
+
finder.reload(replacements: { 'hello' => 'world' }, ignored: 'korn world')
|
194
|
+
expect(finder.ignored?(double(artist: 'korn', title: 'blind'))).to be(false)
|
195
|
+
expect(finder.ignored?(double(artist: 'korn', title: 'hello'))).to be(true)
|
196
|
+
expect(finder.ignored?(double(artist: 'korn', title: 'world'))).to be(true)
|
197
|
+
expect(finder.ignored?(double(artist: 'korn', title: 'hellow'))).to be(false)
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
186
202
|
describe '#library' do
|
187
203
|
|
188
204
|
it 'is library given at initialization' do
|