kagu 0.3.0 → 0.3.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: f9b5cf760c412efb5d62360c290a625dc55b272f
4
- data.tar.gz: 43467eddc6767a1fe8d475a66ecca2b592e28317
3
+ metadata.gz: 89fd743d29b031b192deea490bcacfbc0730167b
4
+ data.tar.gz: 2379f7c84f1fdf815df5c7422df27cae0580bd12
5
5
  SHA512:
6
- metadata.gz: 665ffd39957655f18c8f036826efbea3b91c30ef993b6f08b6c591f2c608efe3a9a26c1010327dc611e7394c5151a73bcadadb6a0c0a3756f936be212e23260d
7
- data.tar.gz: 642792a811a50a7d009b4ef9a9a2a19425768a4dac835336cad885c09a23b0345fb1ea2a33df04049e3362f1556ba5f3214a95dc26fa399bd8d27416278b3403
6
+ metadata.gz: 354178f44a50a2bee48f3fc1b7b1bbec5c6b5422798548798461cdc9c2ed2f2b64192ec0a3abd4e9013badae1c75066652e4a244410a7f3fdcad0401f37739bb
7
+ data.tar.gz: 4526542c6390261e41c8d7c08eb2bcb456c97e95a9c54eb6d7b8c13693b62eb6f5a2540b8ad7d2d67b5efb3532e8f5ac64e47eb5396e32f8100f6c9c037f67ef
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/lib/kagu/track.rb CHANGED
@@ -12,7 +12,7 @@ module Kagu
12
12
 
13
13
  def initialize(attributes = {})
14
14
  super
15
- raise Error.new("No such file: #{path.inspect}") unless File.file?(path)
15
+ raise Error.new("No such file: #{path.inspect}") if File.exists?(path) && !exists?
16
16
  end
17
17
 
18
18
  def <=>(other)
@@ -28,6 +28,10 @@ module Kagu
28
28
  super || self == other
29
29
  end
30
30
 
31
+ def exists?
32
+ File.file?(path)
33
+ end
34
+
31
35
  def relative_path(directory)
32
36
  directory.present? && directory.starts_with?(directory) ? path.gsub(/\A#{Regexp.escape(directory)}\//, '') : path
33
37
  end
@@ -123,6 +123,22 @@ describe Kagu::Track do
123
123
 
124
124
  end
125
125
 
126
+ describe '#exists?' do
127
+
128
+ it 'is true if path is a file' do
129
+ expect {
130
+ allow(track).to receive(:path).and_return('/tmp/foo.mp3')
131
+ }.to change { track.exists? }.from(true).to(false)
132
+ end
133
+
134
+ it 'is false if path is a directory' do
135
+ expect {
136
+ allow(track).to receive(:path).and_return('/tmp')
137
+ }.to change { track.exists? }.from(true).to(false)
138
+ end
139
+
140
+ end
141
+
126
142
  describe '#genre' do
127
143
 
128
144
  it 'is correct' do
@@ -185,10 +201,10 @@ describe Kagu::Track do
185
201
  }.to raise_error(Kagu::Error, 'Kagu::Track#path is mandatory')
186
202
  end
187
203
 
188
- it 'raise an error if not found' do
204
+ it 'does not raise an error if not found' do
189
205
  expect {
190
206
  Kagu::Track.new(attributes.merge(path: '/tmp/bar.mp3'))
191
- }.to raise_error(Kagu::Error, 'No such file: "/tmp/bar.mp3"')
207
+ }.not_to raise_error
192
208
  end
193
209
 
194
210
  it 'raise an error if not a file' do
@@ -16,6 +16,7 @@ describe Kagu::Tracks do
16
16
  expect(track.album).to be_present
17
17
  expect(track.artist).to be_a(String)
18
18
  expect(track.artist).to be_present
19
+ expect(track.exists?).to be(true)
19
20
  expect(track.genre).to be_a(String)
20
21
  expect(track.genre).to be_present
21
22
  expect(track.id).to be_an(Integer)
@@ -42,7 +43,7 @@ describe Kagu::Tracks do
42
43
  it 'all tracks must exists and path should not include UTF-8-MAC charset' do
43
44
  library.tracks.each do |track|
44
45
  expect(track.path).not_to include("\u{65}\u{301}")
45
- expect(File.file?(track.path)).to be(true)
46
+ expect(track.exists?).to be(true)
46
47
  end
47
48
  end
48
49
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kagu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport