kagu 0.2.4 → 0.3.0

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: 8abf34d5d6f0a29f343b0c69bacb3c9787e74d7c
4
- data.tar.gz: 2455ade67d9bb0743c7c9dbceac47aae2f070e57
3
+ metadata.gz: f9b5cf760c412efb5d62360c290a625dc55b272f
4
+ data.tar.gz: 43467eddc6767a1fe8d475a66ecca2b592e28317
5
5
  SHA512:
6
- metadata.gz: 32627c692f97355c767f5c90696729703e4f18d81a1bc6c7e3d5f68496babf51dafe957be3a8d9a5cb79996b0c4adaf4119cd570968507e84cdd2bc5a5cd95be
7
- data.tar.gz: 3de217af25a4f43e343a78b58db6eda4c09a6deefa7c60a08a9cb0a857578b042340a7ddd1010dc64cc37c7be6556c831ed9375a4108a77bc77fae1b63c152eb
6
+ metadata.gz: 665ffd39957655f18c8f036826efbea3b91c30ef993b6f08b6c591f2c608efe3a9a26c1010327dc611e7394c5151a73bcadadb6a0c0a3756f936be212e23260d
7
+ data.tar.gz: 642792a811a50a7d009b4ef9a9a2a19425768a4dac835336cad885c09a23b0345fb1ea2a33df04049e3362f1556ba5f3214a95dc26fa399bd8d27416278b3403
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
data/kagu.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'applescript', '>= 1.0', '< 2.0'
21
21
  s.add_dependency 'htmlentities', '>= 4.3.0', '< 4.4.0'
22
22
 
23
- s.add_development_dependency 'byebug', '>= 3.2.0', '< 3.5.0'
23
+ s.add_development_dependency 'byebug', '>= 3.2.0', '< 3.6.0'
24
24
  s.add_development_dependency 'rake', '>= 10.3.0', '< 10.4.0'
25
25
  s.add_development_dependency 'rspec', '>= 3.1.0', '< 3.2.0'
26
26
  end
data/lib/kagu/track.rb CHANGED
@@ -8,7 +8,7 @@ module Kagu
8
8
  MANDATORY_ATTRIBUTES = %w(added_at id length path)
9
9
  IS_MAC_OS = RUBY_PLATFORM =~ /darwin/
10
10
 
11
- attr_reader :added_at, :album, :artist, :genre, :id, :length, :path, :title
11
+ attr_reader :added_at, :album, :artist, :genre, :id, :length, :path, :title, :year
12
12
 
13
13
  def initialize(attributes = {})
14
14
  super
@@ -80,7 +80,7 @@ module Kagu
80
80
  end
81
81
 
82
82
  def itunes_location=(value)
83
- self.path = CGI.unescape(html_entities_decode(value).gsub('+', '%2B')).gsub(/\Afile:\/\/localhost/, '')
83
+ self.path = CGI.unescape(html_entities_decode(value).gsub('+', '%2B')).gsub(/\Afile:\/\/(localhost)?/, '')
84
84
  self.path = path.encode('UTF-8', 'UTF-8-MAC') if IS_MAC_OS
85
85
  end
86
86
 
@@ -96,6 +96,10 @@ module Kagu
96
96
  self.id = value
97
97
  end
98
98
 
99
+ def itunes_year=(value)
100
+ self.year = value
101
+ end
102
+
99
103
  def length=(value)
100
104
  @length = value.to_s =~ /\A[0-9]+\z/ ? value.to_i : nil
101
105
  end
@@ -108,6 +112,10 @@ module Kagu
108
112
  @title = value.to_s.squish.presence
109
113
  end
110
114
 
115
+ def year=(value)
116
+ @year = value.to_s =~ /\A\d{,4}\z/ ? value.to_i : nil
117
+ end
118
+
111
119
  end
112
120
 
113
121
  end
@@ -40,13 +40,6 @@ describe Kagu::Library do
40
40
  expect(library.tracks.library).to be(library)
41
41
  end
42
42
 
43
- it 'path must exists and not include UTF-8-MAC charset' do
44
- library.tracks.each do |track|
45
- expect(track.path).not_to include("\u{65}\u{301}")
46
- expect(File.file?(track.path)).to be(true)
47
- end
48
- end
49
-
50
43
  end
51
44
 
52
45
  end
@@ -228,4 +228,41 @@ describe Kagu::Track do
228
228
 
229
229
  end
230
230
 
231
+ describe '#year' do
232
+
233
+ it 'is an integer' do
234
+ expect(track.year).to be_an(Integer)
235
+ end
236
+
237
+ it 'is correct' do
238
+ expect(track.year.to_s).to match(/\A\d{4}\z/)
239
+ end
240
+
241
+ it 'is nil if negative' do
242
+ track.send(:year=, -1)
243
+ expect(track.year).to be_nil
244
+ end
245
+
246
+ it 'is nil if invalid' do
247
+ track.send(:year=, 20434)
248
+ expect(track.year).to be_nil
249
+ end
250
+
251
+ it 'can be < 1000' do
252
+ track.send(:year=, 942)
253
+ expect(track.year).to be(942)
254
+ end
255
+
256
+ it 'can be set as string' do
257
+ track.send(:year=, '1984')
258
+ expect(track.year).to be(1984)
259
+ end
260
+
261
+ it 'is nil if string is invalid' do
262
+ track.send(:year=, '1984 ')
263
+ expect(track.year).to be_nil
264
+ end
265
+
266
+ end
267
+
231
268
  end
@@ -24,6 +24,8 @@ describe Kagu::Tracks do
24
24
  expect(track.path).to include('Music')
25
25
  expect(track.title).to be_a(String)
26
26
  expect(track.title).to be_present
27
+ expect(track.year).to be_an(Integer)
28
+ expect(track.year.to_s).to match(/\A\d{4}\z/)
27
29
  end
28
30
  end
29
31
 
@@ -37,6 +39,13 @@ describe Kagu::Tracks do
37
39
  expect(tracks.each {}).to be_nil
38
40
  end
39
41
 
42
+ it 'all tracks must exists and path should not include UTF-8-MAC charset' do
43
+ library.tracks.each do |track|
44
+ expect(track.path).not_to include("\u{65}\u{301}")
45
+ expect(File.file?(track.path)).to be(true)
46
+ end
47
+ end
48
+
40
49
  end
41
50
 
42
51
  describe '#library' do
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.2.4
4
+ version: 0.3.0
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-09-20 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -79,7 +79,7 @@ dependencies:
79
79
  version: 3.2.0
80
80
  - - "<"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.5.0
82
+ version: 3.6.0
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: 3.2.0
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
- version: 3.5.0
92
+ version: 3.6.0
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rake
95
95
  requirement: !ruby/object:Gem::Requirement