kagu 3.0.5 → 3.0.10

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
  SHA256:
3
- metadata.gz: f42802bc51d1c4527070117392111e06dc86a5a076abdafbb323a57b81d3e4e0
4
- data.tar.gz: 7f095724080e80aa06d323bfdfc6ad7bb562e3f671ce14c26d8e985bd64c888f
3
+ metadata.gz: 9edb39356c4523c2f2682c519ad5557d91cdc20107ca3022d0222be2fd66f9bb
4
+ data.tar.gz: d35d8c4c55f71acc49d89a904a6cc43186d561988b0669ba6a751452ef339603
5
5
  SHA512:
6
- metadata.gz: 2f64f022b5b4562ab006346d4171c363b5c84c0494d8f4002cf2ff222d8e4526f7f30de48de5087a7eabc96db84760997ae33c446c84e3f5fea7d2d26729790a
7
- data.tar.gz: 3c44ac6690a8ea947b0a2a77c76167fd1e0200a64ffc28850c22d85fa33ff85b0388127ebda179304ef3da8d76f97edcbf281fd4fcd9c92566c3e69f9d4da436
6
+ metadata.gz: a6368d27b74e8d21b14ade2233c91a63be38e6013415eda29b1ae0ddb4f2715316e7a392bf6bbf128ddbcd27e130ed387f280f75d26d6ea520942d99713d3ebc
7
+ data.tar.gz: ba74cc6b7117ee7f50517b625f0bbcffa2b20169e4baae4b21c4a8f36663b7ecd8d5158aaa5bcbeca84e321e77869e3f155bbcd78269a62ad900403b1cac90f1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.5
1
+ 3.0.10
@@ -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
 
@@ -34,7 +34,7 @@ module Kagu
34
34
  AppleScript.execute(%Q{
35
35
  tell application #{Kagu::OSX_APP_NAME.inspect}
36
36
  set playlistToPush to user playlist #{name.inspect}
37
- set idsToAdd to {#{ids.join(',')}}
37
+ set idsToAdd to {#{ids.map(&:inspect).join(',')}}
38
38
  repeat with idToAdd in idsToAdd
39
39
  duplicate (tracks of library playlist 1 whose persistent ID is idToAdd) to playlistToPush
40
40
  end repeat
@@ -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(format: "%02X", track.persistentID.intValue))
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
@@ -2,7 +2,7 @@ module Kagu
2
2
 
3
3
  module SwiftHelper
4
4
 
5
- def self.execute(code, &block)
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
- if block_given?
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
@@ -5,7 +5,7 @@ module Kagu
5
5
  include AttributesInitializer
6
6
  include Comparable
7
7
 
8
- MANDATORY_ATTRIBUTES = %w(added_at id length path)
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,8 +22,8 @@ module Kagu
22
22
  super || self == other
23
23
  end
24
24
 
25
- def exists?
26
- path.file?
25
+ def exists_on_disk?
26
+ path.present? && path.file?
27
27
  end
28
28
 
29
29
  def hash
@@ -31,6 +31,7 @@ module Kagu
31
31
  end
32
32
 
33
33
  def relative_path(directory)
34
+ return nil if path.blank?
34
35
  directory = directory.to_s
35
36
  directory.present? ? Pathname.new(path.to_s.gsub(/\A#{Regexp.escape(directory)}\//, '')) : path
36
37
  end
@@ -59,7 +60,8 @@ module Kagu
59
60
  end
60
61
 
61
62
  def bpm=(value)
62
- @bpm = value.to_s =~ /\A[0-9]+\z/ ? value.to_i : nil
63
+ value = value.to_s =~ /\A[0-9]+\z/ ? value.to_i : nil
64
+ @bpm = (value && value > 0) ? value : nil
63
65
  end
64
66
 
65
67
  def genre=(value)
@@ -76,11 +78,9 @@ module Kagu
76
78
 
77
79
  def path=(value)
78
80
  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?
81
+ value = URI.unescape(URI.parse(value).path).presence if value.is_a?(String) && value.starts_with?('file://')
82
+ value = value.encode('UTF-8', 'UTF-8-MAC') if value.present? && Kagu::IS_MAC_OS
83
+ @path = value.present? ? Pathname.new(value) : nil
84
84
  end
85
85
 
86
86
  def title=(value)
@@ -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.5
4
+ version: 3.0.10
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: 2019-12-06 00:00:00.000000000 Z
11
+ date: 2020-09-30 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: []