pinch 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pinch.rb +41 -4
  2. metadata +31 -34
@@ -2,30 +2,66 @@
2
2
  require 'net/http'
3
3
  require 'zlib'
4
4
 
5
+ # @author Peter Hellberg
6
+ # @author Edward Patel
5
7
  class Pinch
6
- VERSION = "0.0.6"
8
+ VERSION = "0.0.7"
7
9
 
8
10
  attr_reader :uri
9
- attr_reader :file_name
10
11
 
12
+ ##
13
+ # Retrieve a file from inside a zip file, over the network!
14
+ #
15
+ # @param [String] url Full URL to the ZIP file
16
+ # @param [String] file_name Name of the file inside the ZIP archive
17
+ # @return [String] File data, ready to be displayed/saved
18
+ # @example
19
+ #
20
+ # puts Pinch.get('http://peterhellberg.github.com/pinch/test.zip', 'data.json')
21
+ #
11
22
  def self.get(url, file_name)
12
- new(url).data(file_name)
23
+ new(url).get(file_name)
13
24
  end
14
25
 
26
+ ##
27
+ # List of files inside the zip file
28
+ #
29
+ # @param [String] url Full URL to the ZIP file
30
+ # @return [Array] List of all the files in the ZIP archive
31
+ # @example
32
+ #
33
+ # Pinch.file_list('http://peterhellberg.github.com/pinch/test.zip').first #=> "data.json"
34
+ #
15
35
  def self.file_list(url)
16
36
  new(url).file_list
17
37
  end
18
38
 
39
+ ##
40
+ # Initializes a new Pinch object
41
+ #
42
+ # @param [String] url Full URL to the ZIP file
43
+ # @note You might want to use Pinch#get instead.
44
+ #
19
45
  def initialize(url)
20
46
  @uri = URI.parse(url)
21
47
  @files = {}
22
48
  end
23
49
 
50
+ ##
51
+ # @note You might want to use Pinch#file_list instead.
52
+ #
24
53
  def file_list
25
54
  file_headers.keys
26
55
  end
27
56
 
28
- def data(file_name)
57
+ ##
58
+ # @example
59
+ #
60
+ # puts Pinch.new('http://peterhellberg.github.com/pinch/test.zip').get('data.json')
61
+ #
62
+ # @note You might want to use Pinch#get instead
63
+ #
64
+ def get(file_name)
29
65
  local_file(file_name)
30
66
  end
31
67
 
@@ -77,6 +113,7 @@ private
77
113
  end
78
114
  end
79
115
 
116
+
80
117
  def file_headers
81
118
  @file_headers ||= begin
82
119
  raise RuntimeError, "Couldn’t find the central directory." if central_directory.nil?
metadata CHANGED
@@ -1,40 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pinch
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
4
5
  prerelease:
5
- version: 0.0.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Peter Hellberg
9
9
  - Edward Patel
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-07-05 00:00:00 +02:00
13
+ date: 2011-07-05 00:00:00.000000000 +02:00
15
14
  default_executable:
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
18
17
  name: minitest
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &2152860800 !ruby/object:Gem::Requirement
21
19
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
26
24
  type: :development
27
- version_requirements: *id001
28
- description: Pinch makes it possible to download a specific file from within a ZIP file over HTTP 1.1.
25
+ prerelease: false
26
+ version_requirements: *2152860800
27
+ description: Pinch makes it possible to download a specific file from within a ZIP
28
+ file over HTTP 1.1.
29
29
  email: peter@c7.se
30
30
  executables: []
31
-
32
31
  extensions: []
33
-
34
- extra_rdoc_files:
32
+ extra_rdoc_files:
35
33
  - README.rdoc
36
34
  - MIT-LICENSE
37
- files:
35
+ files:
38
36
  - lib/pinch.rb
39
37
  - MIT-LICENSE
40
38
  - README.rdoc
@@ -43,34 +41,33 @@ files:
43
41
  - spec/pinch_spec.rb
44
42
  has_rdoc: true
45
43
  homepage: https://github.com/peterhellberg/pinch
46
- licenses:
44
+ licenses:
47
45
  - MIT-LICENSE
48
46
  post_install_message:
49
- rdoc_options:
47
+ rdoc_options:
50
48
  - --main
51
49
  - README.rdoc
52
50
  - --charset=UTF-8
53
- require_paths:
51
+ require_paths:
54
52
  - lib
55
53
  - lib
56
- required_ruby_version: !ruby/object:Gem::Requirement
54
+ required_ruby_version: !ruby/object:Gem::Requirement
57
55
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
61
59
  version: 1.8.7
62
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
68
66
  requirements: []
69
-
70
67
  rubyforge_project:
71
68
  rubygems_version: 1.6.2
72
69
  signing_key:
73
70
  specification_version: 3
74
71
  summary: Retrieve a file from inside a zip file, over the network!
75
- test_files:
72
+ test_files:
76
73
  - spec/pinch_spec.rb