kagu 0.4.7 → 1.0.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: 89b8d0e5b1ab87c52760d75afa4d66fb53bcc39d
4
- data.tar.gz: af1df47c829a14d5286f99580d1b9269371a3b8f
3
+ metadata.gz: 1cc4fa20633a483023599a2d5db4d1cfa98dfa2d
4
+ data.tar.gz: ef1c98202b4db8848f137667241a8d2ff49565b5
5
5
  SHA512:
6
- metadata.gz: 59581f5968eacf605a7081387cb2579c856b1f4ea9a9f4ffbb6a70848485a370e5e909ceb54c52345fd71e177e747a1570051ba2f338a562cd833e8ceaa84619
7
- data.tar.gz: 462998c1286726105cb61d156b3348e896f01e6337471fa6183f4ab05545b846b632f368a021a8b7b1be234354e6990a0d455e7cd09e826fb7959a1408379236
6
+ metadata.gz: d9f773466e3c04f84c292bca74cf0277a15dbd3fca6cb197fea176dfbfd16743c16e4ce8fa22efc26a383e0ee82e2821243a86520df1dff6dca52cab54cbdfe4
7
+ data.tar.gz: 2b39cf4d9a94479848bb3e28a03d0537cbf4d94906fe391983dc59af961371364713ef17cde4a4f2fc2ad30e5b18a0ba1bc66c29426a00b19b2153c0685aa166
data/README.mdown CHANGED
@@ -52,6 +52,15 @@ library.finder.find(artist: 'Serial Killaz', title: 'Walk and Skank').each do
52
52
  end
53
53
  ```
54
54
 
55
+ ### Configuring logger
56
+
57
+ In order to have some debug informations about what kagu does, you could
58
+ configure its logger:
59
+
60
+ ```ruby
61
+ Kagu.logger = Logger.new(STDERR)
62
+ ```
63
+
55
64
  ## Executing test suite
56
65
 
57
66
  This project is fully tested with [Rspec 3](http://github.com/rspec/rspec).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.7
1
+ 1.0.0
data/lib/kagu/finder.rb CHANGED
@@ -114,7 +114,10 @@ module Kagu
114
114
  end
115
115
 
116
116
  def tracks
117
- @tracks ||= library.tracks.to_a
117
+ return @tracks if @tracks
118
+ (@tracks = library.tracks.to_a).tap do |tracks|
119
+ Kagu.logger.debug('Kagu') { "Loaded #{tracks.size} track(s) from iTunes library" }
120
+ end
118
121
  end
119
122
 
120
123
  def tracks_digests
data/lib/kagu/playlist.rb CHANGED
@@ -28,6 +28,7 @@ module Kagu
28
28
  private
29
29
 
30
30
  def add_tracks
31
+ Kagu.logger.info('Kagu') { "Adding #{tracks.size} track(s) to iTunes playlist #{name.inspect}" }
31
32
  tracks.map(&:id).each_slice(500) do |ids|
32
33
  AppleScript.execute(%Q{
33
34
  tell application "iTunes"
@@ -45,6 +46,7 @@ module Kagu
45
46
  end
46
47
 
47
48
  def clear
49
+ Kagu.logger.info('Kagu') { "Removing all tracks from iTunes playlist #{name.inspect}" }
48
50
  AppleScript.execute(%Q{
49
51
  tell application "iTunes"
50
52
  delete tracks of playlist #{name.inspect}
@@ -56,6 +58,7 @@ module Kagu
56
58
  end
57
59
 
58
60
  def create
61
+ Kagu.logger.info('Kagu') { "Creating iTunes playlist #{name.inspect}" }
59
62
  AppleScript.execute(%Q{
60
63
  tell application "iTunes"
61
64
  if not (exists user playlist #{name.inspect}) then
@@ -24,6 +24,7 @@ module Kagu
24
24
  tracks = {}.tap do |tracks|
25
25
  library.tracks.each { |track| tracks[track.id] = track }
26
26
  end
27
+ Kagu.logger.debug('Kagu') { "Reading iTunes library playlists from #{library.path.inspect}" }
27
28
  File.open(library.path, 'r') do |file|
28
29
  begin
29
30
  line = file.readline.strip
data/lib/kagu/tracks.rb CHANGED
@@ -15,6 +15,7 @@ module Kagu
15
15
 
16
16
  def each(&block)
17
17
  return unless block_given?
18
+ Kagu.logger.debug('Kagu') { "Loading iTunes library tracks from #{library.path.inspect}" }
18
19
  File.open(library.path, 'r') do |file|
19
20
  while !file.eof? && (line = file.readline.strip)
20
21
  next unless line.starts_with?('<key>Track ID</key>')
data/lib/kagu.rb CHANGED
@@ -3,9 +3,17 @@ require 'active_support/core_ext'
3
3
  require 'applescript'
4
4
  require 'byebug' if ENV['DEBUGGER']
5
5
  require 'htmlentities'
6
+ require 'logger'
6
7
 
7
8
  lib_path = "#{__dir__}/kagu"
8
9
 
10
+ module Kagu
11
+
12
+ mattr_accessor :logger
13
+ self.logger = Logger.new(nil)
14
+
15
+ end
16
+
9
17
  require "#{lib_path}/attributes_initializer"
10
18
  require "#{lib_path}/error"
11
19
  require "#{lib_path}/finder"
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.4.7
4
+ version: 1.0.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: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project: kagu
184
- rubygems_version: 2.5.1
184
+ rubygems_version: 2.5.2
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: API for iTunes