Class: Pack::Expander
- Inherits:
-
Object
- Object
- Pack::Expander
- Defined in:
- lib/pack/expander.rb
Instance Attribute Summary collapse
-
#source_size ⇒ Object
readonly
Returns the value of attribute source_size.
-
#target_size ⇒ Object
readonly
Returns the value of attribute target_size.
Class Method Summary collapse
Instance Method Summary collapse
- #expand(source) ⇒ Object
-
#initialize(delta) ⇒ Expander
constructor
A new instance of Expander.
Constructor Details
#initialize(delta) ⇒ Expander
Returns a new instance of Expander.
15 16 17 18 19 20 |
# File 'lib/pack/expander.rb', line 15 def initialize(delta) @delta = StringIO.new(delta) @source_size = read_size @target_size = read_size end |
Instance Attribute Details
#source_size ⇒ Object (readonly)
Returns the value of attribute source_size.
9 10 11 |
# File 'lib/pack/expander.rb', line 9 def source_size @source_size end |
#target_size ⇒ Object (readonly)
Returns the value of attribute target_size.
9 10 11 |
# File 'lib/pack/expander.rb', line 9 def target_size @target_size end |
Class Method Details
Instance Method Details
#expand(source) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pack/expander.rb', line 22 def (source) check_size(source, @source_size) target = "" until @delta.eof? byte = @delta.readbyte if byte < 0x80 insert = Delta::Insert.parse(@delta, byte) target.concat(insert.data) else copy = Delta::Copy.parse(@delta, byte) size = (copy.size == 0) ? GIT_MAX_COPY : copy.size target.concat(source.byteslice(copy.offset, size)) end end check_size(target, @target_size) target end |