nehm 1.5.1 → 1.5.2

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
  SHA1:
3
- metadata.gz: 522fa489786504c1af992b0e72d4bace47c06243
4
- data.tar.gz: 645a69728cbecb7cd384189e044df8753a6e8377
3
+ metadata.gz: b08eefd3115d43cbe5cd3668fc4dcab6b2393b52
4
+ data.tar.gz: c1f896f13a89eeac413c7f3dc7f4be5341bc8dcd
5
5
  SHA512:
6
- metadata.gz: 2a68159c8bd5a1387fb21f1339d73af9c61a3586afa0cf5f7eeb12eac475a6f25f43b48dcbf22742af5aa793eae27755d919c5d54926954bca62c4e77ddde811
7
- data.tar.gz: 9e849f3554f6c3e9b4ad3a4e7de3489cc7f8f5bfe6c65ad7f852398eb4bcc37dc16420a6379e4e0182b7c6da65381d796c46871e4a7d072504a4e9d506d10df4
6
+ metadata.gz: bb02cb4c2974269b3de4c6d2e661f1e9b4e00b5e25fd4c3936bc4ccd806bfed6aad887681542bae3602010738e426e4c894a8861e2da738bd3689a0bb1d96445
7
+ data.tar.gz: f88c3e0575446c42bee43d55b2394275c5f83525994eae2732f3b09d749fa63b4291efde25d073d04cac340a66d24581a175b0291baf784c107c353dca85f2b3
@@ -1,5 +1,9 @@
1
1
  # nehm change log
2
2
 
3
+ ## 1.5.2
4
+ * Binary now works if you use nehm from source
5
+ * Minor improvements
6
+
3
7
  ## 1.5.1
4
8
  * Update `nehm help`
5
9
  * Fix some descriptions
data/bin/nehm CHANGED
@@ -1,3 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ nehm_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(nehm_dir) unless $LOAD_PATH.include?(nehm_dir)
2
4
  require 'nehm'
5
+
3
6
  App.do(ARGV)
@@ -61,6 +61,6 @@ module App
61
61
  end
62
62
 
63
63
  def initialized?
64
- File.exist?(File.join(ENV['HOME'], '.nehmconfig'))
64
+ File.exist?(Cfg::FILE_PATH)
65
65
  end
66
66
  end
@@ -1,41 +1,27 @@
1
- require 'yaml'
1
+ require 'bogy'
2
2
 
3
3
  # Cfg module manipulate with nehm's config file (~/.nehmconfig)
4
4
  module Cfg
5
+ FILE_PATH = File.join(ENV['HOME'], '.nehmconfig')
6
+ CONFIG_FILE = Bogy.new(file: FILE_PATH)
7
+
5
8
  def self.[](key)
6
- config_hash = load_config
7
- config_hash[key.to_s]
9
+ CONFIG_FILE[key.to_s]
8
10
  end
9
11
 
10
12
  def self.[]=(key, value)
11
- config_hash = load_config
12
- config_hash[key.to_s] = value
13
- save_config(config_hash)
13
+ CONFIG_FILE[key.to_s] = value
14
14
  end
15
15
 
16
16
  def self.create
17
- File.open(file_path, 'w+') { |f| f.write("---\napp: nehm") }
17
+ File.open(FILE_PATH, 'w+') { |f| f.write("---\napp: nehm") }
18
18
  end
19
19
 
20
20
  def self.exist?
21
- File.exist?(file_path)
21
+ File.exist?(FILE_PATH)
22
22
  end
23
23
 
24
24
  def self.key?(key)
25
- load_config.key?(key.to_s)
26
- end
27
-
28
- module_function
29
-
30
- def file_path
31
- File.join(ENV['HOME'], '.nehmconfig')
32
- end
33
-
34
- def load_config
35
- YAML.load_file(file_path)
36
- end
37
-
38
- def save_config(config_hash)
39
- IO.write(file_path, config_hash.to_yaml)
25
+ CONFIG_FILE.to_h.key?(key.to_s)
40
26
  end
41
27
  end
@@ -1,5 +1,4 @@
1
1
  require 'taglib'
2
- require 'fileutils'
3
2
 
4
3
  # TrackUtils module responds to 'nehm get/dl ...' commands
5
4
  module Get
@@ -1,16 +1,18 @@
1
1
  # Help module responds to 'nehm help ...' command
2
2
  module Help
3
3
  def self.available_commands
4
- puts Paint['Avalaible nehm commands:', :yellow]
5
- puts ' ' + Paint['get', :green] + ' Downloading, setting tags and adding to your iTunes library last post or like from your profile'
6
- puts ' ' + Paint['dl', :green] + ' Downloading and setting tags last post or like from your profile'
7
- puts ' ' + Paint['configure', :green] + ' Configuring application'
8
- puts "See #{Paint['nehm help [command]', :yellow]} to read about a specific subcommand"
4
+ puts <<-HELP.gsub(/^ {6}/, '')
5
+ #{Paint['Avalaible nehm commands:', :yellow]}
6
+ #{Paint['get', :green]} Downloading, setting tags and adding to your iTunes library last post or like from your profile
7
+ #{Paint['dl', :green]} Downloading and setting tags last post or like from your profile
8
+ #{Paint['configure', :green]} Configuring application
9
+ See #{Paint['nehm help [command]', :yellow]} to read about a specific subcommand
10
+ HELP
9
11
  end
10
12
 
11
13
  def self.show(command)
12
14
  case command
13
- when 'get', 'dl', 'configure'
15
+ when 'get', 'dl', 'configure', 'permalink'
14
16
  Help.send(command)
15
17
  when nil
16
18
  Help.available_commands
@@ -24,54 +26,62 @@ module Help
24
26
  module_function
25
27
 
26
28
  def configure
27
- puts Paint['Input: ', :yellow] + 'nehm configure'
28
- puts "\n"
29
- puts Paint['Summary:', :yellow]
30
- puts ' Configuring nehm app'
29
+ puts <<-CONFIGURE.gsub(/^ {6}/, '')
30
+ #{Paint['Input:', :yellow]} nehm configure
31
+
32
+ #{Paint['Summary:', :yellow]}
33
+ Configuring nehm app
34
+ CONFIGURE
31
35
  end
32
36
 
33
37
  def dl
34
- puts Paint['Input: ', :yellow] + 'nehm dl OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]'
35
- puts "\n"
36
- puts Paint['Summary:', :yellow]
37
- puts ' Downloading tracks from SoundCloud and setting tags'
38
- puts "\n"
39
- puts Paint['OPTIONS:', :yellow]
40
- puts ' ' + Paint['post', :green] + ' Do same with last post (track or repost) from your profile'
41
- puts ' ' + Paint['<number> posts', :green] + ' Do same with last <number> posts from your profile'
42
- puts ' ' + Paint['like', :green] + ' Do same with your last like'
43
- puts ' ' + Paint['<number> likes', :green] + ' Do same with your last <number> likes'
44
- puts ' ' + Paint['url', :magenta] + ' Do same with track from entered url'
45
- puts "\n"
46
- puts Paint['Extra options:', :yellow]
47
- puts ' ' + Paint['from PERMALINK', :green] + ' Do aforecited operations from custom user profile'
48
- puts ' ' + Paint['to PATH_TO_DIRECTORY', :green] + ' Do aforecited operations to custom directory'
49
- puts ' ' + Paint['to current', :green] + ' Do aforecited operations to current working directory'
50
- puts ' ' + Paint['playlist ITUNES_PLAYLIST', :green] + ' Do aforecited operations to custom iTunes playlist'
38
+ puts <<-DL.gsub(/^ {6}/, '')
39
+ #{Paint['Input:', :yellow]} nehm dl OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]
40
+
41
+ #{Paint['Summary:', :yellow]}
42
+ Downloading tracks from SoundCloud and setting tags
43
+
44
+ #{Paint['OPTIONS:', :yellow]}
45
+ #{Paint['post', :green]} Do same with last post (track or repost) from your profile
46
+ #{Paint['<number> posts', :green]} Do same with last <number> posts from your profile
47
+ #{Paint['like', :green]} Do same with your last like
48
+ #{Paint['<number> likes', :green]} Do same with your last <number> likes
49
+ #{Paint['url', :magenta]} Do same with track from entered url
50
+
51
+ #{Paint['Extra options:', :yellow]}
52
+ #{Paint['from PERMALINK', :green]} Do aforecited operations from custom user profile
53
+ #{Paint['to PATH_TO_DIRECTORY', :green]} Do aforecited operations to custom directory
54
+ #{Paint['to current', :green]} Do aforecited operations to current working directory
55
+ #{Paint['playlist ITUNES_PLAYLIST', :green]} Do aforecited operations to custom iTunes playlist
56
+ DL
51
57
  end
52
58
 
53
59
  def get
54
- puts Paint['Input: ', :yellow] + 'nehm get OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]'
55
- puts "\n"
56
- puts Paint['Summary:', :yellow]
57
- puts ' Downloading tracks, setting tags and adding to your iTunes library tracks from Soundcloud'
58
- puts "\n"
59
- puts Paint['OPTIONS:', :yellow]
60
- puts ' ' + Paint['post', :green] + ' Do same with last post (track or repost) from your profile'
61
- puts ' ' + Paint['<number> posts', :green] + ' Do same with last <number> posts from your profile'
62
- puts ' ' + Paint['like', :green] + ' Do same with your last like'
63
- puts ' ' + Paint['<number> likes', :green] + ' Do same with your last <number> likes'
64
- puts ' ' + Paint['url', :magenta] + ' Do same with track from entered url'
65
- puts "\n"
66
- puts Paint['Extra options:', :yellow]
67
- puts ' ' + Paint['from PERMALINK', :green] + ' Do aforecited operations from profile with PERMALINK'
68
- puts ' ' + Paint['to PATH_TO_DIRECTORY', :green] + ' Do aforecited operations to custom directory'
69
- puts ' ' + Paint['to current', :green] + ' Do aforecited operations to current working directory'
70
- puts ' ' + Paint['playlist ITUNES_PLAYLIST', :green] + ' Do aforecited operations to custom iTunes playlist'
60
+ puts <<-GET.gsub(/^ {6}/, '')
61
+ #{Paint['Input:', :yellow]} nehm get OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]
62
+
63
+ #{Paint['Summary:', :yellow]}
64
+ Downloading tracks, setting tags and adding to your iTunes library tracks from Soundcloud
65
+
66
+ #{Paint['OPTIONS:', :yellow]}
67
+ #{Paint['post', :green]} Do same with last post (track or repost) from your profile
68
+ #{Paint['<number> posts', :green]} Do same with last <number> posts from your profile
69
+ #{Paint['like', :green]} Do same with your last like
70
+ #{Paint['<number> likes', :green]} Do same with your last <number> likes
71
+ #{Paint['url', :magenta]} Do same with track from entered url
72
+
73
+ #{Paint['Extra options:', :yellow]}
74
+ #{Paint['from PERMALINK', :green]} Do aforecited operations from profile with PERMALINK
75
+ #{Paint['to PATH_TO_DIRECTORY', :green]} Do aforecited operations to custom directory
76
+ #{Paint['to current', :green]} Do aforecited operations to current working directory
77
+ #{Paint['playlist ITUNES_PLAYLIST', :green]} Do aforecited operations to custom iTunes playlist
78
+ GET
71
79
  end
72
80
 
73
81
  def permalink
74
- puts 'Permalink is the last word in your profile url'
75
- puts 'Example: for profile url ' + Paint['soundcloud.com/qwerty', :magenta] + ' permalink is ' + Paint['qwerty', :magenta]
82
+ puts <<-PERM.gsub(/^ {6}/, '')
83
+ Permalink is the last word in your profile url
84
+ Example: for profile url #{Paint['soundcloud.com/qwerty', :magenta]} permalink is #{Paint['qwerty', :magenta]}
85
+ PERM
76
86
  end
77
87
  end
@@ -1,4 +1,7 @@
1
1
  module UserControl
2
+ def self.user
3
+ @temp_user || default_user
4
+ end
2
5
 
3
6
  def self.logged_in?
4
7
  Cfg.key?(:default_id)
@@ -7,9 +10,8 @@ module UserControl
7
10
  def self.log_in
8
11
  loop do
9
12
  permalink = HighLine.new.ask('Please enter your permalink (last word in your profile url): ')
10
- url = "https://soundcloud.com/#{permalink}"
11
- if user_exist?(permalink)
12
- user = Client.get('/resolve', url: url)
13
+ user = get_user(permalink)
14
+ if user
13
15
  Cfg[:default_id] = user.id
14
16
  Cfg[:permalink] = permalink
15
17
  puts Paint['Successfully logged in!', :green]
@@ -21,8 +23,8 @@ module UserControl
21
23
  end
22
24
 
23
25
  def self.temp_user=(permalink)
24
- if user_exist?(permalink)
25
- user = Client.get('/resolve', url: "https://soundcloud.com/#{permalink}")
26
+ user = get_user(permalink)
27
+ if user
26
28
  @temp_user = User.new(user.id)
27
29
  else
28
30
  puts Paint['Invalid permalink. Please enter correct permalink', :red]
@@ -30,10 +32,6 @@ module UserControl
30
32
  end
31
33
  end
32
34
 
33
- def self.user
34
- @temp_user || default_user
35
- end
36
-
37
35
  module_function
38
36
 
39
37
  def default_user
@@ -46,16 +44,16 @@ module UserControl
46
44
  end
47
45
  end
48
46
 
49
- def user_exist?(permalink)
50
- Client.get('/resolve', url: "https://soundcloud.com/#{permalink}")
51
-
47
+ def get_user(permalink)
48
+ begin
49
+ user = Client.get('/resolve', url: "https://soundcloud.com/#{permalink}")
52
50
  rescue SoundCloud::ResponseError => e
53
51
  if e.message =~ /404/
54
- false
52
+ user = nil
55
53
  else
56
54
  raise e
57
55
  end
58
- else
59
- true
56
+ end
57
+ user
60
58
  end
61
59
  end
@@ -1,3 +1,3 @@
1
1
  module Nehm
2
- VERSION = '1.5.1'.freeze
2
+ VERSION = '1.5.2'.freeze
3
3
  end
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'highline', '>= 1.7.2'
27
27
  spec.add_dependency 'certifi'
28
28
  spec.add_dependency 'paint'
29
+ spec.add_dependency 'bogy'
29
30
  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: 1.5.1
4
+ version: 1.5.2
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-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: soundcloud
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bogy
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: " nehm is a console tool, which downloads, sets IDv3 tags and adds to
98
112
  your iTunes library your SoundCloud posts or likes in convenient way. See homepage
99
113
  for instructions "