spty 0.2.0 → 0.3.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: 522850d6e6a9a6eb5f13810aa5d6fd1a7b5b2c5e
4
- data.tar.gz: a60e505c3c678e4192c59d5eb92ac31e55f1295d
3
+ metadata.gz: 36a4a7466d3e6d655f2738738476d2411d604e12
4
+ data.tar.gz: f16da74414643bf5380ddd217e81975878cebbd5
5
5
  SHA512:
6
- metadata.gz: 71ce6cce28e3d61f19cf9eb95f9cc6e6b2103f2bf414536df847ab49d467959a983765f050fffb2ef8b117916cc3a66cf8ae4bb2185424ae2f903b978ebe28ef
7
- data.tar.gz: 15f6143a5197f7f1f7c677518ac3c30bb5f9d9be62779508e0f1f2031a1e8a9ed2fd50e7949a7716709838812d6c57d305c8315ff8e1c8afc4f433ac257779bb
6
+ metadata.gz: 833a1aac1594c88ff35ea7ae3c7e08bf93244537975a1686f1b5473efc89f92cb8c642b7a654ce1b7281cebc017fccdbf1109d60b32bf18357792b04f4e60226
7
+ data.tar.gz: 9410b8bcb475f9904c712e506df2bb39bd334d8c68ea2c37cf15b127dbbefd4b16b152ef3312d1d263ca98574b96ddc0fb5a3e96c7ce1163f081264332a60f03
@@ -0,0 +1,21 @@
1
+ module Spty::Command
2
+ class InfoCommand
3
+ ASCRIPT_TRACK_INFO = <<-EOL
4
+ tell application "Spotify"
5
+ set currentTrack to name of current track as string
6
+ set currentArtist to artist of current track as string
7
+
8
+ return currentTrack & " - " & currentArtist
9
+ end tell
10
+ EOL
11
+ def self.call(_, _command = 'info')
12
+ if Spty::Command::PlayerCommand.running?
13
+ track_info = Spty::AppleScriptRunner.(ASCRIPT_TRACK_INFO)
14
+ player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
15
+ player_state = Spty::AppleScriptRunner.(player_state_script)
16
+
17
+ puts "=> #{track_info.strip} [#{player_state.strip}]"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -15,25 +15,21 @@ module Spty::Command
15
15
  puts "=> player not running" and return false
16
16
  end
17
17
 
18
- # Display the current state of the player.
19
- ASCRIPT_PLAYER_STATE = <<-EOL
20
- tell application "Spotify" to return player state
21
- EOL
22
- def self.state(_)
18
+ # Method is depreciated. It calls the actuall method
19
+ # This method should be removed on next release
20
+ def self.state(_, command = 'state')
23
21
  if running?
24
- player_state = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_STATE)
25
- puts "=> player #{player_state}"
22
+ Spty::Command::StateCommand.('state')
23
+ puts "Command is deprecated. Use \"spty #{command}\"."
26
24
  end
27
25
  end
28
26
 
29
- # Toggle player play / pause
30
- ASCRIPT_PLAYER_TOGGLE = <<-EOL
31
- tell application "Spotify" to playpause
32
- EOL
33
- def self.toggle(_)
27
+ # Method is depreciated. It calls the actuall method
28
+ # This method should be removed on next release
29
+ def self.toggle(_, command = 'toggle')
34
30
  if running?
35
- Spty::AppleScriptRunner.(ASCRIPT_PLAYER_TOGGLE)
36
- state(nil)
31
+ Spty::Command::ToggleCommand.(nil, 'toggle')
32
+ puts "Command is deprecated. Use \"spty #{command}\"."
37
33
  end
38
34
  end
39
35
  end
@@ -0,0 +1,17 @@
1
+ module Spty::Command
2
+ class ReplayCommand < BaseCommand
3
+
4
+ ASCRIPT_TRACK_REPLAY = <<-EOL
5
+ tell application "Spotify"
6
+ previous track
7
+ end tell
8
+ EOL
9
+ def self.call(_, command = 'replay')
10
+ if Spty::Command::PlayerCommand.running?
11
+ Spty::AppleScriptRunner.(ASCRIPT_TRACK_REPLAY)
12
+ Spty::Command::InfoCommand.(nil, command)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Spty::Command
2
+ class SkipCommand
3
+
4
+ ASCRIPT_TRACK_SKIP = <<-EOL
5
+ tell application "Spotify"
6
+ next track
7
+ end tell
8
+ EOL
9
+ def self.call(_, command = 'skip')
10
+ if Spty::Command::PlayerCommand.running?
11
+ Spty::AppleScriptRunner.(ASCRIPT_TRACK_SKIP)
12
+ Spty::Command::InfoCommand.(nil, command)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module Spty::Command
2
+ class StateCommand
3
+ # Display the current state of the player.
4
+ ASCRIPT_PLAYER_STATE = <<-EOL
5
+ tell application "Spotify" to return player state
6
+ EOL
7
+ def self.call(_, _command = nil)
8
+ if Spty::Command::PlayerCommand.running?
9
+ player_state = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_STATE)
10
+ puts "=> player #{player_state}"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Spty::Command
2
+ class ToggleCommand
3
+ # Toggle player play / pause
4
+ ASCRIPT_PLAYER_TOGGLE = <<-EOL
5
+ tell application "Spotify" to playpause
6
+ EOL
7
+ def self.call(_, command = 'toggle')
8
+ if Spty::Command::PlayerCommand.running?
9
+ Spty::AppleScriptRunner.(ASCRIPT_PLAYER_TOGGLE)
10
+ Spty::Command::StateCommand.(nil, command)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,48 +1,26 @@
1
1
  module Spty::Command
2
2
  class TrackCommand < BaseCommand
3
- ASCRIPT_TRACK_INFO = <<-EOL
4
- tell application "Spotify"
5
- set currentTrack to name of current track as string
6
- set currentArtist to artist of current track as string
7
3
 
8
- return currentTrack & " - " & currentArtist
9
- end tell
10
- EOL
11
- def self.info(_)
4
+ # This command is deprecated.
5
+ def self.info(_, command = 'info')
12
6
  if Spty::Command::PlayerCommand.running?
13
- track_info = Spty::AppleScriptRunner.(ASCRIPT_TRACK_INFO)
14
- player_state_script = Spty::Command::PlayerCommand::ASCRIPT_PLAYER_STATE
15
- player_state = Spty::AppleScriptRunner.(player_state_script)
16
-
17
- puts "=> #{track_info.strip} [#{player_state.strip}]"
7
+ Spty::Command::InfoCommand.(nil, 'info')
8
+ puts "Command is deprecated. Use \"spty #{command}\"."
18
9
  end
19
10
  end
20
11
 
21
- ASCRIPT_TRACK_SKIP = <<-EOL
22
- tell application "Spotify"
23
- next track
24
- end tell
25
- EOL
12
+ # This command is deprecated.
26
13
  def self.skip(_)
27
- move_track(ASCRIPT_TRACK_SKIP)
14
+ Spty::Command::SkipCommand.call(nil)
15
+ puts 'Command is deprecated. Use "spty skip".'
28
16
  end
29
17
 
30
- ASCRIPT_TRACK_REPLAY = <<-EOL
31
- tell application "Spotify"
32
- previous track
33
- end tell
34
- EOL
18
+ # This command is deprecared.
35
19
  def self.replay(_)
36
- move_track(ASCRIPT_TRACK_REPLAY)
37
- end
38
-
39
- def self.move_track(ascript)
40
- if Spty::Command::PlayerCommand.running?
41
- Spty::AppleScriptRunner.(ascript)
42
- Spty::Command::TrackCommand.info(nil)
43
- end
20
+ #move_track(ASCRIPT_TRACK_REPLAY, 'replay')
21
+ Spty::Command::ReplayCommand.call(nil)
22
+ puts 'Command is deprecated. Use "spty replay".'
44
23
  end
45
24
 
46
- private_class_method :move_track
47
25
  end
48
26
  end
@@ -1,3 +1,3 @@
1
1
  module Spty
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["jibone@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Spotify Player Terminal Utility}
13
- spec.description = %q{Lets you control your Spotify player from the terminal
14
- Currently only works for Mac OSX.}
13
+ spec.description = "Control your Spotify player from the terminal. "\
14
+ "Currently only works for Mac OSX."
15
15
  spec.homepage = "https://github.com/jibone/spty-rb"
16
16
  spec.license = "MIT"
17
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Shamsul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,8 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '9.0'
69
- description: |-
70
- Lets you control your Spotify player from the terminal
71
- Currently only works for Mac OSX.
69
+ description: Control your Spotify player from the terminal. Currently only works for
70
+ Mac OSX.
72
71
  email:
73
72
  - jibone@gmail.com
74
73
  executables:
@@ -91,7 +90,12 @@ files:
91
90
  - lib/spty/apple_script_runner.rb
92
91
  - lib/spty/cli.rb
93
92
  - lib/spty/commands/base_command.rb
93
+ - lib/spty/commands/info_command.rb
94
94
  - lib/spty/commands/player_command.rb
95
+ - lib/spty/commands/replay_command.rb
96
+ - lib/spty/commands/skip_command.rb
97
+ - lib/spty/commands/state_command.rb
98
+ - lib/spty/commands/toggle_command.rb
95
99
  - lib/spty/commands/track_command.rb
96
100
  - lib/spty/commands/version_command.rb
97
101
  - lib/spty/version.rb