outback 0.0.14 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +11 -0
  3. data/LICENSE +21 -0
  4. data/README.md +29 -3
  5. data/lib/outback/archive.rb +6 -17
  6. data/lib/outback/backup.rb +38 -20
  7. data/lib/outback/cli.rb +6 -2
  8. data/lib/outback/configuration.rb +15 -10
  9. data/lib/outback/directory_source.rb +8 -7
  10. data/lib/outback/directory_target.rb +18 -11
  11. data/lib/outback/encryption_processor.rb +34 -0
  12. data/lib/outback/errors.rb +7 -0
  13. data/lib/outback/logging.rb +7 -0
  14. data/lib/outback/mysql_source.rb +9 -9
  15. data/lib/outback/processor.rb +17 -0
  16. data/lib/outback/s3_target.rb +18 -9
  17. data/lib/outback/sftp_target.rb +70 -0
  18. data/lib/outback/source.rb +9 -2
  19. data/lib/outback/source_archive.rb +17 -0
  20. data/lib/outback/support/attr_setter.rb +1 -1
  21. data/lib/outback/support/configurable.rb +5 -3
  22. data/lib/outback/target.rb +52 -14
  23. data/lib/outback/target_archive.rb +30 -0
  24. data/lib/outback/version.rb +3 -0
  25. data/lib/outback.rb +16 -11
  26. data/lib/vendor/enumerable_ext.rb +9 -0
  27. data/lib/{outback/vendor → vendor}/metaclass.rb +1 -1
  28. data/lib/vendor/methodphitamine.rb +28 -0
  29. data/lib/vendor/mysql/charset.rb +325 -0
  30. data/lib/vendor/mysql/constants.rb +165 -0
  31. data/lib/vendor/mysql/error.rb +989 -0
  32. data/lib/vendor/mysql/packet.rb +78 -0
  33. data/lib/vendor/mysql/protocol.rb +770 -0
  34. data/lib/vendor/mysql.rb +1093 -0
  35. data/lib/vendor/numeric_ext.rb +49 -0
  36. data/lib/vendor/string_ext.rb +19 -0
  37. metadata +84 -43
  38. data/MIT-LICENSE +0 -20
  39. data/VERSION +0 -1
  40. data/lib/outback/configuration_error.rb +0 -4
  41. data/lib/outback/directory_archive.rb +0 -8
  42. data/lib/outback/local_archive.rb +0 -6
  43. data/lib/outback/s3_archive.rb +0 -18
  44. data/lib/outback/temp_archive.rb +0 -5
  45. data/lib/outback/vendor/methodphitamine.rb +0 -25
  46. data/lib/outback/vendor/mysql.rb +0 -1214
@@ -0,0 +1,78 @@
1
+ # coding: ascii-8bit
2
+ class Mysql
3
+ class Packet
4
+ # convert Numeric to LengthCodedBinary
5
+ def self.lcb(num)
6
+ return "\xfb" if num.nil?
7
+ return [num].pack("C") if num < 251
8
+ return [252, num].pack("Cv") if num < 65536
9
+ return [253, num&0xffff, num>>16].pack("CvC") if num < 16777216
10
+ return [254, num&0xffffffff, num>>32].pack("CVV")
11
+ end
12
+
13
+ # convert String to LengthCodedString
14
+ def self.lcs(str)
15
+ str = Charset.to_binary str.dup
16
+ lcb(str.length)+str
17
+ end
18
+
19
+ def initialize(data)
20
+ @data = data
21
+ end
22
+
23
+ def lcb
24
+ return nil if @data.empty?
25
+ case v = utiny
26
+ when 0xfb
27
+ return nil
28
+ when 0xfc
29
+ return ushort
30
+ when 0xfd
31
+ c, v = utiny, ushort
32
+ return (v << 8)+c
33
+ when 0xfe
34
+ v1, v2 = ulong, ulong
35
+ return (v2 << 32)+v1
36
+ else
37
+ return v
38
+ end
39
+ end
40
+
41
+ def lcs
42
+ len = self.lcb
43
+ return nil unless len
44
+ @data.slice!(0, len)
45
+ end
46
+
47
+ def read(len)
48
+ @data.slice!(0, len)
49
+ end
50
+
51
+ def string
52
+ str = @data.unpack('Z*').first
53
+ @data.slice!(0, str.length+1)
54
+ str
55
+ end
56
+
57
+ def utiny
58
+ @data.slice!(0, 1).unpack('C').first
59
+ end
60
+
61
+ def ushort
62
+ @data.slice!(0, 2).unpack('v').first
63
+ end
64
+
65
+ def ulong
66
+ @data.slice!(0, 4).unpack('V').first
67
+ end
68
+
69
+ def eof?
70
+ @data[0] == ?\xfe && @data.length == 5
71
+ end
72
+
73
+ def to_s
74
+ @data
75
+ end
76
+
77
+ end
78
+ end