nehm 1.0.5 → 1.0.6

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: 30b7af70280e2a89ed90949bd3479a50121974de
4
- data.tar.gz: 1c824ca32b37501388ed2045972c075d717ae750
3
+ metadata.gz: fbd0359788a4269a83d34e129ecac922ca5d323f
4
+ data.tar.gz: 12081c404cc2274639d6b9a21e46b2692bcc9c20
5
5
  SHA512:
6
- metadata.gz: 254c4d7a1bcfcd2436002f722b8f38d5300c547724c14c9b830f526770d7fb300790320601c5b6c9953adf4a0b43f519f70d10c8edfee6ba8076ea4f8412828b
7
- data.tar.gz: d1de57366a23efc66aa73d56ef3c091feb22f2772d17e515f6bec4eb48fbdf2fbfb23ee5ac187113cb4c41097b213205bb74906886602f7bb68523f609628b80
6
+ metadata.gz: 33f2c6ea8f259d2e302a25e46d439e5a7b21491642b812fca6ff7cc241bfaa2d58ac590ad06ee762b27b63e8efb0b484bdb48e06e242ce87196e6f09a8f7da55
7
+ data.tar.gz: 2a2884f2ad85b63331989c25e045d47f2de03b8400173e0ef871c7bc0168d2b8fdce98496fab98abd7f0a456eef34c4420d169d78879a34bcef11338046b8e6f
@@ -0,0 +1,35 @@
1
+ # nehm Change Log
2
+
3
+ ## 1.0.5
4
+
5
+ * Fix bundler development dependency
6
+
7
+ ## 1.0.4
8
+
9
+ * Edit summary in gemspec
10
+
11
+ ## 1.0.3
12
+
13
+ * Change description of nehm
14
+
15
+ ## 1.0.2
16
+
17
+ * Edit path to nehm version in Rakefile
18
+
19
+ * Fix: nehm fails, then setting tags to track
20
+
21
+ ## 1.0.1
22
+
23
+ * Rakefile:
24
+
25
+ * Add push (push to rubygems.org) task
26
+
27
+ * Modify tasks
28
+
29
+ * Edit required Ruby version
30
+
31
+ * Fix: if you invalid argument in 'nehm get', then app fails
32
+
33
+ ## 1.0
34
+
35
+ * First release!
@@ -6,6 +6,7 @@ require_relative 'nehm/config.rb'
6
6
  require_relative 'nehm/configure.rb'
7
7
  require_relative 'nehm/help.rb'
8
8
  module App
9
+
9
10
  # Public
10
11
 
11
12
  def self.do(args)
@@ -1,3 +1,4 @@
1
+ # Artwork objects contains all needed information of track's artwork
1
2
  class Artwork
2
3
  def initialize(track)
3
4
  @track = track
@@ -1,8 +1,9 @@
1
1
  require 'soundcloud'
2
2
  require_relative 'config.rb'
3
3
 
4
+ # Just a Soundcloud API client.
4
5
  module Client
5
- # SSL Certificate
6
+ # Set a SSL certificate file path for SC API
6
7
  ENV['SSL_CERT_FILE'] = File.join(__dir__, 'cacert.pem')
7
8
 
8
9
  CLIENT_ID = '11a37feb6ccc034d5975f3f803928a32'
@@ -1,6 +1,8 @@
1
1
  require 'yaml'
2
2
 
3
+ # Config module manipulate with nehm's config file (~/.nehmconfig)
3
4
  module Config
5
+
4
6
  # Public
5
7
 
6
8
  def self.[](key)
@@ -5,6 +5,7 @@ require_relative 'os.rb'
5
5
  require_relative 'config.rb'
6
6
  require_relative 'path_control.rb'
7
7
 
8
+ # Configure module responds to 'nehm configure' command
8
9
  module Configure
9
10
  def self.menu
10
11
  puts 'Download path: ' + Paint[PathControl.dl_path, :magenta]
@@ -1,3 +1,4 @@
1
+ # Help module responds to 'nehm help ...' command
1
2
  module Help
2
3
 
3
4
  # Public
@@ -23,23 +24,15 @@ module Help
23
24
 
24
25
  module_function
25
26
 
26
- def permalink
27
- puts 'Permalink is the last word in your profile url'
28
- puts 'Example: for profile url ' + Paint['soundcloud.com/qwerty', :magenta] + ' permalink is ' + Paint['qwerty', :magenta]
29
- end
30
-
31
- def get
32
- puts Paint['Input: ', :yellow] + 'nehm get [options]'
27
+ def configure
28
+ puts Paint['Input: ', :yellow] + 'nehm configure'
33
29
 
34
30
  puts Paint['Available options:', :yellow]
35
- puts ' ' + Paint['track', :green] + ' - Downloading, setting tags and adding to your iTunes library last post(track or repost) from your profile'
36
- puts ' ' + Paint['[number] tracks', :green] + ' - Downloading, setting tags and adding to your iTunes library last [number] posts from your profile'
37
- puts ' ' + Paint['like', :green] + ' - Downloading, setting tags and adding to your iTunes library your last like'
38
- puts ' ' + Paint['[number] likes', :green] + ' - Downloading, setting tags and adding to your iTunes library your last [number] likes'
31
+ puts ' No options'
39
32
  end
40
33
 
41
34
  def dl
42
- puts Paint['Input: ', :yellow] + 'nehm dl [options]'
35
+ puts Paint['Input: ', :yellow] + 'nehm dl OPTIONS'
43
36
 
44
37
  puts Paint['Available options:', :yellow]
45
38
  puts ' ' + Paint['track', :green] + ' - Downloading and setting tags last post(track or repost) from your profile'
@@ -48,10 +41,19 @@ module Help
48
41
  puts ' ' + Paint['[number] likes', :green] + ' - Downloading and setting tags your last [number] likes'
49
42
  end
50
43
 
51
- def configure
52
- puts Paint['Input: ', :yellow] + 'nehm configure'
44
+ def get
45
+ puts Paint['Input: ', :yellow] + 'nehm get OPTIONS'
53
46
 
54
47
  puts Paint['Available options:', :yellow]
55
- puts ' No options'
48
+ puts ' ' + Paint['track', :green] + ' - Downloading, setting tags and adding to your iTunes library last post(track or repost) from your profile'
49
+ puts ' ' + Paint['[number] tracks', :green] + ' - Downloading, setting tags and adding to your iTunes library last [number] posts from your profile'
50
+ puts ' ' + Paint['like', :green] + ' - Downloading, setting tags and adding to your iTunes library your last like'
51
+ puts ' ' + Paint['[number] likes', :green] + ' - Downloading, setting tags and adding to your iTunes library your last [number] likes'
56
52
  end
53
+
54
+ def permalink
55
+ puts 'Permalink is the last word in your profile url'
56
+ puts 'Example: for profile url ' + Paint['soundcloud.com/qwerty', :magenta] + ' permalink is ' + Paint['qwerty', :magenta]
57
+ end
58
+
57
59
  end
@@ -18,15 +18,6 @@ class Track
18
18
  end
19
19
  end
20
20
 
21
- def title
22
- if @hash['title'].include?('-')
23
- title = @hash['title'].split('-')
24
- title[1].lstrip
25
- else
26
- @hash['title']
27
- end
28
- end
29
-
30
21
  def artwork
31
22
  Artwork.new(self)
32
23
  end
@@ -46,4 +37,14 @@ class Track
46
37
  def id
47
38
  @hash['id'].to_s
48
39
  end
40
+
41
+ def title
42
+ if @hash['title'].include?('-')
43
+ title = @hash['title'].split('-')
44
+ title[1].lstrip
45
+ else
46
+ @hash['title']
47
+ end
48
+ end
49
+
49
50
  end
@@ -7,7 +7,9 @@ require_relative 'user.rb'
7
7
  require_relative 'track.rb'
8
8
  require_relative 'os.rb'
9
9
 
10
+ # TrackUtils module responds to 'nehm get/dl ...' commands
10
11
  module TrackUtils
12
+
11
13
  # Public
12
14
 
13
15
  def self.get(dl, args)
@@ -16,16 +18,21 @@ module TrackUtils
16
18
  case args.last
17
19
  when 'like'
18
20
  User.new.likes(1)
21
+
19
22
  when 'post'
20
23
  User.new.posts(1)
24
+
21
25
  when 'likes'
22
26
  count = args[-2].to_i
23
27
  User.new.likes(count)
28
+
24
29
  when 'posts'
25
30
  count = args[-2].to_i
26
31
  User.new.posts(count)
32
+
27
33
  when %r{https:\/\/soundcloud.com\/}
28
34
  track_from_url(args.last)
35
+
29
36
  else
30
37
  puts Paint['Invalid argument(s)', :red]
31
38
  puts "Input #{Paint['nehm help', :yellow]} for help"
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
  require 'faraday'
3
+ require 'paint'
3
4
  require_relative 'client.rb'
4
5
  require_relative 'config.rb'
5
6
  require_relative 'user_control.rb'
@@ -17,12 +18,22 @@ class User
17
18
  end
18
19
 
19
20
  def likes(count)
21
+ unless count.class == Fixnum
22
+ puts Paint['Invalid number of likes!', :red]
23
+ exit
24
+ end
25
+
20
26
  client = Client.new
21
27
  likes = client.get("/users/#{@id}/favorites?limit=#{count}")
22
28
  likes.map { |like| Track.new(like) }
23
29
  end
24
30
 
25
31
  def posts(count)
32
+ unless count.class == Fixnum
33
+ puts Paint['Invalid number of posts!', :red]
34
+ exit
35
+ end
36
+
26
37
  conn = Faraday.new(url: 'https://api-v2.soundcloud.com/') do |faraday|
27
38
  faraday.request :url_encoded # form-encode POST params
28
39
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
@@ -4,38 +4,18 @@ require_relative 'config.rb'
4
4
  require_relative 'client.rb'
5
5
 
6
6
  module UserControl
7
- def self.logged_in?
8
- Config.key?(:default_id)
9
- end
10
-
11
- def self.log_in
12
- loop do
13
- permalink = HighLine.new.ask('Please enter your permalink (last word in your profile url): ')
14
- client = Client.new
15
- url = "https://soundcloud.com/#{permalink}"
16
- if UserControl.exist?(url)
17
- user = client.get('/resolve', url: url)
18
- Config[:default_id] = user.id
19
- Config[:permalink] = permalink
20
- puts Paint['Successfully logged in!', :green]
21
- break
22
- else
23
- puts Paint['Invalid permalink. Please enter correct permalink', :red]
24
- end
25
- end
26
- end
27
7
 
28
8
  def self.default_id
29
9
  if UserControl.logged_in?
30
10
  Config[:default_id]
31
11
  else
32
- puts "You didn't logged in"
12
+ puts Paint["You didn't logged in", :red]
33
13
  puts "Input #{Paint['nehm configure', :yellow]} to login"
34
14
  exit
35
15
  end
36
16
  end
37
17
 
38
- def self.exist?(url)
18
+ def self.user_exist?(url)
39
19
  Client.new.get('/resolve', url: url)
40
20
  rescue SoundCloud::ResponseError => e
41
21
  if e.message =~ /404/
@@ -46,4 +26,25 @@ module UserControl
46
26
  else
47
27
  true
48
28
  end
29
+
30
+ def self.logged_in?
31
+ Config.key?(:default_id)
32
+ end
33
+
34
+ def self.log_in
35
+ loop do
36
+ permalink = HighLine.new.ask('Please enter your permalink (last word in your profile url): ')
37
+ client = Client.new
38
+ url = "https://soundcloud.com/#{permalink}"
39
+ if UserControl.user_exist?(url)
40
+ user = client.get('/resolve', url: url)
41
+ Config[:default_id] = user.id
42
+ Config[:permalink] = permalink
43
+ puts Paint['Successfully logged in!', :green]
44
+ break
45
+ else
46
+ puts Paint['Invalid permalink. Please enter correct permalink', :red]
47
+ end
48
+ end
49
+ end
49
50
  end
@@ -1,3 +1,3 @@
1
1
  module Nehm
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Albert Nigmatzianov']
10
10
  spec.email = ['albertnigma@gmail.com']
11
11
 
12
- spec.summary = %q{Convenient way to get tracks from SoundCloud via terminal}
13
- spec.description = %q{nehm is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way}
12
+ spec.summary = %q{ Convenient way to get tracks from SoundCloud via terminal }
13
+ spec.description = %q{ nehm is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way. See http://www.github.com/bogem/nehm for instructions }
14
14
  spec.homepage = 'http://www.github.com/bogem/nehm'
15
15
  spec.license = 'MIT'
16
16
 
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: 1.0.5
4
+ version: 1.0.6
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-07-17 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,8 +130,9 @@ dependencies:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: 1.7.2
133
- description: nehm is a console tool, which downloads, sets IDv3 tags and adds to your
134
- iTunes library your SoundCloud posts or likes in convenient way
133
+ description: " nehm is a console tool, which downloads, sets IDv3 tags and adds to
134
+ your iTunes library your SoundCloud posts or likes in convenient way. See http://www.github.com/bogem/nehm
135
+ for instructions "
135
136
  email:
136
137
  - albertnigma@gmail.com
137
138
  executables:
@@ -140,7 +141,7 @@ extensions: []
140
141
  extra_rdoc_files: []
141
142
  files:
142
143
  - ".gitignore"
143
- - ".travis.yml"
144
+ - CHANGELOG.md
144
145
  - Gemfile
145
146
  - LICENSE
146
147
  - README.md
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.1
7
- - 2.2.1
8
- before_install: gem install bundler -v 1.10.5