downlow 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ Downloading files on the DL
8
8
 
9
9
  Tested against Ruby 1.8.7 and 1.9.1
10
10
 
11
- == Usage
11
+ == What
12
12
 
13
13
  Why is downloading and extracting files such a pain in Ruby?
14
14
 
@@ -37,6 +37,36 @@ BONUS BEATS FOR GITHUB
37
37
  Downloads the tarball and extracts.
38
38
 
39
39
  >> DL('gh://quirkey/sammy', ~/Desktop')
40
+
41
+
42
+ == Usage
43
+
44
+ Downlow is comprised of two main features: Fetchers and Extractors.
45
+ They do what they sound like they do.
46
+
47
+ To just fetch a remote (or local file or directory)
48
+
49
+ Downlow::Fetcher.fetch('remote', :destination => 'local')
50
+
51
+ Fetcher currently handles these styles of URL
52
+
53
+ Git (git://)
54
+ HTTP (http://)
55
+ Github (gh://user/project)
56
+ Local (anything else)
57
+
58
+ Extractors take a local file, and extract them based on their extension:
59
+
60
+ Downlow::Extractor.extract('local.archive', :destination => 'directory')
61
+
62
+ The extractors currently supported are
63
+
64
+ .tar.gz
65
+ .zip
66
+ dir (everything else)
67
+
68
+ DL() is just an alias for Downlow.get() which is just a wrapper around
69
+ .fetch() and then .extract()
40
70
 
41
71
  == Thanks
42
72
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{downlow}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = %q{2010-01-31}
12
+ s.date = %q{2010-02-19}
13
13
  s.description = %q{Downlow provides an easy way to fetch files or archives and extract them with minimal hassle.}
14
14
  s.email = %q{aaron@quirkey.com}
15
15
  s.extra_rdoc_files = [
@@ -1,7 +1,7 @@
1
1
  require 'downlow/ext/pathname'
2
2
 
3
3
  module Downlow
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
 
6
6
  def self.get(url, *args)
7
7
  options = {}
@@ -1,14 +1,18 @@
1
1
  module Downlow
2
2
  class Extractor
3
3
 
4
- def self.handles(which)
4
+ def self.handles(which, options = {})
5
5
  @@handlers ||= []
6
- @@handlers << [which, self]
6
+ @@handlers << [which, options, self]
7
7
  end
8
8
 
9
9
  def self.extractor_for(path)
10
- @@handlers.each do |matcher, klass|
11
- return klass if matcher.match path
10
+ @@handlers.each do |matcher, options, klass|
11
+ if options[:file_only] && !File.file?(path)
12
+ next
13
+ else
14
+ return klass if matcher.match(path)
15
+ end
12
16
  end
13
17
  end
14
18
 
@@ -4,7 +4,7 @@ require 'archive/tar/minitar'
4
4
  module Downlow
5
5
  class TarGz < Extractor
6
6
 
7
- handles(/\.tar\.gz$/)
7
+ handles(/\.tar\.gz$/, :file_only => true)
8
8
 
9
9
  def extract
10
10
  destination.mkpath
@@ -3,7 +3,7 @@ require 'zip/zip'
3
3
  module Downlow
4
4
  class Zip < Extractor
5
5
 
6
- handles(/\.zip$/)
6
+ handles(/\.zip$/, :file_only => true)
7
7
 
8
8
  def extract
9
9
  ::Zip::ZipFile.foreach(path) do |file|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: downlow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Quint
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-31 00:00:00 -05:00
12
+ date: 2010-02-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency