itunes-client 0.1.1 → 0.1.2

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: 8f1c91e02d16364127d719091b1ed109ae00d905
4
- data.tar.gz: f063ff6d206acc2795795c7f30cf768d16c39d94
3
+ metadata.gz: 7b23fc7101437304af9f40938b9c1ffd1a8c1200
4
+ data.tar.gz: f87f2609ef6ae98a19c0ff27ccbf58d9930f5f5b
5
5
  SHA512:
6
- metadata.gz: b614bc34af5c7adca7cd1e7afd6d2d836c85260a825d287bfe410e109ffb70714ba91f68c20947f204b318ab40e1fc7bdb2e0f6b9dd1a0c02dfe0d4d44eeeb89
7
- data.tar.gz: 0d255ef6391c425c76e1aa3d168ec677896affffb4e9f7b1261f386a41f05cb03cffc3bcd3ab344bafd23dab639356293802ad06eebeca6a0284651235e89f7f
6
+ metadata.gz: 5bc6e7a8e429d395d8bd3f1b4a633f0f33d0bc316b268bfe82219d0bd979adfb75542a7c59372e22d328a921b1d59903fc566c57d9e783f1014de0775c021d1b
7
+ data.tar.gz: e409d720b89d34548c6c24039530357ecd45725aa5fa98902f6c0b1211274509203a473177f86ee63edc6fe58db5a8ec8eb7dccc91182d6bd0b269201c81a0b7
@@ -51,6 +51,11 @@ module Itunes
51
51
  Track.find_by(persistent_id: persistent_id).first
52
52
  end
53
53
 
54
+ def current_track
55
+ persistent_id = execute_script("#{script_dir}/current_track.scpt")
56
+ Track.find_by(persistent_id: persistent_id).first
57
+ end
58
+
54
59
  private
55
60
  def script_dir
56
61
  'player'
@@ -88,11 +88,6 @@ module Itunes
88
88
  end
89
89
  end
90
90
 
91
- def self.current_track
92
- persistent_id = execute_script('track/current_track.scpt')
93
- Track.find_by(persistent_id: persistent_id).first
94
- end
95
-
96
91
  def self.find_conditions(args)
97
92
  conditions = []
98
93
  args.each do |key, val|
@@ -1,3 +1,3 @@
1
1
  module Itunes
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -5,16 +5,14 @@ require 'itunes-client'
5
5
  include Itunes
6
6
 
7
7
  describe Player do
8
- let(:player) { Itunes::Player }
9
-
10
8
  describe '.add' do
11
- subject(:add) { player.add(file_name) }
9
+ subject(:add) { Player.add(file_name) }
12
10
 
13
11
  let(:file_name) { 'foo.wav' }
14
12
  let(:new_persistent_id) { 'foo' }
15
13
 
16
14
  before do
17
- player.should_receive(:execute_script).
15
+ Player.should_receive(:execute_script).
18
16
  with('player/add.scpt', file_name).and_return(new_persistent_id)
19
17
  Track.should_receive(:find_by).
20
18
  with(persistent_id: new_persistent_id).
@@ -29,67 +27,67 @@ describe Player do
29
27
 
30
28
  describe '.pause' do
31
29
  it 'calls pause.scpt' do
32
- player.should_receive(:execute_script).with('player/pause.scpt')
33
- player.pause
30
+ Player.should_receive(:execute_script).with('player/pause.scpt')
31
+ Player.pause
34
32
  end
35
33
  end
36
34
 
37
35
  describe '.stop' do
38
36
  it 'calls stop.scpt' do
39
- player.should_receive(:execute_script).with('player/stop.scpt')
40
- player.stop
37
+ Player.should_receive(:execute_script).with('player/stop.scpt')
38
+ Player.stop
41
39
  end
42
40
  end
43
41
 
44
42
  describe '.play' do
45
43
  it 'calls play.scpt' do
46
- player.should_receive(:execute_script).with('player/play.scpt')
47
- player.play
44
+ Player.should_receive(:execute_script).with('player/play.scpt')
45
+ Player.play
48
46
  end
49
47
  end
50
48
 
51
49
  describe '.playing?' do
52
- subject { player.playing? }
50
+ subject { Player.playing? }
53
51
  context 'when iTunes plays a track' do
54
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
52
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
55
53
  it { expect(subject).to be_true }
56
54
  end
57
55
 
58
56
  context 'when iTunes stops a track' do
59
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
57
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
60
58
  it { expect(subject).to be_false }
61
59
  end
62
60
  end
63
61
 
64
62
  describe '.paused?' do
65
- subject { player.paused? }
63
+ subject { Player.paused? }
66
64
  context 'when iTunes plays a track' do
67
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
65
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
68
66
  it { expect(subject).to be_false }
69
67
  end
70
68
 
71
69
  context 'when iTunes pauses' do
72
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('paused') }
70
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('paused') }
73
71
  it { expect(subject).to be_true }
74
72
  end
75
73
  end
76
74
 
77
75
  describe '.stopped?' do
78
- subject { player.stopped? }
76
+ subject { Player.stopped? }
79
77
  context 'when iTunes plays a track' do
80
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
78
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
81
79
  it { expect(subject).to be_false }
82
80
  end
83
81
 
84
82
  context 'when iTunes stops a track' do
85
- before { player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
83
+ before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
86
84
  it { expect(subject).to be_true }
87
85
  end
88
86
  end
89
87
 
90
88
  describe '.next_track' do
91
89
  before do
92
- player.should_receive(:execute_script).
90
+ Player.should_receive(:execute_script).
93
91
  with('player/next_track.scpt').and_return(new_persistent_id)
94
92
  Track.should_receive(:find_by).
95
93
  with(persistent_id: new_persistent_id).
@@ -98,14 +96,14 @@ describe Player do
98
96
  let(:new_persistent_id) { 'foo' }
99
97
 
100
98
  it 'plays a next track' do
101
- next_track = player.next_track
99
+ next_track = Player.next_track
102
100
  expect(next_track.persistent_id).to eq(new_persistent_id)
103
101
  end
104
102
  end
105
103
 
106
104
  describe '.prev_track' do
107
105
  before do
108
- player.should_receive(:execute_script).
106
+ Player.should_receive(:execute_script).
109
107
  with('player/prev_track.scpt').and_return(new_persistent_id)
110
108
  Track.should_receive(:find_by).
111
109
  with(persistent_id: new_persistent_id).
@@ -114,9 +112,26 @@ describe Player do
114
112
  let(:new_persistent_id) { 'foo' }
115
113
 
116
114
  it 'plays a previous track' do
117
- next_track = player.prev_track
115
+ next_track = Player.prev_track
118
116
  expect(next_track.persistent_id).to eq(new_persistent_id)
119
117
  end
120
118
  end
121
119
 
120
+ describe '.current_track' do
121
+ before do
122
+ Player.should_receive(:execute_script).
123
+ with('player/current_track.scpt').
124
+ and_return(new_persistent_id)
125
+ Track.should_receive(:find_by).
126
+ with({ persistent_id: new_persistent_id }).
127
+ and_return([Track.new(persistent_id: new_persistent_id)])
128
+ end
129
+ let(:new_persistent_id) { 'new_persistent_id' }
130
+
131
+ it 'returns a current track' do
132
+ current_track = Player.current_track
133
+ expect(current_track.persistent_id).to eq(new_persistent_id)
134
+ end
135
+ end
136
+
122
137
  end
@@ -155,20 +155,4 @@ describe Track do
155
155
  end
156
156
  end
157
157
  end
158
-
159
- describe '.current_track' do
160
- subject(:current_track) { Track.current_track }
161
- let(:new_persistent_id) { 'new_persistent_id' }
162
- before do
163
- Track.should_receive(:execute_script).
164
- with('track/current_track.scpt').
165
- and_return(new_persistent_id)
166
- Track.should_receive(:find_by).
167
- with({ persistent_id: new_persistent_id }).
168
- and_return([Track.new(persistent_id: new_persistent_id)])
169
- end
170
- it 'returns a current track' do
171
- expect(current_track.persistent_id).to eq(new_persistent_id)
172
- end
173
- end
174
158
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryo katsuma
@@ -175,6 +175,7 @@ files:
175
175
  - lib/itunes/util/executor.rb
176
176
  - lib/itunes/version.rb
177
177
  - scripts/player/add.scpt
178
+ - scripts/player/current_track.scpt
178
179
  - scripts/player/next_track.scpt
179
180
  - scripts/player/pause.scpt
180
181
  - scripts/player/play.scpt
@@ -182,7 +183,6 @@ files:
182
183
  - scripts/player/prev_track.scpt
183
184
  - scripts/player/stop.scpt
184
185
  - scripts/track/convert.scpt
185
- - scripts/track/current_track.scpt
186
186
  - scripts/track/delete.scpt
187
187
  - scripts/track/finder.tmpl.scpt
188
188
  - scripts/track/play.scpt