rubyzip 2.3.1 → 3.0.0.alpha

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +368 -0
  3. data/README.md +122 -39
  4. data/Rakefile +11 -7
  5. data/lib/zip/central_directory.rb +164 -118
  6. data/lib/zip/compressor.rb +3 -1
  7. data/lib/zip/constants.rb +25 -21
  8. data/lib/zip/crypto/decrypted_io.rb +3 -1
  9. data/lib/zip/crypto/encryption.rb +4 -2
  10. data/lib/zip/crypto/null_encryption.rb +5 -3
  11. data/lib/zip/crypto/traditional_encryption.rb +5 -3
  12. data/lib/zip/decompressor.rb +4 -3
  13. data/lib/zip/deflater.rb +10 -8
  14. data/lib/zip/dirtyable.rb +32 -0
  15. data/lib/zip/dos_time.rb +41 -5
  16. data/lib/zip/entry.rb +273 -170
  17. data/lib/zip/entry_set.rb +9 -7
  18. data/lib/zip/errors.rb +115 -16
  19. data/lib/zip/extra_field/generic.rb +3 -10
  20. data/lib/zip/extra_field/ntfs.rb +4 -2
  21. data/lib/zip/extra_field/old_unix.rb +3 -1
  22. data/lib/zip/extra_field/universal_time.rb +3 -1
  23. data/lib/zip/extra_field/unix.rb +5 -3
  24. data/lib/zip/extra_field/unknown.rb +33 -0
  25. data/lib/zip/extra_field/zip64.rb +12 -5
  26. data/lib/zip/extra_field.rb +15 -21
  27. data/lib/zip/file.rb +152 -221
  28. data/lib/zip/file_split.rb +97 -0
  29. data/lib/zip/filesystem/dir.rb +86 -0
  30. data/lib/zip/filesystem/directory_iterator.rb +48 -0
  31. data/lib/zip/filesystem/file.rb +262 -0
  32. data/lib/zip/filesystem/file_stat.rb +110 -0
  33. data/lib/zip/filesystem/zip_file_name_mapper.rb +81 -0
  34. data/lib/zip/filesystem.rb +26 -595
  35. data/lib/zip/inflater.rb +6 -4
  36. data/lib/zip/input_stream.rb +43 -25
  37. data/lib/zip/ioextras/abstract_input_stream.rb +13 -8
  38. data/lib/zip/ioextras/abstract_output_stream.rb +5 -3
  39. data/lib/zip/ioextras.rb +6 -6
  40. data/lib/zip/null_compressor.rb +3 -1
  41. data/lib/zip/null_decompressor.rb +3 -1
  42. data/lib/zip/null_input_stream.rb +3 -1
  43. data/lib/zip/output_stream.rb +45 -39
  44. data/lib/zip/pass_thru_compressor.rb +3 -1
  45. data/lib/zip/pass_thru_decompressor.rb +4 -2
  46. data/lib/zip/streamable_directory.rb +3 -1
  47. data/lib/zip/streamable_stream.rb +3 -0
  48. data/lib/zip/version.rb +3 -1
  49. data/lib/zip.rb +15 -22
  50. data/rubyzip.gemspec +38 -0
  51. data/samples/example.rb +8 -3
  52. data/samples/example_filesystem.rb +2 -1
  53. data/samples/example_recursive.rb +3 -1
  54. data/samples/gtk_ruby_zip.rb +4 -2
  55. data/samples/qtzip.rb +6 -5
  56. data/samples/write_simple.rb +1 -0
  57. data/samples/zipfind.rb +1 -0
  58. metadata +83 -35
  59. data/TODO +0 -15
  60. data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
data/lib/zip/dos_time.rb CHANGED
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+
1
5
  module Zip
2
- class DOSTime < Time #:nodoc:all
6
+ class DOSTime < Time # :nodoc:all
3
7
  # MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
4
8
 
5
9
  # Register CX, the Time:
@@ -24,9 +28,16 @@ module Zip
24
28
  ((year - 1980) << 9)
25
29
  end
26
30
 
27
- # Dos time is only stored with two seconds accuracy
28
31
  def dos_equals(other)
29
- to_i / 2 == other.to_i / 2
32
+ warn 'Zip::DOSTime#dos_equals is deprecated. Use `==` instead.'
33
+ self == other
34
+ end
35
+
36
+ # Dos time is only stored with two seconds accuracy.
37
+ def <=>(other)
38
+ return unless other.kind_of?(Time)
39
+
40
+ (to_i / 2) <=> (other.to_i / 2)
30
41
  end
31
42
 
32
43
  # Create a DOSTime instance from a vanilla Time instance.
@@ -41,9 +52,34 @@ module Zip
41
52
  day = (0b11111 & bin_dos_date)
42
53
  month = (0b111100000 & bin_dos_date) >> 5
43
54
  year = ((0b1111111000000000 & bin_dos_date) >> 9) + 1980
44
- begin
45
- local(year, month, day, hour, minute, second)
55
+
56
+ local(year, month, day, hour, minute, second)
57
+ end
58
+
59
+ if defined? JRUBY_VERSION && Gem::Version.new(JRUBY_VERSION) < '9.2.18.0'
60
+ module JRubyCMP # :nodoc:
61
+ def ==(other)
62
+ (self <=> other).zero?
63
+ end
64
+
65
+ def <(other)
66
+ (self <=> other).negative?
67
+ end
68
+
69
+ def <=(other)
70
+ (self <=> other) <= 0
71
+ end
72
+
73
+ def >(other)
74
+ (self <=> other).positive?
75
+ end
76
+
77
+ def >=(other)
78
+ (self <=> other) >= 0
79
+ end
46
80
  end
81
+
82
+ include JRubyCMP
47
83
  end
48
84
  end
49
85
  end