kagu 3.0.6 → 3.1.0
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/attributes_initializer.rb +1 -1
- data/lib/kagu/playlists.rb +3 -2
- data/lib/kagu/swift_helper.rb +2 -7
- data/lib/kagu/track.rb +8 -14
- data/lib/kagu/tracks.rb +2 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5358df20144489a5d2c8a49fec5716a2078046631b9c43e52b6ecf3265cec875
|
4
|
+
data.tar.gz: 6cce3b0f9f8c8d32bfdd6eeb0615a0cfc6402201c0f977db4ee2007fc0b4a761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd8f9d7221dde8a0fb25ab993e4dd97cc127fa003ee385ed7133dccee2f6ec84ccd2a93e60aac15dc2d79ee8f044a3c11bbcca7914a4a0e245a9ae278f75cec
|
7
|
+
data.tar.gz: c1f3fbfb7413b0aa9de63931f6a71fcaf454e47bfd918dd12c74cfbad2df03033c499d6754fae82f32025ed9d60ed69878421cc6d53e54a837f1cdb29dc55481
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.1.0
|
@@ -7,7 +7,7 @@ module Kagu
|
|
7
7
|
send("#{name}=", value) if respond_to?("#{name}=", true)
|
8
8
|
end
|
9
9
|
self.class.const_get(:MANDATORY_ATTRIBUTES).each do |attribute|
|
10
|
-
raise Error.new("#{self.class}##{attribute} is mandatory") if send(attribute).nil?
|
10
|
+
raise Error.new("#{self.class}##{attribute} is mandatory for #{inspect}") if send(attribute).nil?
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
data/lib/kagu/playlists.rb
CHANGED
@@ -28,11 +28,11 @@ module Kagu
|
|
28
28
|
print("BEGIN_PLAYLIST")
|
29
29
|
print(playlist.name)
|
30
30
|
for track in playlist.items.filter({ $0.mediaKind == ITLibMediaItemMediaKind.kindSong }) {
|
31
|
-
print(String(
|
31
|
+
print(String(track.persistentID.uint64Value, radix: 16).uppercased())
|
32
32
|
}
|
33
33
|
print("END_PLAYLIST")
|
34
34
|
}
|
35
|
-
}) do |line|
|
35
|
+
}).each do |line|
|
36
36
|
if line == 'BEGIN_PLAYLIST'
|
37
37
|
playlist_name = nil
|
38
38
|
playlist_tracks = []
|
@@ -44,6 +44,7 @@ module Kagu
|
|
44
44
|
playlist_tracks << tracks[line]
|
45
45
|
end
|
46
46
|
end
|
47
|
+
nil
|
47
48
|
end
|
48
49
|
|
49
50
|
end
|
data/lib/kagu/swift_helper.rb
CHANGED
@@ -2,7 +2,7 @@ module Kagu
|
|
2
2
|
|
3
3
|
module SwiftHelper
|
4
4
|
|
5
|
-
def self.execute(code
|
5
|
+
def self.execute(code)
|
6
6
|
tempfile = Tempfile.new
|
7
7
|
begin
|
8
8
|
tempfile << code
|
@@ -12,12 +12,7 @@ module Kagu
|
|
12
12
|
begin
|
13
13
|
stdout, stderr, result = Open3.capture3("swift #{tempfile.path.inspect}")
|
14
14
|
raise(stderr.presence || "Swift command returned with code: #{result.exitstatus}") unless result.success?
|
15
|
-
|
16
|
-
stdout.lines.each { |line| yield(line.chomp) }
|
17
|
-
nil
|
18
|
-
else
|
19
|
-
stdout
|
20
|
-
end
|
15
|
+
stdout.lines.map(&:chomp)
|
21
16
|
ensure
|
22
17
|
tempfile.unlink
|
23
18
|
end
|
data/lib/kagu/track.rb
CHANGED
@@ -5,7 +5,7 @@ module Kagu
|
|
5
5
|
include AttributesInitializer
|
6
6
|
include Comparable
|
7
7
|
|
8
|
-
MANDATORY_ATTRIBUTES = %w(added_at id length
|
8
|
+
MANDATORY_ATTRIBUTES = %w(added_at id length)
|
9
9
|
|
10
10
|
attr_reader :added_at, :album, :artist, :bpm, :genre, :id, :length, :path, :title, :year
|
11
11
|
|
@@ -22,19 +22,14 @@ module Kagu
|
|
22
22
|
super || self == other
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
path.file?
|
25
|
+
def exists_on_disk?
|
26
|
+
path.present? && path.file?
|
27
27
|
end
|
28
28
|
|
29
29
|
def hash
|
30
30
|
[artist, title].hash
|
31
31
|
end
|
32
32
|
|
33
|
-
def relative_path(directory)
|
34
|
-
directory = directory.to_s
|
35
|
-
directory.present? ? Pathname.new(path.to_s.gsub(/\A#{Regexp.escape(directory)}\//, '')) : path
|
36
|
-
end
|
37
|
-
|
38
33
|
def to_s
|
39
34
|
"#{artist} - #{title}"
|
40
35
|
end
|
@@ -59,7 +54,8 @@ module Kagu
|
|
59
54
|
end
|
60
55
|
|
61
56
|
def bpm=(value)
|
62
|
-
|
57
|
+
value = value.to_s =~ /\A[0-9]+\z/ ? value.to_i : nil
|
58
|
+
@bpm = (value && value > 0) ? value : nil
|
63
59
|
end
|
64
60
|
|
65
61
|
def genre=(value)
|
@@ -76,11 +72,9 @@ module Kagu
|
|
76
72
|
|
77
73
|
def path=(value)
|
78
74
|
value = value.to_s.presence
|
79
|
-
value = URI.unescape(URI.parse(value).path) if value.is_a?(String) && value.starts_with?('file://')
|
80
|
-
value = value.encode('UTF-8', 'UTF-8-MAC') if Kagu::IS_MAC_OS
|
81
|
-
@path = Pathname.new(value)
|
82
|
-
raise Error.new("No such file: #{path.to_s.inspect}") if path.exist? && !exists?
|
83
|
-
Kagu.logger.error('Kagu') { "No such track: #{path.inspect}" } unless exists?
|
75
|
+
value = URI.unescape(URI.parse(value).path).presence if value.is_a?(String) && value.starts_with?('file://')
|
76
|
+
value = value.encode('UTF-8', 'UTF-8-MAC') if value.present? && Kagu::IS_MAC_OS
|
77
|
+
@path = value.present? ? Pathname.new(value) : nil
|
84
78
|
end
|
85
79
|
|
86
80
|
def title=(value)
|
data/lib/kagu/tracks.rb
CHANGED
@@ -35,7 +35,7 @@ module Kagu
|
|
35
35
|
printObjectProperty(name: "year", value: track.year)
|
36
36
|
print("END_TRACK")
|
37
37
|
}
|
38
|
-
}) do |line|
|
38
|
+
}).each do |line|
|
39
39
|
if line == 'BEGIN_TRACK'
|
40
40
|
attributes = {}
|
41
41
|
elsif line == 'END_TRACK'
|
@@ -44,6 +44,7 @@ module Kagu
|
|
44
44
|
attributes[match[1]] = JSON.parse(match[2])
|
45
45
|
end
|
46
46
|
end
|
47
|
+
nil
|
47
48
|
end
|
48
49
|
|
49
50
|
end
|
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Toulotte
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,7 +134,7 @@ homepage: https://github.com/alexistoulotte/kagu
|
|
134
134
|
licenses:
|
135
135
|
- MIT
|
136
136
|
metadata: {}
|
137
|
-
post_install_message:
|
137
|
+
post_install_message:
|
138
138
|
rdoc_options: []
|
139
139
|
require_paths:
|
140
140
|
- lib
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
152
|
rubygems_version: 3.0.3
|
153
|
-
signing_key:
|
153
|
+
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: API for macOS Music
|
156
156
|
test_files: []
|