dl 1.0.0 → 1.1.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 (5) hide show
  1. data/.gitignore +1 -0
  2. data/bin/dl +3 -0
  3. data/lib/dl/dl.rb +8 -2
  4. data/lib/dl.rb +11 -1
  5. metadata +2 -2
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg/
2
+ .rake_tasks~
data/bin/dl CHANGED
@@ -20,6 +20,9 @@ Usage:
20
20
  Where [options] are:
21
21
  EOS
22
22
  opt :raw, "Don't save downloaded data to disk, simply print it to standard output."
23
+ opt :quiet, "Don't output any download status info."
23
24
  end
24
25
 
26
+ Dl::be_quiet = opts[:quiet]
27
+
25
28
  Dl::download ARGV[0], opts[:raw]
data/lib/dl/dl.rb CHANGED
@@ -2,7 +2,7 @@ module Dl
2
2
  def self.download(url, raw = false)
3
3
  session = Patron::Session.new
4
4
 
5
- puts "Downloading #{url}..."
5
+ output "Downloading #{url}..."
6
6
 
7
7
  response = session.get url
8
8
 
@@ -11,8 +11,14 @@ module Dl
11
11
  puts response.body
12
12
  else
13
13
  filename = response.url.split('/').pop
14
- puts "Downloaded to file #{filename}!"
14
+ output "Downloaded to file #{filename}!"
15
15
  File.new(filename, 'w').write(response.body)
16
16
  end
17
17
  end
18
+
19
+ private
20
+
21
+ def self.output(string)
22
+ puts string unless Dl::be_quiet == true
23
+ end
18
24
  end
data/lib/dl.rb CHANGED
@@ -3,5 +3,15 @@ require 'patron'
3
3
  require 'dl/dl'
4
4
 
5
5
  module Dl
6
- VERSION = "1.0.0"
6
+ VERSION = "1.1.0"
7
+
8
+ @@be_quiet = false
9
+
10
+ def self.be_quiet
11
+ @@be_quiet
12
+ end
13
+
14
+ def self.be_quiet=(value)
15
+ @@be_quiet = value
16
+ end
7
17
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Szymanski
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-16 00:00:00 Z
13
+ date: 2011-04-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: patron