itunes-client 0.1.8 → 0.2.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: 65c223fb2667334432e8c1abae7ba824866af422
4
- data.tar.gz: 5f0696afab2934878524b5d3bcf4a302f72cb968
3
+ metadata.gz: 2f636c50e60a1601b8d1666384714bd4d2501e18
4
+ data.tar.gz: 680822064d023dca16d84a7a44563e15c8bebb24
5
5
  SHA512:
6
- metadata.gz: 2195776658c61f904b1bc40e3b545b6d9e4d294917d7d44b77f81712d9c720d687dbb9ae14cf36b0bb2ea57aa41b70f87686ba9d83e5ede4654356e4215f035b
7
- data.tar.gz: c928d7021796713d796dfc27198a3922a1c9cdca85408f2c6394cef723560e8130b66cf0e3e08b68bb4f98f200ebc5052c4d27a925650e52fb3c54fc25601198
6
+ metadata.gz: 8f73dd601b66ad9ca14ab81f0c3a6cbf319f255b7765b98a020f1f21c116933caa08ba4a19e2fb761eecbe6aed7997d6920b0c7c8f0c8da9b97e348c76adb98e
7
+ data.tar.gz: f776209c942f08ee85ad7bf919dbf9767147c418a4c9e3d8853226d3c26b388574cd94a86cd7dffb8f2462c1ecca62cb6434ab0b3979590ffa3df6d4d33e9560
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .DS_Store
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
+ before_install:
3
+ - gem update bundler
2
4
  rvm:
3
5
  - 2.2
4
6
  - 2.1
5
7
  - 2.0
6
- - 1.9
data/README.md CHANGED
@@ -29,10 +29,10 @@ $ gem install itunes-client
29
29
 
30
30
 
31
31
  ## Supported Ruby
32
- - 2.2.0-preview1
33
- - 2.1.3
34
- - 2.0.0
35
- - 1.9.3
32
+ - 2.2
33
+ - 2.1
34
+ - 2.0
35
+
36
36
 
37
37
  ## Usage
38
38
 
@@ -57,6 +57,22 @@ track.play
57
57
 
58
58
  # Stop track
59
59
  track.stop
60
+
61
+ # Control volume
62
+ volume = Itunes::Volume
63
+
64
+ # Decrease and increase the volume
65
+ volume.down(20)
66
+ volume.down # default 10
67
+ volume.up(20)
68
+ volume.up # default 10
69
+
70
+ # Mute and unmute the volume
71
+ volume.mute
72
+ volume.unmute
73
+
74
+ # Return volume value
75
+ volume.value
60
76
  ```
61
77
 
62
78
  ## License
@@ -3,6 +3,7 @@ require 'singleton'
3
3
 
4
4
  require 'itunes/track'
5
5
  require 'itunes/util'
6
+ require 'itunes/volume'
6
7
 
7
8
  module Itunes
8
9
  class Player
@@ -14,7 +14,11 @@ module Itunes
14
14
  :artist,
15
15
  :track_count,
16
16
  :track_number,
17
- :year
17
+ :year,
18
+ :season_number,
19
+ :episode_number,
20
+ :show,
21
+ :video_kind
18
22
  ].freeze
19
23
 
20
24
  FINDER_ATTRIBUTES = [
@@ -120,7 +124,11 @@ module Itunes
120
124
  records = []
121
125
  args.each do |key, val|
122
126
  if ATTRIBUTES.include?(key)
123
- records << "set #{key.to_s.gsub('_', ' ')} of specified_track to \"#{val}\""
127
+ if key == :video_kind
128
+ records << "set video kind of specified_track to #{val}"
129
+ else
130
+ records << "set #{key.to_s.gsub('_', ' ')} of specified_track to \"#{val}\""
131
+ end
124
132
  end
125
133
  end
126
134
  records.join("\n")
@@ -1,3 +1,3 @@
1
1
  module Itunes
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require 'itunes/util'
2
+
3
+ module Itunes
4
+ class Volume
5
+ extend Itunes::Util::Executor
6
+
7
+ class << self
8
+ def up(level = 10)
9
+ execute_script("#{script_dir}/up.scpt", level)
10
+ self
11
+ end
12
+
13
+ def down(level = 10)
14
+ execute_script("#{script_dir}/down.scpt", level)
15
+ self
16
+ end
17
+
18
+ def mute
19
+ execute_script("#{script_dir}/mute.scpt")
20
+ self
21
+ end
22
+
23
+ def unmute
24
+ execute_script("#{script_dir}/unmute.scpt")
25
+ self
26
+ end
27
+
28
+ def value
29
+ execute_script("#{script_dir}/value.scpt").to_i
30
+ end
31
+
32
+ private
33
+ def script_dir
34
+ 'volume'
35
+ end
36
+ end
37
+ end
38
+ end
@@ -12,7 +12,11 @@ tell application "iTunes"
12
12
  set end of props to ("\"artist\":\"" & my escape_quote(artist of specified_track) & "\",")
13
13
  set end of props to ("\"track_count\":\"" & track count of specified_track & "\",")
14
14
  set end of props to ("\"track_number\":\"" & track number of specified_track & "\",")
15
- set end of props to ("\"year\":\"" & year of specified_track & "\"")
15
+ set end of props to ("\"year\":\"" & year of specified_track & "\",")
16
+ set end of props to ("\"video_kind\":\"" & video kind of specified_track & "\",")
17
+ set end of props to ("\"show\":\"" & show of specified_track & "\",")
18
+ set end of props to ("\"season_number\":\"" & season number of specified_track & "\",")
19
+ set end of props to ("\"episode_number\":\"" & episode number of specified_track & "\"")
16
20
  set end of props to "}"
17
21
 
18
22
  set json to json & props as string & ","
@@ -0,0 +1,5 @@
1
+ on run argv
2
+ tell application "iTunes"
3
+ set sound volume to (sound volume - (item 1 of argv))
4
+ end tell
5
+ end run
@@ -0,0 +1,3 @@
1
+ tell application "iTunes"
2
+ set mute to true
3
+ end tell
@@ -0,0 +1,3 @@
1
+ tell application "iTunes"
2
+ set mute to false
3
+ end tell
@@ -0,0 +1,5 @@
1
+ on run argv
2
+ tell application "iTunes"
3
+ set sound volume to (sound volume + (item 1 of argv))
4
+ end tell
5
+ end run
@@ -0,0 +1,3 @@
1
+ tell application "iTunes"
2
+ return sound volume
3
+ end tell
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'itunes-client'
3
+
4
+ include Itunes
5
+
6
+ describe Volume do
7
+ let(:level) { an_instance_of(Fixnum) }
8
+
9
+ describe '.up' do
10
+ it 'calls up.scpt' do
11
+ expect(Volume).to receive(:execute_script).with('volume/up.scpt', level)
12
+ Volume.up
13
+ end
14
+ end
15
+
16
+ describe '.down' do
17
+ it 'calls down.scpt' do
18
+ expect(Volume).to receive(:execute_script).with('volume/down.scpt', level)
19
+ Volume.down
20
+ end
21
+ end
22
+
23
+ describe '.mute' do
24
+ it 'calls mute.scpt' do
25
+ expect(Volume).to receive(:execute_script).with('volume/mute.scpt')
26
+ Volume.mute
27
+ end
28
+ end
29
+
30
+ describe '.unmute' do
31
+ it 'calls unmute.scpt' do
32
+ expect(Volume).to receive(:execute_script).with('volume/unmute.scpt')
33
+ Volume.unmute
34
+ end
35
+ end
36
+
37
+ describe '.value' do
38
+ context 'when iTunes returns volume level' do
39
+ it 'returns current value' do
40
+ allow(Volume).to receive(:execute_script).with('volume/value.scpt').and_return("30")
41
+ expect(Volume.value).to eq(30)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
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.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryo katsuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2015-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -174,6 +174,7 @@ files:
174
174
  - lib/itunes/util.rb
175
175
  - lib/itunes/util/executor.rb
176
176
  - lib/itunes/version.rb
177
+ - lib/itunes/volume.rb
177
178
  - scripts/player/add.scpt
178
179
  - scripts/player/current_track.scpt
179
180
  - scripts/player/next_track.scpt
@@ -189,9 +190,15 @@ files:
189
190
  - scripts/track/finder.tmpl.scpt
190
191
  - scripts/track/play.scpt
191
192
  - scripts/track/updater.tmpl.scpt
193
+ - scripts/volume/down.scpt
194
+ - scripts/volume/mute.scpt
195
+ - scripts/volume/unmute.scpt
196
+ - scripts/volume/up.scpt
197
+ - scripts/volume/value.scpt
192
198
  - spec/itunes/player_spec.rb
193
199
  - spec/itunes/track_spec.rb
194
200
  - spec/itunes/util/executor_spec.rb
201
+ - spec/itunes/volume_spec.rb
195
202
  - spec/spec_helper.rb
196
203
  homepage: https://github.com/katsuma/itunes-client
197
204
  licenses:
@@ -222,4 +229,5 @@ test_files:
222
229
  - spec/itunes/player_spec.rb
223
230
  - spec/itunes/track_spec.rb
224
231
  - spec/itunes/util/executor_spec.rb
232
+ - spec/itunes/volume_spec.rb
225
233
  - spec/spec_helper.rb