cherrypicker 0.3.5 → 0.3.6

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.
data/README.md CHANGED
@@ -18,9 +18,18 @@ Usage
18
18
 
19
19
  require 'cherrypicker'
20
20
 
21
- Examples
21
+ Terminal Examples
22
22
  --------
23
+ Within your terminal type
24
+
25
+ cherrypick
26
+
27
+ cherrypick http://www.youtube.com/watch?v=I5DCwN28y8o -d "~/Movies"
28
+ cherrypick http://rapidshare.com/files/453165880/test_file.txt -u "karlentwistle" -p "foobar"
23
29
 
30
+
31
+ Gem Examples
32
+ --------
24
33
  test = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password")
25
34
  test.download
26
35
 
data/bin/cherrypick CHANGED
@@ -5,7 +5,7 @@ require 'getoptlong'
5
5
  require 'pathname'
6
6
 
7
7
  def usage()
8
- puts "Cherrypicker lets you download from; Rapidshare, Hotfile, Hotfile, Youtube, Vimeo & Megavideo"
8
+ puts "Cherrypicker lets you download from; Rapidshare, Hotfile, Youtube, Vimeo & Megavideo"
9
9
  puts "Usage: cherrypick link [--directory|-d] [--username|-u] [--password|-p]"
10
10
  puts
11
11
  puts "example: cherrypick http://www.youtube.com/watch?v=I5DCwN28y8o -d \"~/Movies\""
@@ -17,45 +17,19 @@ if not ARGV[0]
17
17
  exit
18
18
  end
19
19
 
20
+ #refactored by Hamac credit http://is.gd/sbxAwG
21
+ options = {username: nil, password: nil, directory: nil}
22
+
20
23
  parser = GetoptLong.new
21
- parser.set_options(
22
- ["-d", "--directory", GetoptLong::REQUIRED_ARGUMENT],
23
- ["-u", "--username", GetoptLong::REQUIRED_ARGUMENT],
24
- ["-p", "--password", GetoptLong::REQUIRED_ARGUMENT]
24
+ parser.set_options(*options.keys.map{|opt| ["--#{opt.to_s}", "-#{opt.to_s[0]}", GetoptLong::REQUIRED_ARGUMENT]}
25
25
  )
26
26
 
27
- username = ""
28
- password = ""
29
- directory = ""
30
-
31
- loop do
27
+ parser.each{|opt, arg| options[opt.gsub('--', '').to_sym] = arg unless arg == ''}
32
28
 
33
- opt, arg = parser.get
34
- break if not opt
35
-
36
- case opt
37
- when "-u"
38
- username = arg
39
- when "-p"
40
- password = arg
41
- when "-d"
42
- directory = arg
43
- end
44
-
29
+ if options[:directory] && !File.directory?(options[:directory]) then
30
+ puts "Directory not found " + directory
31
+ usage
32
+ exit
45
33
  end
46
-
47
- unless directory == "" || nil?
48
- p path = Pathname.new(directory)
49
-
50
- if not path.directory?
51
- puts "Directory not found " + path.to_s
52
- usage
53
- exit
54
- end
55
- end
56
-
57
- username = nil unless username != ""
58
- password = nil unless password != ""
59
- directory = nil unless directory != ""
60
-
61
- Cherrypicker::Cherrypick.new(ARGV[0], :location => directory, :username => username, :password => password)
34
+ s
35
+ Cherrypicker::Cherrypick.new(ARGV[0], :location => options[:directory], :username => options[:username], :password => options[:password])
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.5
5
+ version: 0.3.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Entwistle
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-23 00:00:00 +01:00
13
+ date: 2011-04-24 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency