lg_pod_plugin 1.0.8 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lg +5 -0
  3. data/lib/command/cache.rb +22 -18
  4. data/lib/command/command.rb +27 -35
  5. data/lib/command/install.rb +52 -0
  6. data/lib/command/update.rb +39 -0
  7. data/lib/lg_pod_plugin/downloader.rb +12 -17
  8. data/lib/lg_pod_plugin/git_util.rb +150 -106
  9. data/lib/lg_pod_plugin/install.rb +74 -88
  10. data/lib/lg_pod_plugin/l_cache.rb +11 -77
  11. data/lib/lg_pod_plugin/l_util.rb +6 -2
  12. data/lib/lg_pod_plugin/request.rb +90 -82
  13. data/lib/lg_pod_plugin/version.rb +1 -1
  14. data/lib/lg_pod_plugin.rb +9 -5
  15. metadata +57 -118
  16. data/lib/git/author.rb +0 -14
  17. data/lib/git/base/factory.rb +0 -101
  18. data/lib/git/base.rb +0 -670
  19. data/lib/git/branch.rb +0 -126
  20. data/lib/git/branches.rb +0 -71
  21. data/lib/git/config.rb +0 -22
  22. data/lib/git/diff.rb +0 -155
  23. data/lib/git/encoding_utils.rb +0 -33
  24. data/lib/git/escaped_path.rb +0 -77
  25. data/lib/git/index.rb +0 -5
  26. data/lib/git/lib.rb +0 -1215
  27. data/lib/git/log.rb +0 -135
  28. data/lib/git/object.rb +0 -312
  29. data/lib/git/path.rb +0 -31
  30. data/lib/git/remote.rb +0 -36
  31. data/lib/git/repository.rb +0 -6
  32. data/lib/git/stash.rb +0 -27
  33. data/lib/git/stashes.rb +0 -55
  34. data/lib/git/status.rb +0 -199
  35. data/lib/git/url.rb +0 -127
  36. data/lib/git/version.rb +0 -5
  37. data/lib/git/working_directory.rb +0 -4
  38. data/lib/git/worktree.rb +0 -38
  39. data/lib/git/worktrees.rb +0 -47
  40. data/lib/git.rb +0 -326
  41. data/lib/rchardet/big5freq.rb +0 -927
  42. data/lib/rchardet/big5prober.rb +0 -42
  43. data/lib/rchardet/chardistribution.rb +0 -250
  44. data/lib/rchardet/charsetgroupprober.rb +0 -110
  45. data/lib/rchardet/charsetprober.rb +0 -70
  46. data/lib/rchardet/codingstatemachine.rb +0 -67
  47. data/lib/rchardet/constants.rb +0 -42
  48. data/lib/rchardet/escprober.rb +0 -90
  49. data/lib/rchardet/escsm.rb +0 -245
  50. data/lib/rchardet/eucjpprober.rb +0 -88
  51. data/lib/rchardet/euckrfreq.rb +0 -597
  52. data/lib/rchardet/euckrprober.rb +0 -42
  53. data/lib/rchardet/euctwfreq.rb +0 -431
  54. data/lib/rchardet/euctwprober.rb +0 -42
  55. data/lib/rchardet/gb18030freq.rb +0 -474
  56. data/lib/rchardet/gb18030prober.rb +0 -42
  57. data/lib/rchardet/hebrewprober.rb +0 -289
  58. data/lib/rchardet/jisfreq.rb +0 -571
  59. data/lib/rchardet/jpcntx.rb +0 -229
  60. data/lib/rchardet/langbulgarianmodel.rb +0 -229
  61. data/lib/rchardet/langcyrillicmodel.rb +0 -330
  62. data/lib/rchardet/langgreekmodel.rb +0 -227
  63. data/lib/rchardet/langhebrewmodel.rb +0 -202
  64. data/lib/rchardet/langhungarianmodel.rb +0 -226
  65. data/lib/rchardet/langthaimodel.rb +0 -201
  66. data/lib/rchardet/latin1prober.rb +0 -147
  67. data/lib/rchardet/mbcharsetprober.rb +0 -89
  68. data/lib/rchardet/mbcsgroupprober.rb +0 -47
  69. data/lib/rchardet/mbcssm.rb +0 -542
  70. data/lib/rchardet/sbcharsetprober.rb +0 -122
  71. data/lib/rchardet/sbcsgroupprober.rb +0 -58
  72. data/lib/rchardet/sjisprober.rb +0 -88
  73. data/lib/rchardet/universaldetector.rb +0 -179
  74. data/lib/rchardet/utf8prober.rb +0 -87
  75. data/lib/rchardet/version.rb +0 -3
  76. data/lib/rchardet.rb +0 -67
  77. data/lib/zip/central_directory.rb +0 -212
  78. data/lib/zip/compressor.rb +0 -9
  79. data/lib/zip/constants.rb +0 -115
  80. data/lib/zip/crypto/decrypted_io.rb +0 -40
  81. data/lib/zip/crypto/encryption.rb +0 -11
  82. data/lib/zip/crypto/null_encryption.rb +0 -43
  83. data/lib/zip/crypto/traditional_encryption.rb +0 -99
  84. data/lib/zip/decompressor.rb +0 -31
  85. data/lib/zip/deflater.rb +0 -34
  86. data/lib/zip/dos_time.rb +0 -53
  87. data/lib/zip/entry.rb +0 -719
  88. data/lib/zip/entry_set.rb +0 -88
  89. data/lib/zip/errors.rb +0 -19
  90. data/lib/zip/extra_field/generic.rb +0 -44
  91. data/lib/zip/extra_field/ntfs.rb +0 -94
  92. data/lib/zip/extra_field/old_unix.rb +0 -46
  93. data/lib/zip/extra_field/universal_time.rb +0 -77
  94. data/lib/zip/extra_field/unix.rb +0 -39
  95. data/lib/zip/extra_field/zip64.rb +0 -70
  96. data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
  97. data/lib/zip/extra_field.rb +0 -103
  98. data/lib/zip/file.rb +0 -468
  99. data/lib/zip/filesystem.rb +0 -643
  100. data/lib/zip/inflater.rb +0 -54
  101. data/lib/zip/input_stream.rb +0 -180
  102. data/lib/zip/ioextras/abstract_input_stream.rb +0 -122
  103. data/lib/zip/ioextras/abstract_output_stream.rb +0 -43
  104. data/lib/zip/ioextras.rb +0 -36
  105. data/lib/zip/null_compressor.rb +0 -15
  106. data/lib/zip/null_decompressor.rb +0 -19
  107. data/lib/zip/null_input_stream.rb +0 -10
  108. data/lib/zip/output_stream.rb +0 -198
  109. data/lib/zip/pass_thru_compressor.rb +0 -23
  110. data/lib/zip/pass_thru_decompressor.rb +0 -31
  111. data/lib/zip/streamable_directory.rb +0 -15
  112. data/lib/zip/streamable_stream.rb +0 -52
  113. data/lib/zip/version.rb +0 -3
  114. data/lib/zip.rb +0 -72
@@ -1,180 +0,0 @@
1
- module Zip
2
- # InputStream is the basic class for reading zip entries in a
3
- # zip file. It is possible to create a InputStream object directly,
4
- # passing the zip file name to the constructor, but more often than not
5
- # the InputStream will be obtained from a File (perhaps using the
6
- # ZipFileSystem interface) object for a particular entry in the zip
7
- # archive.
8
- #
9
- # A InputStream inherits IOExtras::AbstractInputStream in order
10
- # to provide an IO-like interface for reading from a single zip
11
- # entry. Beyond methods for mimicking an IO-object it contains
12
- # the method get_next_entry for iterating through the entries of
13
- # an archive. get_next_entry returns a Entry object that describes
14
- # the zip entry the InputStream is currently reading from.
15
- #
16
- # Example that creates a zip archive with ZipOutputStream and reads it
17
- # back again with a InputStream.
18
- #
19
- # require 'zip'
20
- #
21
- # Zip::OutputStream.open("my.zip") do |io|
22
- #
23
- # io.put_next_entry("first_entry.txt")
24
- # io.write "Hello world!"
25
- #
26
- # io.put_next_entry("adir/first_entry.txt")
27
- # io.write "Hello again!"
28
- # end
29
- #
30
- #
31
- # Zip::InputStream.open("my.zip") do |io|
32
- #
33
- # while (entry = io.get_next_entry)
34
- # puts "Contents of #{entry.name}: '#{io.read}'"
35
- # end
36
- # end
37
- #
38
- # java.util.zip.ZipInputStream is the original inspiration for this
39
- # class.
40
-
41
- class InputStream
42
- CHUNK_SIZE = 32_768
43
-
44
- include ::Zip::IOExtras::AbstractInputStream
45
-
46
- # Opens the indicated zip file. An exception is thrown
47
- # if the specified offset in the specified filename is
48
- # not a local zip entry header.
49
- #
50
- # @param context [String||IO||StringIO] file path or IO/StringIO object
51
- # @param offset [Integer] offset in the IO/StringIO
52
- def initialize(context, offset = 0, decrypter = nil)
53
- super()
54
- @archive_io = get_io(context, offset)
55
- @decompressor = ::Zip::NullDecompressor
56
- @decrypter = decrypter || ::Zip::NullDecrypter.new
57
- @current_entry = nil
58
- end
59
-
60
- def close
61
- @archive_io.close
62
- end
63
-
64
- # Returns a Entry object. It is necessary to call this
65
- # method on a newly created InputStream before reading from
66
- # the first entry in the archive. Returns nil when there are
67
- # no more entries.
68
- def get_next_entry
69
- @archive_io.seek(@current_entry.next_header_offset, IO::SEEK_SET) if @current_entry
70
- open_entry
71
- end
72
-
73
- # Rewinds the stream to the beginning of the current entry
74
- def rewind
75
- return if @current_entry.nil?
76
-
77
- @lineno = 0
78
- @pos = 0
79
- @archive_io.seek(@current_entry.local_header_offset, IO::SEEK_SET)
80
- open_entry
81
- end
82
-
83
- # Modeled after IO.sysread
84
- def sysread(length = nil, outbuf = '')
85
- @decompressor.read(length, outbuf)
86
- end
87
-
88
- class << self
89
- # Same as #initialize but if a block is passed the opened
90
- # stream is passed to the block and closed when the block
91
- # returns.
92
- def open(filename_or_io, offset = 0, decrypter = nil)
93
- zio = new(filename_or_io, offset, decrypter)
94
- return zio unless block_given?
95
-
96
- begin
97
- yield zio
98
- ensure
99
- zio.close if zio
100
- end
101
- end
102
-
103
- def open_buffer(filename_or_io, offset = 0)
104
- warn 'open_buffer is deprecated!!! Use open instead!'
105
- ::Zip::InputStream.open(filename_or_io, offset)
106
- end
107
- end
108
-
109
- protected
110
-
111
- def get_io(io_or_file, offset = 0)
112
- if io_or_file.respond_to?(:seek)
113
- io = io_or_file.dup
114
- io.seek(offset, ::IO::SEEK_SET)
115
- io
116
- else
117
- file = ::File.open(io_or_file, 'rb')
118
- file.seek(offset, ::IO::SEEK_SET)
119
- file
120
- end
121
- end
122
-
123
- def open_entry
124
- @current_entry = ::Zip::Entry.read_local_entry(@archive_io)
125
- if @current_entry && @current_entry.encrypted? && @decrypter.kind_of?(NullEncrypter)
126
- raise Error, 'password required to decode zip file'
127
- end
128
-
129
- if @current_entry && @current_entry.incomplete? && @current_entry.crc == 0 \
130
- && @current_entry.compressed_size == 0 \
131
- && @current_entry.size == 0 && !@complete_entry
132
- raise GPFBit3Error,
133
- 'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
134
- 'Please use ::Zip::File instead of ::Zip::InputStream'
135
- end
136
- @decrypted_io = get_decrypted_io
137
- @decompressor = get_decompressor
138
- flush
139
- @current_entry
140
- end
141
-
142
- def get_decrypted_io
143
- header = @archive_io.read(@decrypter.header_bytesize)
144
- @decrypter.reset!(header)
145
-
146
- ::Zip::DecryptedIo.new(@archive_io, @decrypter)
147
- end
148
-
149
- def get_decompressor
150
- return ::Zip::NullDecompressor if @current_entry.nil?
151
-
152
- decompressed_size =
153
- if @current_entry.incomplete? && @current_entry.crc == 0 && @current_entry.size == 0 && @complete_entry
154
- @complete_entry.size
155
- else
156
- @current_entry.size
157
- end
158
-
159
- decompressor_class = ::Zip::Decompressor.find_by_compression_method(@current_entry.compression_method)
160
- if decompressor_class.nil?
161
- raise ::Zip::CompressionMethodError,
162
- "Unsupported compression method #{@current_entry.compression_method}"
163
- end
164
-
165
- decompressor_class.new(@decrypted_io, decompressed_size)
166
- end
167
-
168
- def produce_input
169
- @decompressor.read(CHUNK_SIZE)
170
- end
171
-
172
- def input_finished?
173
- @decompressor.eof
174
- end
175
- end
176
- end
177
-
178
- # Copyright (C) 2002, 2003 Thomas Sondergaard
179
- # rubyzip is free software; you can redistribute it and/or
180
- # modify it under the terms of the ruby license.
@@ -1,122 +0,0 @@
1
- module Zip
2
- module IOExtras
3
- # Implements many of the convenience methods of IO
4
- # such as gets, getc, readline and readlines
5
- # depends on: input_finished?, produce_input and read
6
- module AbstractInputStream
7
- include Enumerable
8
- include FakeIO
9
-
10
- def initialize
11
- super
12
- @lineno = 0
13
- @pos = 0
14
- @output_buffer = ''
15
- end
16
-
17
- attr_accessor :lineno
18
- attr_reader :pos
19
-
20
- def read(number_of_bytes = nil, buf = '')
21
- tbuf = if @output_buffer.bytesize > 0
22
- if number_of_bytes <= @output_buffer.bytesize
23
- @output_buffer.slice!(0, number_of_bytes)
24
- else
25
- number_of_bytes -= @output_buffer.bytesize if number_of_bytes
26
- rbuf = sysread(number_of_bytes, buf)
27
- out = @output_buffer
28
- out << rbuf if rbuf
29
- @output_buffer = ''
30
- out
31
- end
32
- else
33
- sysread(number_of_bytes, buf)
34
- end
35
-
36
- if tbuf.nil? || tbuf.empty?
37
- return nil if number_of_bytes
38
-
39
- return ''
40
- end
41
-
42
- @pos += tbuf.length
43
-
44
- if buf
45
- buf.replace(tbuf)
46
- else
47
- buf = tbuf
48
- end
49
- buf
50
- end
51
-
52
- def readlines(a_sep_string = $INPUT_RECORD_SEPARATOR)
53
- ret_val = []
54
- each_line(a_sep_string) { |line| ret_val << line }
55
- ret_val
56
- end
57
-
58
- def gets(a_sep_string = $INPUT_RECORD_SEPARATOR, number_of_bytes = nil)
59
- @lineno = @lineno.next
60
-
61
- if number_of_bytes.respond_to?(:to_int)
62
- number_of_bytes = number_of_bytes.to_int
63
- a_sep_string = a_sep_string.to_str if a_sep_string
64
- elsif a_sep_string.respond_to?(:to_int)
65
- number_of_bytes = a_sep_string.to_int
66
- a_sep_string = $INPUT_RECORD_SEPARATOR
67
- else
68
- number_of_bytes = nil
69
- a_sep_string = a_sep_string.to_str if a_sep_string
70
- end
71
-
72
- return read(number_of_bytes) if a_sep_string.nil?
73
-
74
- a_sep_string = "#{$INPUT_RECORD_SEPARATOR}#{$INPUT_RECORD_SEPARATOR}" if a_sep_string.empty?
75
-
76
- buffer_index = 0
77
- over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
78
- while (match_index = @output_buffer.index(a_sep_string, buffer_index)).nil? && !over_limit
79
- buffer_index = [buffer_index, @output_buffer.bytesize - a_sep_string.bytesize].max
80
- return @output_buffer.empty? ? nil : flush if input_finished?
81
-
82
- @output_buffer << produce_input
83
- over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
84
- end
85
- sep_index = [match_index + a_sep_string.bytesize, number_of_bytes || @output_buffer.bytesize].min
86
- @pos += sep_index
87
- @output_buffer.slice!(0...sep_index)
88
- end
89
-
90
- def ungetc(byte)
91
- @output_buffer = byte.chr + @output_buffer
92
- end
93
-
94
- def flush
95
- ret_val = @output_buffer
96
- @output_buffer = ''
97
- ret_val
98
- end
99
-
100
- def readline(a_sep_string = $INPUT_RECORD_SEPARATOR)
101
- ret_val = gets(a_sep_string)
102
- raise EOFError unless ret_val
103
-
104
- ret_val
105
- end
106
-
107
- def each_line(a_sep_string = $INPUT_RECORD_SEPARATOR)
108
- loop { yield readline(a_sep_string) }
109
- rescue EOFError
110
- # We just need to catch this; we don't need to handle it.
111
- end
112
-
113
- alias each each_line
114
-
115
- def eof
116
- @output_buffer.empty? && input_finished?
117
- end
118
-
119
- alias eof? eof
120
- end
121
- end
122
- end
@@ -1,43 +0,0 @@
1
- module Zip
2
- module IOExtras
3
- # Implements many of the output convenience methods of IO.
4
- # relies on <<
5
- module AbstractOutputStream
6
- include FakeIO
7
-
8
- def write(data)
9
- self << data
10
- data.to_s.bytesize
11
- end
12
-
13
- def print(*params)
14
- self << params.join($OUTPUT_FIELD_SEPARATOR) << $OUTPUT_RECORD_SEPARATOR.to_s
15
- end
16
-
17
- def printf(a_format_string, *params)
18
- self << format(a_format_string, *params)
19
- end
20
-
21
- def putc(an_object)
22
- self << case an_object
23
- when Integer
24
- an_object.chr
25
- when String
26
- an_object
27
- else
28
- raise TypeError, 'putc: Only Integer and String supported'
29
- end
30
- an_object
31
- end
32
-
33
- def puts(*params)
34
- params << "\n" if params.empty?
35
- params.flatten.each do |element|
36
- val = element.to_s
37
- self << val
38
- self << "\n" unless val[-1, 1] == "\n"
39
- end
40
- end
41
- end
42
- end
43
- end
data/lib/zip/ioextras.rb DELETED
@@ -1,36 +0,0 @@
1
- module Zip
2
- module IOExtras #:nodoc:
3
- CHUNK_SIZE = 131_072
4
-
5
- RANGE_ALL = 0..-1
6
-
7
- class << self
8
- def copy_stream(ostream, istream)
9
- ostream.write(istream.read(CHUNK_SIZE, '')) until istream.eof?
10
- end
11
-
12
- def copy_stream_n(ostream, istream, nbytes)
13
- toread = nbytes
14
- while toread > 0 && !istream.eof?
15
- tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread
16
- ostream.write(istream.read(tr, ''))
17
- toread -= tr
18
- end
19
- end
20
- end
21
-
22
- # Implements kind_of? in order to pretend to be an IO object
23
- module FakeIO
24
- def kind_of?(object)
25
- object == IO || super
26
- end
27
- end
28
- end
29
- end
30
-
31
- require 'zip/ioextras/abstract_input_stream'
32
- require 'zip/ioextras/abstract_output_stream'
33
-
34
- # Copyright (C) 2002-2004 Thomas Sondergaard
35
- # rubyzip is free software; you can redistribute it and/or
36
- # modify it under the terms of the ruby license.
@@ -1,15 +0,0 @@
1
- module Zip
2
- class NullCompressor < Compressor #:nodoc:all
3
- include Singleton
4
-
5
- def <<(_data)
6
- raise IOError, 'closed stream'
7
- end
8
-
9
- attr_reader :size, :compressed_size
10
- end
11
- end
12
-
13
- # Copyright (C) 2002, 2003 Thomas Sondergaard
14
- # rubyzip is free software; you can redistribute it and/or
15
- # modify it under the terms of the ruby license.
@@ -1,19 +0,0 @@
1
- module Zip
2
- module NullDecompressor #:nodoc:all
3
- module_function
4
-
5
- def read(_length = nil, _outbuf = nil)
6
- nil
7
- end
8
-
9
- def eof
10
- true
11
- end
12
-
13
- alias eof? eof
14
- end
15
- end
16
-
17
- # Copyright (C) 2002, 2003 Thomas Sondergaard
18
- # rubyzip is free software; you can redistribute it and/or
19
- # modify it under the terms of the ruby license.
@@ -1,10 +0,0 @@
1
- module Zip
2
- module NullInputStream #:nodoc:all
3
- include ::Zip::NullDecompressor
4
- include ::Zip::IOExtras::AbstractInputStream
5
- end
6
- end
7
-
8
- # Copyright (C) 2002, 2003 Thomas Sondergaard
9
- # rubyzip is free software; you can redistribute it and/or
10
- # modify it under the terms of the ruby license.
@@ -1,198 +0,0 @@
1
- module Zip
2
- # ZipOutputStream is the basic class for writing zip files. It is
3
- # possible to create a ZipOutputStream object directly, passing
4
- # the zip file name to the constructor, but more often than not
5
- # the ZipOutputStream will be obtained from a ZipFile (perhaps using the
6
- # ZipFileSystem interface) object for a particular entry in the zip
7
- # archive.
8
- #
9
- # A ZipOutputStream inherits IOExtras::AbstractOutputStream in order
10
- # to provide an IO-like interface for writing to a single zip
11
- # entry. Beyond methods for mimicking an IO-object it contains
12
- # the method put_next_entry that closes the current entry
13
- # and creates a new.
14
- #
15
- # Please refer to ZipInputStream for example code.
16
- #
17
- # java.util.zip.ZipOutputStream is the original inspiration for this
18
- # class.
19
-
20
- class OutputStream
21
- include ::Zip::IOExtras::AbstractOutputStream
22
-
23
- attr_accessor :comment
24
-
25
- # Opens the indicated zip file. If a file with that name already
26
- # exists it will be overwritten.
27
- def initialize(file_name, stream = false, encrypter = nil)
28
- super()
29
- @file_name = file_name
30
- @output_stream = if stream
31
- iostream = @file_name.dup
32
- iostream.reopen(@file_name)
33
- iostream.rewind
34
- iostream
35
- else
36
- ::File.new(@file_name, 'wb')
37
- end
38
- @entry_set = ::Zip::EntrySet.new
39
- @compressor = ::Zip::NullCompressor.instance
40
- @encrypter = encrypter || ::Zip::NullEncrypter.new
41
- @closed = false
42
- @current_entry = nil
43
- @comment = nil
44
- end
45
-
46
- # Same as #initialize but if a block is passed the opened
47
- # stream is passed to the block and closed when the block
48
- # returns.
49
- class << self
50
- def open(file_name, encrypter = nil)
51
- return new(file_name) unless block_given?
52
-
53
- zos = new(file_name, false, encrypter)
54
- yield zos
55
- ensure
56
- zos.close if zos
57
- end
58
-
59
- # Same as #open but writes to a filestream instead
60
- def write_buffer(io = ::StringIO.new(''), encrypter = nil)
61
- io.binmode if io.respond_to?(:binmode)
62
- zos = new(io, true, encrypter)
63
- yield zos
64
- zos.close_buffer
65
- end
66
- end
67
-
68
- # Closes the stream and writes the central directory to the zip file
69
- def close
70
- return if @closed
71
-
72
- finalize_current_entry
73
- update_local_headers
74
- write_central_directory
75
- @output_stream.close
76
- @closed = true
77
- end
78
-
79
- # Closes the stream and writes the central directory to the zip file
80
- def close_buffer
81
- return @output_stream if @closed
82
-
83
- finalize_current_entry
84
- update_local_headers
85
- write_central_directory
86
- @closed = true
87
- @output_stream
88
- end
89
-
90
- # Closes the current entry and opens a new for writing.
91
- # +entry+ can be a ZipEntry object or a string.
92
- def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression)
93
- raise Error, 'zip stream is closed' if @closed
94
-
95
- new_entry = if entry_name.kind_of?(Entry)
96
- entry_name
97
- else
98
- Entry.new(@file_name, entry_name.to_s)
99
- end
100
- new_entry.comment = comment unless comment.nil?
101
- unless extra.nil?
102
- new_entry.extra = extra.kind_of?(ExtraField) ? extra : ExtraField.new(extra.to_s)
103
- end
104
- new_entry.compression_method = compression_method unless compression_method.nil?
105
- init_next_entry(new_entry, level)
106
- @current_entry = new_entry
107
- end
108
-
109
- def copy_raw_entry(entry)
110
- entry = entry.dup
111
- raise Error, 'zip stream is closed' if @closed
112
- raise Error, 'entry is not a ZipEntry' unless entry.kind_of?(Entry)
113
-
114
- finalize_current_entry
115
- @entry_set << entry
116
- src_pos = entry.local_header_offset
117
- entry.write_local_entry(@output_stream)
118
- @compressor = NullCompressor.instance
119
- entry.get_raw_input_stream do |is|
120
- is.seek(src_pos, IO::SEEK_SET)
121
- ::Zip::Entry.read_local_entry(is)
122
- IOExtras.copy_stream_n(@output_stream, is, entry.compressed_size)
123
- end
124
- @compressor = NullCompressor.instance
125
- @current_entry = nil
126
- end
127
-
128
- private
129
-
130
- def finalize_current_entry
131
- return unless @current_entry
132
-
133
- finish
134
- @current_entry.compressed_size = @output_stream.tell - \
135
- @current_entry.local_header_offset - \
136
- @current_entry.calculate_local_header_size
137
- @current_entry.size = @compressor.size
138
- @current_entry.crc = @compressor.crc
139
- @output_stream << @encrypter.data_descriptor(@current_entry.crc, @current_entry.compressed_size, @current_entry.size)
140
- @current_entry.gp_flags |= @encrypter.gp_flags
141
- @current_entry = nil
142
- @compressor = ::Zip::NullCompressor.instance
143
- end
144
-
145
- def init_next_entry(entry, level = Zip.default_compression)
146
- finalize_current_entry
147
- @entry_set << entry
148
- entry.write_local_entry(@output_stream)
149
- @encrypter.reset!
150
- @output_stream << @encrypter.header(entry.mtime)
151
- @compressor = get_compressor(entry, level)
152
- end
153
-
154
- def get_compressor(entry, level)
155
- case entry.compression_method
156
- when Entry::DEFLATED
157
- ::Zip::Deflater.new(@output_stream, level, @encrypter)
158
- when Entry::STORED
159
- ::Zip::PassThruCompressor.new(@output_stream)
160
- else
161
- raise ::Zip::CompressionMethodError,
162
- "Invalid compression method: '#{entry.compression_method}'"
163
- end
164
- end
165
-
166
- def update_local_headers
167
- pos = @output_stream.pos
168
- @entry_set.each do |entry|
169
- @output_stream.pos = entry.local_header_offset
170
- entry.write_local_entry(@output_stream, true)
171
- end
172
- @output_stream.pos = pos
173
- end
174
-
175
- def write_central_directory
176
- cdir = CentralDirectory.new(@entry_set, @comment)
177
- cdir.write_to_stream(@output_stream)
178
- end
179
-
180
- protected
181
-
182
- def finish
183
- @compressor.finish
184
- end
185
-
186
- public
187
-
188
- # Modeled after IO.<<
189
- def <<(data)
190
- @compressor << data
191
- self
192
- end
193
- end
194
- end
195
-
196
- # Copyright (C) 2002, 2003 Thomas Sondergaard
197
- # rubyzip is free software; you can redistribute it and/or
198
- # modify it under the terms of the ruby license.
@@ -1,23 +0,0 @@
1
- module Zip
2
- class PassThruCompressor < Compressor #:nodoc:all
3
- def initialize(output_stream)
4
- super()
5
- @output_stream = output_stream
6
- @crc = Zlib.crc32
7
- @size = 0
8
- end
9
-
10
- def <<(data)
11
- val = data.to_s
12
- @crc = Zlib.crc32(val, @crc)
13
- @size += val.bytesize
14
- @output_stream << val
15
- end
16
-
17
- attr_reader :size, :crc
18
- end
19
- end
20
-
21
- # Copyright (C) 2002, 2003 Thomas Sondergaard
22
- # rubyzip is free software; you can redistribute it and/or
23
- # modify it under the terms of the ruby license.
@@ -1,31 +0,0 @@
1
- module Zip
2
- class PassThruDecompressor < Decompressor #:nodoc:all
3
- def initialize(*args)
4
- super
5
- @read_so_far = 0
6
- end
7
-
8
- def read(length = nil, outbuf = '')
9
- return (length.nil? || length.zero? ? '' : nil) if eof
10
-
11
- if length.nil? || (@read_so_far + length) > decompressed_size
12
- length = decompressed_size - @read_so_far
13
- end
14
-
15
- @read_so_far += length
16
- input_stream.read(length, outbuf)
17
- end
18
-
19
- def eof
20
- @read_so_far >= decompressed_size
21
- end
22
-
23
- alias eof? eof
24
- end
25
-
26
- ::Zip::Decompressor.register(::Zip::COMPRESSION_METHOD_STORE, ::Zip::PassThruDecompressor)
27
- end
28
-
29
- # Copyright (C) 2002, 2003 Thomas Sondergaard
30
- # rubyzip is free software; you can redistribute it and/or
31
- # modify it under the terms of the ruby license.
@@ -1,15 +0,0 @@
1
- module Zip
2
- class StreamableDirectory < Entry
3
- def initialize(zipfile, entry, src_path = nil, permission = nil)
4
- super(zipfile, entry)
5
-
6
- @ftype = :directory
7
- entry.get_extra_attributes_from_path(src_path) if src_path
8
- @unix_perms = permission if permission
9
- end
10
- end
11
- end
12
-
13
- # Copyright (C) 2002, 2003 Thomas Sondergaard
14
- # rubyzip is free software; you can redistribute it and/or
15
- # modify it under the terms of the ruby license.