nehm 2.1.4 → 2.1.5

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: 77c9b630040b56e2cbedaa2be10a657e44ef156b
4
- data.tar.gz: 1d4bd72a0fbf335bccd513b490008046de41e99c
3
+ metadata.gz: 75ed072f758889011410959f8570e881a4f6fbb0
4
+ data.tar.gz: c7c9bc0647822e95e7d88768de2e3707030bda21
5
5
  SHA512:
6
- metadata.gz: 0153f57f582668008347ba610de269473682090cd4943f5e892f6b7653c5c6f31ffb67f8a6cb0178855515f3dfc673f287d2be1528c64c565776fd58b8ed03bc
7
- data.tar.gz: 854e80521be2013ea28a321ade2bc3b54c36f301e0edea602e1af464713682a2ca48638bfd2b28c88b73fc340d963239b666cc602fbe8fe19f0350d7f04bac51
6
+ metadata.gz: d2442ce4395f8198400dc5283e1b5898995945b1a755d5ef63b3ac58457e441203e2e98b0ea17c10cc103c5e03857ecbe94fce4375c02110aef68dc33552ffaa
7
+ data.tar.gz: 1a51ce91f3b24f49152210f2a838797953fd402658c6d15143fbab2a33f51c5c81febaab4a0408c8754b8186c058b173a3e566bbe935b8e050071ba33ef3ffc4
@@ -1,5 +1,9 @@
1
1
  # nehm change log
2
2
 
3
+ ## 2.1.5
4
+ * Remove `Getting information about tracks(s)` message in `get` and `dl` commands
5
+ * Handle more errors
6
+
3
7
  ## 2.1.4
4
8
  * Fix bug `wrong number of arguments (1 for 0)` in `configure` command or in first initialization
5
9
 
data/bin/nehm CHANGED
@@ -5,10 +5,4 @@ require 'nehm'
5
5
 
6
6
  $stderr = STDOUT
7
7
 
8
- begin
9
- Nehm.start(ARGV)
10
- rescue Interrupt # SIGINT
11
- Nehm::UI.term
12
- rescue StandardError, Timeout::Error => ex
13
- Nehm::UI.term "While executing nehm ... (#{ex.class})\n #{ex}"
14
- end
8
+ Nehm.start(ARGV)
@@ -12,15 +12,23 @@ require 'nehm/user_manager'
12
12
 
13
13
  module Nehm
14
14
 
15
+ class NehmExit < SystemExit; end
16
+
15
17
  def self.start(args)
16
18
  init unless initialized?
17
19
 
18
- if args.empty?
19
- UI.say HELP
20
- UI.term
20
+ begin
21
+ if args.empty?
22
+ UI.say HELP
23
+ UI.term
24
+ end
25
+
26
+ CommandManager.run(args)
27
+ rescue StandardError, Timeout::Error => ex
28
+ Nehm::UI.term "While executing nehm ... (#{ex.class})\n #{ex}"
29
+ rescue Interrupt
30
+ rescue NehmExit
21
31
  end
22
-
23
- CommandManager.run(args)
24
32
  end
25
33
 
26
34
  HELP = <<-EOF
@@ -59,7 +67,7 @@ EOF
59
67
  UI.newline
60
68
  end
61
69
 
62
- UI.success "Now you can use nehm!"
70
+ UI.success 'Now you can use nehm!'
63
71
  UI.newline
64
72
 
65
73
  UI.sleep
@@ -28,8 +28,6 @@ module Nehm
28
28
  # Returns raw array of likes or posts (depends on argument 'type')
29
29
 
30
30
  def self.tracks(count, offset, type, uid)
31
- UI.term "Invalid number of #{type}" if count == 0
32
-
33
31
  iterations = count.to_f / TRACKS_LIMIT
34
32
  iterations = iterations.ceil
35
33
 
@@ -55,9 +53,9 @@ module Nehm
55
53
  end
56
54
 
57
55
  ##
58
- # Returns track hash from SoundCloud by specified uri
56
+ # Returns hash from SoundCloud by specified uri
59
57
 
60
- def self.track(uri)
58
+ def self.resolve(uri)
61
59
  HTTP_CLIENT.resolve(uri)
62
60
  end
63
61
 
@@ -19,7 +19,6 @@ module Nehm
19
19
  def execute
20
20
  track_manager = TrackManager.new(@options)
21
21
 
22
- UI.say 'Getting information about track(s)'
23
22
  arg = @options[:args].pop
24
23
  tracks =
25
24
  case arg
@@ -28,7 +28,7 @@ module Nehm
28
28
  :"-lim" => :limit,
29
29
  :"-dl" => :dl }
30
30
 
31
- options_to_convert.each do |k,v|
31
+ options_to_convert.each do |k, v|
32
32
  value = @options[k]
33
33
  @options.delete(k)
34
34
  @options[v] = value unless value.nil?
@@ -33,9 +33,7 @@ module Nehm
33
33
  end
34
34
  end
35
35
 
36
- if response['status'] =~ /302/
37
- get_hash(response['location'])
38
- end
36
+ get_hash(response['location']) if response['status'] =~ /302/
39
37
  end
40
38
 
41
39
  private
@@ -26,7 +26,7 @@ module Nehm
26
26
  time = Time.at(seconds)
27
27
  time -= time.utc_offset
28
28
 
29
- time.hour > 0 ? time.strftime("%H:%M:%S") : time.strftime("%M:%S")
29
+ time.hour > 0 ? time.strftime('%H:%M:%S') : time.strftime('%M:%S')
30
30
  end
31
31
 
32
32
  def file_name
@@ -23,6 +23,9 @@ module Nehm
23
23
  end
24
24
 
25
25
  def likes(limit, offset)
26
+ UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0
27
+ UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0
28
+
26
29
  likes = Client.tracks(limit, offset, :likes, @uid)
27
30
  return nil if likes.empty?
28
31
 
@@ -31,6 +34,9 @@ module Nehm
31
34
  end
32
35
 
33
36
  def posts(limit, offset)
37
+ UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0
38
+ UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0
39
+
34
40
  posts = Client.tracks(limit, offset, :posts, @uid)
35
41
  return nil if posts.empty?
36
42
 
@@ -41,7 +47,9 @@ module Nehm
41
47
  end
42
48
 
43
49
  def track_from_url(url)
44
- track = [Client.track(url)]
50
+ track = [Client.resolve(url)]
51
+
52
+ UI.term 'Invalid URL! Please type link to track' if track.first['kind'] != 'track'
45
53
  return nil if track.empty?
46
54
 
47
55
  filter(track)
@@ -49,6 +57,9 @@ module Nehm
49
57
  end
50
58
 
51
59
  def search(query, limit, offset)
60
+ UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0
61
+ UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0
62
+
52
63
  found = Client.search(query, limit, offset)
53
64
  return nil if found.empty?
54
65
 
@@ -64,25 +64,8 @@ module Nehm
64
64
  end
65
65
 
66
66
  def setup_environment
67
- limit = @options[:limit]
68
- @limit =
69
- if limit
70
- limit = limit.to_i
71
- UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0
72
- limit
73
- else
74
- DEFAULT_LIMIT
75
- end
76
-
77
- offset = @options[:offset]
78
- @offset =
79
- if offset
80
- offset = offset.to_i
81
- UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0
82
- offset
83
- else
84
- DEFAULT_OFFSET
85
- end
67
+ @limit = @options[:limit] ? @options[:limit].to_i : DEFAULT_LIMIT
68
+ @offset = @options[:offset] ? @options[:offset].to_i : DEFAULT_OFFSET
86
69
  end
87
70
 
88
71
  def add_track_to_queue(track)
@@ -40,11 +40,8 @@ module Nehm
40
40
  end
41
41
 
42
42
  def self.term(msg = nil)
43
- if msg
44
- abort msg.red
45
- else
46
- exit
47
- end
43
+ puts msg.red if msg
44
+ raise NehmExit
48
45
  end
49
46
 
50
47
  def self.warning(msg)
@@ -1,3 +1,3 @@
1
1
  module Nehm
2
- VERSION = '2.1.4'.freeze
2
+ VERSION = '2.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nehm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Nigmatzianov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-14 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: certifi