itunes-client 0.1.7 → 0.1.8

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: c7c189fff206a4195c462ee164b839c8650f2fc7
4
- data.tar.gz: 70e5a4475b5ff5748d093b78516b952bbc3bea19
3
+ metadata.gz: 65c223fb2667334432e8c1abae7ba824866af422
4
+ data.tar.gz: 5f0696afab2934878524b5d3bcf4a302f72cb968
5
5
  SHA512:
6
- metadata.gz: 3b2e8948ff6cf54e8b6c4165ed9292293be30133c32ce3dc8f33fefc0f5c82141b914a5faae9461a4845936f281e8aadc1e9c4d8a2eaa2037c816b3354f1a5fe
7
- data.tar.gz: c55a3960ba159490b62fca65c482cee299b1f7cd2125ad31c06604cec368cbf880b6861815de61f34208629d9b484b030fc02778a921cb09facbe838e1d77e2d
6
+ metadata.gz: 2195776658c61f904b1bc40e3b545b6d9e4d294917d7d44b77f81712d9c720d687dbb9ae14cf36b0bb2ea57aa41b70f87686ba9d83e5ede4654356e4215f035b
7
+ data.tar.gz: c928d7021796713d796dfc27198a3922a1c9cdca85408f2c6394cef723560e8130b66cf0e3e08b68bb4f98f200ebc5052c4d27a925650e52fb3c54fc25601198
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
4
- - 2.0.0
5
- - 1.9.3
3
+ - 2.2
4
+ - 2.1
5
+ - 2.0
6
+ - 1.9
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec' do
1
+ guard 'rspec', cmd: 'bundle exec rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -24,12 +24,13 @@ $ gem install itunes-client
24
24
  ```
25
25
 
26
26
  ## Supported OS
27
- - OSX 10.9 (Mavericks)
28
- - OSX 10.8 (Mountain Lion)
27
+ - OSX Yosemite
28
+ - OSX Mavericks
29
29
 
30
30
 
31
31
  ## Supported Ruby
32
- - 2.1.0
32
+ - 2.2.0-preview1
33
+ - 2.1.3
33
34
  - 2.0.0
34
35
  - 1.9.3
35
36
 
@@ -18,14 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "rake", "~> 10.0.3"
22
- spec.add_development_dependency "rspec", "~> 2.13.0"
23
- spec.add_development_dependency "rb-fsevent", "~> 0.9.3"
24
- spec.add_development_dependency "guard", "~> 1.8.1"
25
- spec.add_development_dependency "guard-rspec", "~> 3.0.2"
21
+ spec.add_development_dependency "rake", "~> 10.3.2"
22
+ spec.add_development_dependency "rspec", "~> 3.1.0"
23
+ spec.add_development_dependency "rb-fsevent", "~> 0.9.4"
24
+ spec.add_development_dependency "guard", "~> 2.6.1"
25
+ spec.add_development_dependency "guard-rspec", "~> 4.3.1"
26
26
  spec.add_development_dependency "growl", "~> 1.0.3"
27
- spec.add_development_dependency "fakefs", "~> 0.4.2"
28
- spec.add_development_dependency "simplecov", "~> 0.7.1"
29
- spec.add_development_dependency "coveralls", "~> 0.6.6"
30
- spec.add_development_dependency "pry", "~> 0.9.12.2"
27
+ spec.add_development_dependency "fakefs", "~> 0.6.0"
28
+ spec.add_development_dependency "simplecov", "~> 0.9.0"
29
+ spec.add_development_dependency "coveralls", "~> 0.7.1"
30
+ spec.add_development_dependency "pry", "~> 0.10.1"
31
31
  end
data/lib/itunes/player.rb CHANGED
@@ -47,6 +47,14 @@ module Itunes
47
47
  execute_script("#{script_dir}/player_state.scpt") == 'stopped'
48
48
  end
49
49
 
50
+ def position
51
+ execute_script("#{script_dir}/position.scpt").to_f
52
+ end
53
+
54
+ def position=(position)
55
+ execute_script("#{script_dir}/set_position.scpt", position).to_f
56
+ end
57
+
50
58
  def next_track
51
59
  persistent_id = execute_script("#{script_dir}/next_track.scpt")
52
60
  Track.find_by(persistent_id: persistent_id).first
@@ -1,3 +1,3 @@
1
1
  module Itunes
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -0,0 +1,3 @@
1
+ tell application "iTunes"
2
+ player position
3
+ end tell
@@ -0,0 +1,6 @@
1
+ on run argv
2
+ tell application "iTunes"
3
+ set player position to (item 1 of argv)
4
+ return player position
5
+ end tell
6
+ end run
@@ -21,9 +21,9 @@ describe Player do
21
21
  end
22
22
 
23
23
  before do
24
- Player.should_receive(:execute_script).
24
+ expect(Player).to receive(:execute_script).
25
25
  with('player/add.scpt', file_name).and_return(new_persistent_id)
26
- Track.should_receive(:find_by).
26
+ expect(Track).to receive(:find_by).
27
27
  with(persistent_id: new_persistent_id).
28
28
  and_return([Track.new(persistent_id: new_persistent_id)])
29
29
  end
@@ -53,21 +53,21 @@ describe Player do
53
53
 
54
54
  describe '.pause' do
55
55
  it 'calls pause.scpt' do
56
- Player.should_receive(:execute_script).with('player/pause.scpt')
56
+ expect(Player).to receive(:execute_script).with('player/pause.scpt')
57
57
  Player.pause
58
58
  end
59
59
  end
60
60
 
61
61
  describe '.stop' do
62
62
  it 'calls stop.scpt' do
63
- Player.should_receive(:execute_script).with('player/stop.scpt')
63
+ expect(Player).to receive(:execute_script).with('player/stop.scpt')
64
64
  Player.stop
65
65
  end
66
66
  end
67
67
 
68
68
  describe '.play' do
69
69
  it 'calls play.scpt' do
70
- Player.should_receive(:execute_script).with('player/play.scpt')
70
+ expect(Player).to receive(:execute_script).with('player/play.scpt')
71
71
  Player.play
72
72
  end
73
73
  end
@@ -75,47 +75,63 @@ describe Player do
75
75
  describe '.playing?' do
76
76
  subject { Player.playing? }
77
77
  context 'when iTunes plays a track' do
78
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
79
- it { expect(subject).to be_true }
78
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
79
+ it { expect(subject).to be_truthy }
80
80
  end
81
81
 
82
82
  context 'when iTunes stops a track' do
83
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
84
- it { expect(subject).to be_false }
83
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
84
+ it { expect(subject).to be_falsey }
85
85
  end
86
86
  end
87
87
 
88
88
  describe '.paused?' do
89
89
  subject { Player.paused? }
90
90
  context 'when iTunes plays a track' do
91
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
92
- it { expect(subject).to be_false }
91
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
92
+ it { expect(subject).to be_falsey }
93
93
  end
94
94
 
95
95
  context 'when iTunes pauses' do
96
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('paused') }
97
- it { expect(subject).to be_true }
96
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('paused') }
97
+ it { expect(subject).to be_truthy }
98
98
  end
99
99
  end
100
100
 
101
101
  describe '.stopped?' do
102
102
  subject { Player.stopped? }
103
103
  context 'when iTunes plays a track' do
104
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
105
- it { expect(subject).to be_false }
104
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('playing') }
105
+ it { expect(subject).to be_falsey }
106
106
  end
107
107
 
108
108
  context 'when iTunes stops a track' do
109
- before { Player.should_receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
110
- it { expect(subject).to be_true }
109
+ before { expect(Player).to receive(:execute_script).with('player/player_state.scpt').and_return('stopped') }
110
+ it { expect(subject).to be_truthy }
111
+ end
112
+ end
113
+
114
+ describe '.position' do
115
+ it 'calls position.scpt' do
116
+ expect(Player).to receive(:execute_script).with('player/position.scpt')
117
+ Player.position
118
+ end
119
+ end
120
+
121
+ describe '.position=' do
122
+ let(:position) { 10 }
123
+
124
+ it 'sets player position by argument' do
125
+ expect(Player).to receive(:execute_script).with('player/set_position.scpt', position)
126
+ Player.position = position
111
127
  end
112
128
  end
113
129
 
114
130
  describe '.next_track' do
115
131
  before do
116
- Player.should_receive(:execute_script).
132
+ expect(Player).to receive(:execute_script).
117
133
  with('player/next_track.scpt').and_return(new_persistent_id)
118
- Track.should_receive(:find_by).
134
+ expect(Track).to receive(:find_by).
119
135
  with(persistent_id: new_persistent_id).
120
136
  and_return([Track.new(persistent_id: new_persistent_id)])
121
137
  end
@@ -129,9 +145,9 @@ describe Player do
129
145
 
130
146
  describe '.prev_track' do
131
147
  before do
132
- Player.should_receive(:execute_script).
148
+ expect(Player).to receive(:execute_script).
133
149
  with('player/prev_track.scpt').and_return(new_persistent_id)
134
- Track.should_receive(:find_by).
150
+ expect(Track).to receive(:find_by).
135
151
  with(persistent_id: new_persistent_id).
136
152
  and_return([Track.new(persistent_id: new_persistent_id)])
137
153
  end
@@ -145,10 +161,10 @@ describe Player do
145
161
 
146
162
  describe '.current_track' do
147
163
  before do
148
- Player.should_receive(:execute_script).
164
+ expect(Player).to receive(:execute_script).
149
165
  with('player/current_track.scpt').
150
166
  and_return(new_persistent_id)
151
- Track.should_receive(:find_by).
167
+ expect(Track).to receive(:find_by).
152
168
  with({ persistent_id: new_persistent_id }).
153
169
  and_return([Track.new(persistent_id: new_persistent_id)])
154
170
  end
@@ -32,10 +32,10 @@ describe Track do
32
32
  let(:new_persistent_id) { 'bar' }
33
33
 
34
34
  before do
35
- track.should_receive(:execute_script).
35
+ expect(track).to receive(:execute_script).
36
36
  with('track/convert.scpt', base_persistent_id).
37
37
  and_return(new_persistent_id)
38
- Track.should_receive(:find_by).
38
+ expect(Track).to receive(:find_by).
39
39
  with(persistent_id: new_persistent_id).
40
40
  and_return([Track.new(persistent_id: new_persistent_id)])
41
41
  end
@@ -51,7 +51,7 @@ describe Track do
51
51
  subject { track.delete! }
52
52
 
53
53
  before do
54
- track.should_receive(:execute_script).
54
+ expect(track).to receive(:execute_script).
55
55
  with('track/delete.scpt', track.persistent_id)
56
56
  end
57
57
 
@@ -62,7 +62,7 @@ describe Track do
62
62
  subject { track.play }
63
63
 
64
64
  before do
65
- track.should_receive(:execute_script).
65
+ expect(track).to receive(:execute_script).
66
66
  with('track/play.scpt', track.persistent_id)
67
67
  end
68
68
 
@@ -73,7 +73,7 @@ describe Track do
73
73
  subject(:pause) { track.pause }
74
74
 
75
75
  it 'calls player#pause' do
76
- player.should_receive(:pause)
76
+ expect(player).to receive(:pause)
77
77
  pause
78
78
  end
79
79
  end
@@ -82,7 +82,7 @@ describe Track do
82
82
  subject(:stop) { track.stop }
83
83
 
84
84
  it 'calls player#stop' do
85
- player.should_receive(:stop)
85
+ expect(player).to receive(:stop)
86
86
  stop
87
87
  end
88
88
  end
@@ -104,10 +104,10 @@ describe Track do
104
104
  let(:attributes) { { name: new_name, album: new_album } }
105
105
 
106
106
  before do
107
- track.stub(:generate_script_from_template).
107
+ allow(track).to receive(:generate_script_from_template).
108
108
  with('track/updater.tmpl.scpt', persistent_id: track.persistent_id, update_records: "set name of specified_track to \"#{new_name}\"\nset album of specified_track to \"#{new_album}\"").
109
109
  and_return(new_scpt)
110
- track.stub(:execute_template_based_script).
110
+ allow(track).to receive(:execute_template_based_script).
111
111
  with(new_scpt)
112
112
  end
113
113
 
@@ -148,10 +148,10 @@ describe Track do
148
148
  let(:name) { 'Hey Jude' }
149
149
 
150
150
  before do
151
- Track.stub(:generate_script_from_template).
151
+ allow(Track).to receive(:generate_script_from_template).
152
152
  and_return(new_scpt)
153
153
 
154
- Track.stub(:execute_template_based_script).
154
+ allow(Track).to receive(:execute_template_based_script).
155
155
  and_return([{ persistent_id: new_persistent_id, name: name }].to_json)
156
156
  end
157
157
 
@@ -167,10 +167,10 @@ describe Track do
167
167
  subject(:all) { Track.all }
168
168
 
169
169
  it 'calls find_by(:all)' do
170
- Track.stub(:generate_script_from_template).
170
+ allow(Track).to receive(:generate_script_from_template).
171
171
  and_return('new.scpt')
172
172
 
173
- Track.stub(:execute_template_based_script).
173
+ allow(Track).to receive(:execute_template_based_script).
174
174
  with('new.scpt').
175
175
  and_return([].to_json)
176
176
 
@@ -16,7 +16,7 @@ describe Itunes::Util::Executor do
16
16
  let(:result) { { status: 'ok' }.to_json }
17
17
 
18
18
  it 'returns a script result' do
19
- Open3.should_receive(:capture2).with("osascript #{klass.script_base_dir}/#{path} #{args}").and_return(result)
19
+ expect(Open3).to receive(:capture2).with("osascript #{klass.script_base_dir}/#{path} #{args}").and_return(result)
20
20
  expect(execute_script).to eq(result)
21
21
  end
22
22
  end
@@ -29,7 +29,7 @@ describe Itunes::Util::Executor do
29
29
  let(:result) { { status: 'ok' }.to_json }
30
30
 
31
31
  before do
32
- Open3.should_receive(:capture2).with("osascript #{script_full_path}").and_return(result)
32
+ expect(Open3).to receive(:capture2).with("osascript #{script_full_path}").and_return(result)
33
33
  FileUtils.touch(script_full_path)
34
34
  end
35
35
 
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ require 'coveralls'
8
8
  Bundler.setup(:default, :development)
9
9
 
10
10
  RSpec.configure do |config|
11
- config.color_enabled = true
11
+ config.color = true
12
12
  config.tty = true
13
13
  #config.formatter = :documentation
14
14
  config.include FakeFS::SpecHelpers, fakefs: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryo katsuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2015-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 10.0.3
19
+ version: 10.3.2
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 10.0.3
26
+ version: 10.3.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.13.0
33
+ version: 3.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.13.0
40
+ version: 3.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rb-fsevent
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.9.3
47
+ version: 0.9.4
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.3
54
+ version: 0.9.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.8.1
61
+ version: 2.6.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.1
68
+ version: 2.6.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.0.2
75
+ version: 4.3.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.0.2
82
+ version: 4.3.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: growl
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.4.2
103
+ version: 0.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.4.2
110
+ version: 0.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.7.1
117
+ version: 0.9.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.7.1
124
+ version: 0.9.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: coveralls
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.6.6
131
+ version: 0.7.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.6.6
138
+ version: 0.7.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.9.12.2
145
+ version: 0.10.1
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.9.12.2
152
+ version: 0.10.1
153
153
  description: iTunes client with high level API
154
154
  email:
155
155
  - katsuma@gmail.com
@@ -180,7 +180,9 @@ files:
180
180
  - scripts/player/pause.scpt
181
181
  - scripts/player/play.scpt
182
182
  - scripts/player/player_state.scpt
183
+ - scripts/player/position.scpt
183
184
  - scripts/player/prev_track.scpt
185
+ - scripts/player/set_position.scpt
184
186
  - scripts/player/stop.scpt
185
187
  - scripts/track/convert.scpt
186
188
  - scripts/track/delete.scpt
@@ -211,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
213
  version: '0'
212
214
  requirements: []
213
215
  rubyforge_project:
214
- rubygems_version: 2.2.0
216
+ rubygems_version: 2.4.5
215
217
  signing_key:
216
218
  specification_version: 4
217
219
  summary: itunes-client provides a high level API like ActiveRecord style to control