audio_addict 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20084805bf5d4e9fa5409b4354364be364e005e8c5db251d4bc84dfa68f04436
4
- data.tar.gz: 8011bab35c939ffd10c183b56e62d169259add2f6c7c042a4e60b29b9e1fa1ca
3
+ metadata.gz: 78b583c758b2761c1722e3d70822ae254fc1fb45f3443d4b569d35bcbd2d69a5
4
+ data.tar.gz: '03608ec25c58034590834c322185adba375026292f0249d96cd8b1c29a8758a8'
5
5
  SHA512:
6
- metadata.gz: d28c3632e64e82c2154c70366c6664c90f1cb9a9e84b3ef6082efcf0629cde1ab3003ee6985a048d2d21c5d699bf7a87ba15119e5ff4d8ec18a581d7e9dad7bc
7
- data.tar.gz: f53f5dfeaabed9bb8d099809bae886f2b7b5cca0eb838e401f235257407cc9e8f7d386eab99d30577699b91f8110a7eda34126f059e3ea9b3a9d434fe0e8d775
6
+ metadata.gz: 182cca3495b2a000347eb9299c9981ecbbe8bbe464459dc1848293095a473f3153fbf611678bb2696a0811b052f6c6920b00b70e06a8176030381ad3ada6f048
7
+ data.tar.gz: 798d39dd7ada375219e5b45af40b82c2b45aa27ad1913b6eaa9ea239965ed8faf90d27bfe4532f3eca0975129a99e9700e896e2b26f0b96f726a80cabf356b8a
data/README.md CHANGED
@@ -67,6 +67,7 @@ Commands:
67
67
  vote Vote on the currently playing track
68
68
  playlist Generate playlists
69
69
  config Manage local configuration
70
+ log Manage local like log
70
71
 
71
72
 
72
73
  ```
data/bin/radio CHANGED
@@ -5,11 +5,22 @@ router = AudioAddict::CLI.router
5
5
 
6
6
  begin
7
7
  exit router.run ARGV
8
+
8
9
  rescue AudioAddict::Interrupt, TTY::Reader::InputInterrupt
9
10
  say "\nGoodbye"
10
11
  exit 1
11
- rescue => e
12
+
13
+ rescue AudioAddict::ConfigError => e
14
+ say "!undred!ERROR: Missing Configuration Values"
15
+ say "#{e.message}:"
16
+ e.missing_keys.each do |key|
17
+ say "- !txtblu!#{key}"
18
+ end
12
19
  say ""
20
+ say "Run !txtpur!radio config guide!txtrst! for more information"
21
+ exit 1
22
+
23
+ rescue => e
13
24
  if ENV['DEBUG']
14
25
  puts e.backtrace.reverse
15
26
  say ""
@@ -12,6 +12,7 @@ module AudioAddict
12
12
  router.route 'vote', to: Commands::VoteCmd
13
13
  router.route 'playlist', to: Commands::PlaylistCmd
14
14
  router.route 'config', to: Commands::ConfigCmd
15
+ router.route 'log', to: Commands::LogCmd
15
16
 
16
17
  router
17
18
  end
@@ -12,14 +12,11 @@ module AudioAddict
12
12
  missing.push key unless Config.has_key? key
13
13
  end
14
14
 
15
- if missing.any?
16
- missing_keys = missing.map { |k| "- !txtblu!#{k}" }.join "\n"
17
- raise ConfigError, "This operation requires some config parameters that are missing:\n#{missing_keys}"
18
- end
15
+ raise ConfigError, missing if missing.any?
19
16
  end
20
17
 
21
18
  def require_premium_account
22
- raise PremiumAccount, "This operation requires a premium account" unless Config.premium
19
+ raise PremiumAccount unless Config.premium
23
20
  end
24
21
 
25
22
  def radio
@@ -8,7 +8,7 @@ module AudioAddict
8
8
  usage "radio channels [SEARCH]"
9
9
  usage "radio channels --help"
10
10
 
11
- param "SEARCH", "Channel name or a partial name to search for."
11
+ param "SEARCH", "Channel name or a partial name to search for"
12
12
 
13
13
  example "radio channels"
14
14
  example "radio channels metal"
@@ -8,7 +8,7 @@ module AudioAddict
8
8
  usage "radio config del KEY"
9
9
  usage "radio config show"
10
10
  usage "radio config edit"
11
- usage "radio config keys"
11
+ usage "radio config guide"
12
12
  usage "radio config --help"
13
13
 
14
14
  param "KEY", "Config key"
@@ -17,12 +17,12 @@ module AudioAddict
17
17
  option "-s --show", "Show the contents of the config file"
18
18
  option "-e --edit", "Open the config file for editing"
19
19
 
20
- command "get", "Show the value of this config key."
21
- command "set", "Set the value of this config key."
22
- command "del", "Delete the value of this config key."
23
- command "show", "Show the entire config file contents."
24
- command "edit", "Open the config file for editing."
25
- command "keys", "Show a list of supported config keys and their purpose."
20
+ command "get", "Show the value of this config key"
21
+ command "set", "Set the value of this config key"
22
+ command "del", "Delete the value of this config key"
23
+ command "show", "Show the entire config file contents"
24
+ command "edit", "Open the config file for editing"
25
+ command "guide", "Show a list of supported config keys and their purpose"
26
26
 
27
27
  example "radio config edit"
28
28
  example "radio config set like_log ~/like.log"
@@ -64,7 +64,7 @@ module AudioAddict
64
64
  system "#{editor} #{Config.path}"
65
65
  end
66
66
 
67
- def keys_command(args)
67
+ def guide_command(args)
68
68
  key_guide.each do |key, value|
69
69
  say "!txtgrn!#{key}"
70
70
  say word_wrap " #{value}"
@@ -0,0 +1,53 @@
1
+ module AudioAddict
2
+ module Commands
3
+ class LogCmd < Base
4
+ summary "Manage local like log"
5
+
6
+ usage "radio log show"
7
+ usage "radio log tail [--lines N]"
8
+ usage "radio log sort"
9
+ usage "radio log --help"
10
+
11
+ option "-l --lines N", "Number of lines to show [default: 5]"
12
+
13
+ command "show", "Show the entire like log"
14
+ command "tail", "Show the last few rows of the like log"
15
+ command "sort", "Sort the log alphabetically and save it"
16
+
17
+ example "radio log show"
18
+ example "radio log tail"
19
+ example "radio log tail --lines 10"
20
+ example "radio log sort"
21
+
22
+ def show_command(args)
23
+ setup
24
+ puts File.read(logfile)
25
+ end
26
+
27
+ def tail_command(args)
28
+ setup
29
+ lines = args['--lines'].to_i
30
+ puts File.readlines(logfile)[-lines..-1]
31
+ end
32
+
33
+ def sort_command(args)
34
+ setup
35
+ lines = File.readlines logfile
36
+ File.write logfile, lines.sort.join
37
+ say "!txtgrn!Sorted"
38
+ end
39
+
40
+ private
41
+
42
+ def setup
43
+ needs :like_log
44
+ raise Error, "File not found: #{logfile}" unless File.exist? logfile
45
+ end
46
+
47
+ def logfile
48
+ @logfile ||= Config.like_log
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -30,7 +30,7 @@ module AudioAddict
30
30
  radio.api.login user, pass
31
31
  resay "!txtgrn!Saved"
32
32
  else
33
- say "!txtred!Aborted"
33
+ say "!txtred!Cancelled"
34
34
  end
35
35
  end
36
36
 
@@ -69,7 +69,7 @@ module AudioAddict
69
69
  save_channel list.first.key
70
70
  else
71
71
  answer = channel_prompt list
72
- save_channel(answer, echo: false) unless answer == :abort
72
+ save_channel(answer, echo: false) unless answer == :cancel
73
73
  end
74
74
  end
75
75
 
@@ -80,19 +80,19 @@ module AudioAddict
80
80
  save_network list.keys.first
81
81
  else
82
82
  answer = network_prompt list
83
- save_network(answer, echo: false) unless answer == :abort
83
+ save_network(answer, echo: false) unless answer == :cancel
84
84
  end
85
85
  end
86
86
 
87
87
  def channel_prompt(channels)
88
88
  options = channels.map { |channel| ["#{channel.name.ljust 20} # #{channel.key}", channel.key] }.to_h
89
- options = { "Abort" => :abort }.merge options
89
+ options = { "Cancel" => :cancel }.merge options
90
90
  prompt.select "Channel :", options, marker: '>', filter: true
91
91
  end
92
92
 
93
93
  def network_prompt(networks)
94
94
  options = networks.invert
95
- options["Abort"] = :abort
95
+ options["Skip"] = :cancel
96
96
  prompt.select "Network :", options, marker: '>', filter: true
97
97
  end
98
98
 
@@ -5,16 +5,20 @@ module AudioAddict
5
5
 
6
6
  help "Start an interactive voting prompt for the currently playing track."
7
7
 
8
- usage "radio vote"
8
+ usage "radio vote [--all]"
9
9
  usage "radio vote --help"
10
10
 
11
+ option "-a --all", "Show all voting options"
12
+
11
13
  def run(args)
12
14
  needs :network, :channel, :session_key
13
15
 
16
+ prompt_style = args['--all'] ? :menu : :simple
17
+
14
18
  NowCmd.new.run args
15
19
  puts ""
16
- answer = get_user_vote
17
- unless answer == :abort
20
+ answer = get_user_vote style: prompt_style
21
+ unless answer == :cancel
18
22
  say "Voting... "
19
23
  current_channel.vote answer
20
24
  resay "!txtgrn!Voted"
@@ -23,12 +27,25 @@ module AudioAddict
23
27
 
24
28
  private
25
29
 
26
- def get_user_vote
30
+ def get_user_vote(style: :menu)
31
+ if style == :menu
32
+ menu_prompt
33
+ else
34
+ simple_prompt
35
+ end
36
+ end
37
+
38
+ def menu_prompt
27
39
  options = { "Like" => :up, "Dislike" => :down,
28
- "Unvote" => :delete, "Abort" => :abort }
40
+ "Unvote" => :delete, "Cancel" => :cancel }
29
41
  prompt.select "Your Vote :", options, marker: '>'
30
42
  end
31
43
 
44
+ def simple_prompt
45
+ like = prompt.yes? "Like?"
46
+ like ? :up : :cancel
47
+ end
48
+
32
49
  end
33
50
  end
34
51
  end
@@ -2,9 +2,23 @@ module AudioAddict
2
2
  class Error < StandardError; end
3
3
 
4
4
  class Interrupt < Error; end
5
+
5
6
  class ArgumentError < Error; end
6
- class ConfigError < Error; end
7
- class PremiumAccount < Error; end
7
+
8
+ class ConfigError < Error
9
+ attr_reader :missing_keys
10
+
11
+ def initialize(missing_keys)
12
+ @missing_keys = missing_keys
13
+ super "Some parameters required by this operation are missing"
14
+ end
15
+ end
16
+
17
+ class PremiumAccount < Error
18
+ def initialize(message="This operation requires a premium account")
19
+ super
20
+ end
21
+ end
8
22
 
9
23
  class APIError < Error
10
24
  attr_reader :response
@@ -1,3 +1,3 @@
1
1
  module AudioAddict
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_addict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -113,6 +113,7 @@ files:
113
113
  - lib/audio_addict/commands/base.rb
114
114
  - lib/audio_addict/commands/channels.rb
115
115
  - lib/audio_addict/commands/config.rb
116
+ - lib/audio_addict/commands/log.rb
116
117
  - lib/audio_addict/commands/login.rb
117
118
  - lib/audio_addict/commands/now.rb
118
119
  - lib/audio_addict/commands/playlist.rb