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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c64b2bce11df1db7eef71c7aa0a3de60c0e6246f
4
- data.tar.gz: 004ebcd692535602f6ec4a16d0775f8ef2d18ba3
3
+ metadata.gz: d4b993fe54c9f0a4e84e09bb7cdb9fc5e9b9e971
4
+ data.tar.gz: 9aeff1f243ef81c1e15b439c4b086279b96a9b17
5
5
  SHA512:
6
- metadata.gz: 2dca79d485bd293043ce57b9e39babe9a5d86c8ee470f25640c8c2ad8ccf4e4129b05b3ca01adf8443955dfad2a207518dbeacf06bbcdab7b0e57f484f2ce8df
7
- data.tar.gz: 485d551b04e5d8793ab28db422a2713f02dd578ab48e455cec64d73517d6e2f7d2a32567acceffdf2ef8445068f55fece8eae1cccdc17e66e2f31be384034924
6
+ metadata.gz: 3f9fbe51d2f9fe6f1c8af9afee40f48f3a79e61d4b0b8e59db10b359c32dc1c31964449ba24246115ff723c55f6db6850fe51b72cbe7b0a25c91bd566bf361b2
7
+ data.tar.gz: d98d4576bdada6675ec6daecaf7268d94778569fdedeb8d35b0718cb530051caa6254ece2566e34ff235058d78ea257acac3b722d3f69cd3880f1b99553fea04
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.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(artist: track.artist, title: track.title)
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] ||= {}
@@ -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
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.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte