cmus 2.0.4.5 → 2.0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,14 +95,12 @@ if options[:status]
95
95
  controller.status.tap {|status|
96
96
  puts "status #{status.to_sym}"
97
97
  puts "file #{status.path}" if status.path
98
- puts "duration #{status.duration}" if status.duration
99
- puts "position #{status.position}" if status.position
100
-
101
- if status.song
102
- status.song.marshal_dump.each {|name, value|
103
- puts "tag #{name} #{value}"
104
- }
105
- end
98
+ puts "duration #{status.song.duration}" if status.song.duration
99
+ puts "position #{status.song.position}" if status.song.position
100
+
101
+ status.song.tags.marshal_dump.each {|name, value|
102
+ puts "tag #{name} #{value}"
103
+ }
106
104
 
107
105
  status.settings.marshal_dump.each {|name, value|
108
106
  puts "set #{name} #{value}"
@@ -13,37 +13,60 @@ require 'ostruct'
13
13
  module Cmus; class Controller
14
14
 
15
15
  class Status
16
- attr_reader :controller, :path, :duration, :position, :song, :settings
16
+ class Song
17
+ attr_reader :controller, :tags
18
+ attr_accessor :file, :position, :duration
19
+
20
+ def initialize (controller)
21
+ @tags = OpenStruct.new
22
+ end
23
+
24
+ %w[title artist album].each {|name|
25
+ define_method name do
26
+ tags.__send__ name
27
+ end
28
+ }
29
+
30
+ def track
31
+ tags.tracknumber
32
+ end
33
+ end
34
+
35
+ attr_reader :controller, :song, :settings
17
36
 
18
37
  def initialize (controller)
19
38
  @controller = controller
20
39
 
21
- @song = OpenStruct.new
40
+ @song = Song.new(controller)
22
41
  @settings = OpenStruct.new
23
42
 
24
43
  controller.send 'status'
25
- controller.wait_for_data.buffer.each_line {|line|
44
+ controller.wait_for_data.each_line {|line|
26
45
  type, data = line.chomp.split ' ', 2
27
46
 
28
47
  next unless type
29
48
 
30
49
  case type.to_sym
31
50
  when :status
32
- @status = data.to_sym
51
+ @status = case data.to_sym
52
+ when :stopped then :STOP
53
+ when :paused then :PAUSE
54
+ else :PLAY
55
+ end
33
56
 
34
57
  when :file
35
- @path = data
58
+ @song.file = data
36
59
 
37
60
  when :duration
38
- @duration = data.to_i
61
+ @song.duration = data.to_i
39
62
 
40
63
  when :position
41
- @position = data.to_i
64
+ @song.position = data.to_i
42
65
 
43
66
  when :tag
44
67
  name, data = data.split ' ', 2
45
68
 
46
- @song.send "#{name}=", data
69
+ @song.tags.send "#{name}=", data
47
70
 
48
71
  when :set
49
72
  name, data = data.split ' ', 2
@@ -64,9 +87,7 @@ class Status
64
87
  end
65
88
  }
66
89
 
67
- if @song.marshal_dump.empty?
68
- @song = nil
69
- end
90
+ @song = nil if self == :stop
70
91
  end
71
92
 
72
93
  def volume
@@ -74,7 +95,7 @@ class Status
74
95
  end
75
96
 
76
97
  def == (other)
77
- super || to_sym == other
98
+ super || to_sym.downcase == other.to_sym.downcase
78
99
  end
79
100
 
80
101
  def to_sym
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Cmus
12
12
  def self.version
13
- '2.0.4.5'
13
+ '2.0.4.6'
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4.5
4
+ version: 2.0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: meh@paranoici.org