dl 1.1.0 → 1.2.0

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.
Files changed (4) hide show
  1. data/bin/dl +7 -0
  2. data/lib/dl.rb +10 -1
  3. data/lib/dl/dl.rb +5 -1
  4. metadata +1 -1
data/bin/dl CHANGED
@@ -21,8 +21,15 @@ Where [options] are:
21
21
  EOS
22
22
  opt :raw, "Don't save downloaded data to disk, simply print it to standard output."
23
23
  opt :quiet, "Don't output any download status info."
24
+ opt :file, "Output to a specific filename, will not work in conjunction with the --raw option.", :type => :string
25
+ end
26
+
27
+ if opts[:raw] == true and opts[:file] != nil
28
+ puts "Error: --raw and --file cannot be used in conjunction"
29
+ exit 1
24
30
  end
25
31
 
26
32
  Dl::be_quiet = opts[:quiet]
33
+ Dl::file = opts[:file]
27
34
 
28
35
  Dl::download ARGV[0], opts[:raw]
data/lib/dl.rb CHANGED
@@ -3,9 +3,18 @@ require 'patron'
3
3
  require 'dl/dl'
4
4
 
5
5
  module Dl
6
- VERSION = "1.1.0"
6
+ VERSION = "1.2.0"
7
7
 
8
8
  @@be_quiet = false
9
+ @@file = ""
10
+
11
+ def self.file
12
+ @@file
13
+ end
14
+
15
+ def self.file=(value)
16
+ @@file = value
17
+ end
9
18
 
10
19
  def self.be_quiet
11
20
  @@be_quiet
@@ -10,7 +10,11 @@ module Dl
10
10
  if raw == true
11
11
  puts response.body
12
12
  else
13
- filename = response.url.split('/').pop
13
+ if Dl::file != nil
14
+ filename = Dl::file
15
+ else
16
+ filename = response.url.split('/').pop
17
+ end
14
18
  output "Downloaded to file #{filename}!"
15
19
  File.new(filename, 'w').write(response.body)
16
20
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Szymanski