fossilize 1.0.0 → 1.1.0
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.
- data/.rspec +2 -0
- data/bin/fossilize +23 -3
- data/lib/fossilize.rb +4 -11
- data/lib/fossilize/version.rb +1 -1
- metadata +3 -2
data/.rspec
ADDED
data/bin/fossilize
CHANGED
@@ -2,8 +2,28 @@
|
|
2
2
|
|
3
3
|
require "fossilize"
|
4
4
|
|
5
|
-
|
6
|
-
output = Fossilize.apply(ARGV[0], delta)
|
5
|
+
usage = "usage: fossilize <create|apply> old_version <new_version|delta_string>"
|
7
6
|
|
8
|
-
|
7
|
+
if ARGV.size < 2
|
8
|
+
puts usage
|
9
|
+
exit -1
|
10
|
+
end
|
9
11
|
|
12
|
+
old_version = ARGV[1]
|
13
|
+
new_or_delta = ARGV[2]
|
14
|
+
|
15
|
+
if ARGV[0] == "create"
|
16
|
+
delta = Fossilize.create(old_version, new_or_delta)
|
17
|
+
File.write("#{old_version}.delta", delta)
|
18
|
+
puts "Wrote delta string to: #{old_version}.fdelta\n\n"
|
19
|
+
puts delta
|
20
|
+
exit 0
|
21
|
+
elsif ARGV[0] == "apply"
|
22
|
+
result = Fossilize.apply(old_version, new_or_delta)
|
23
|
+
File.write("#{old_version}.fossilized", result)
|
24
|
+
puts "Wrote new version to: #{old_version}.fossilized"
|
25
|
+
exit 0
|
26
|
+
else
|
27
|
+
puts usage
|
28
|
+
exit -1
|
29
|
+
end
|
data/lib/fossilize.rb
CHANGED
@@ -54,20 +54,14 @@ module Fossilize
|
|
54
54
|
source_string = check_input(source)
|
55
55
|
target_string = check_input(target)
|
56
56
|
|
57
|
-
# Create native memory buffers for the input Strings.
|
58
|
-
source_ptr = FFI::MemoryPointer.new(:char, source_string.size)
|
59
|
-
source_ptr.put_bytes(0, source_string)
|
60
|
-
target_ptr = FFI::MemoryPointer.new(:char, target_string.size)
|
61
|
-
target_ptr.put_bytes(0, target_string)
|
62
|
-
|
63
57
|
# Create a bare string to hold to returning delta from the C function that's the
|
64
58
|
# size of the target + 60 (according to the Fossil source docs).
|
65
|
-
delta = (
|
59
|
+
delta = ("\0" * (target_string.size + 60))
|
66
60
|
|
67
61
|
# create the delta, retaining the size of the delta output and return the delta,
|
68
62
|
# stripping out any excess left over (needs refinement...).
|
69
|
-
delta_size = delta_create(
|
70
|
-
return delta.
|
63
|
+
delta_size = delta_create(source_string, source_string.size, target_string, target_string.size, delta)
|
64
|
+
return delta.rstrip!
|
71
65
|
end
|
72
66
|
|
73
67
|
# Access
|
@@ -96,7 +90,6 @@ module Fossilize
|
|
96
90
|
|
97
91
|
# Get the eventual size of the deltaed file and create a string to hold it
|
98
92
|
expected_output_size = delta_output_size(delta_string, delta_string.size)
|
99
|
-
puts "expected = #{expected_output_size}"
|
100
93
|
|
101
94
|
# The algorithm will return -1 as the output size if there was an error
|
102
95
|
if expected_output_size == -1
|
@@ -116,7 +109,7 @@ module Fossilize
|
|
116
109
|
return nil
|
117
110
|
end
|
118
111
|
|
119
|
-
return output
|
112
|
+
return output
|
120
113
|
end
|
121
114
|
|
122
115
|
private
|
data/lib/fossilize/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fossilize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -86,6 +86,7 @@ extensions:
|
|
86
86
|
extra_rdoc_files: []
|
87
87
|
files:
|
88
88
|
- .gitignore
|
89
|
+
- .rspec
|
89
90
|
- Gemfile
|
90
91
|
- LICENSE
|
91
92
|
- README.md
|