nehm 1.3.1.1 → 1.3.2

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: 1406390ea3bcdf0427ddb52b66db2ffc92f84bc0
4
- data.tar.gz: 7075b0954b1e5c62e01b9f7dc3d67668c451f359
3
+ metadata.gz: 95154a08e75bc3f3d979e6b9b2b8eaea43a1dcbc
4
+ data.tar.gz: b99a099bde117d9aeb37e0a126556fe868ae0174
5
5
  SHA512:
6
- metadata.gz: 870dbd26dd929940305bcfb1570ee776e63edd06c8a823d35f2f6c805ff87beec8da3b82e5b05e2791cf5dea04bf47bb44e5500d728828ad83ad673ac56e962d
7
- data.tar.gz: 9d19efd2d5d80eb309be42632a5cbbdf39b5a465ce2b9d77241eba9ef1d33218bddd0555e7c5d57031b0ff022ffe66d0b1117519e18bcd62f89b5efd1fa372a6
6
+ metadata.gz: e080dd9062495fe1e086804c0427a5948210d27de8c86925dc6356df4dafbf160d3be6b0e74edb7f01f64acc2366915de3c68456a05c2fcf20d41c5acc0fcea7
7
+ data.tar.gz: 692221be13b3ef4380ed2c73a27c736d488c93664c3b76952a2cd1fe8ce85a9861267b3a221e0d3036a44635bda6f76d350556fa9b6852f577a130bec61879df
@@ -1,5 +1,9 @@
1
1
  # nehm change log
2
2
 
3
+ ## 1.3.2
4
+
5
+ * Add check for no user's posts/likes
6
+
3
7
  ## 1.3.1.1
4
8
 
5
9
  * Minor changes
@@ -7,27 +7,43 @@ class User
7
7
  end
8
8
 
9
9
  def likes(count)
10
- unless count.class == Fixnum
10
+ # Method to_i return 0, if there aren't any numbers in string
11
+ if count == 0
11
12
  puts Paint['Invalid number of likes!', :red]
12
13
  exit
13
14
  end
14
15
 
15
16
  likes = Client.get("/users/#{@id}/favorites?limit=#{count}")
17
+
18
+ if likes.empty?
19
+ puts Paint["There are no likes yet :(", :red]
20
+ exit
21
+ end
22
+
16
23
  likes.map { |hash| Track.new(hash) }
17
24
  end
18
25
 
19
- # Post is last track or repost in profile
26
+ # Post is last track/repost in profile
20
27
  def posts(count)
21
- unless count.class == Fixnum
28
+ # Method to_i return 0, if there aren't any numbers in string
29
+ if count == 0
22
30
  puts Paint['Invalid number of posts!', :red]
23
31
  exit
24
32
  end
25
33
 
34
+ # Official SC API wrapper doesn't support for posts
35
+ # So I should get posts by HTTP requests
26
36
  conn = Faraday.new(url: 'https://api-v2.soundcloud.com/')
27
37
  response = conn.get("/profile/soundcloud:users:#{@id}?limit=#{count}&offset=0")
28
38
 
29
39
  parsed = JSON.parse(response.body)
30
- parsed = parsed['collection']
31
- parsed.map { |hash| Track.new(hash['track']) }
40
+ posts = parsed['collection']
41
+
42
+ if posts.empty?
43
+ puts Paint["There are no posts yet :(", :red]
44
+ exit
45
+ end
46
+
47
+ posts.map { |hash| Track.new(hash['track']) }
32
48
  end
33
49
  end
@@ -1,3 +1,3 @@
1
1
  module Nehm
2
- VERSION = '1.3.1.1'
2
+ VERSION = '1.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nehm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Nigmatzianov