Class: GitObjectBrowser::Models::PackedObject
- Inherits:
-
Bindata
- Object
- Bindata
- GitObjectBrowser::Models::PackedObject
show all
- Defined in:
- lib/git-object-browser/models/packed_object.rb
Constant Summary
collapse
- TYPES =
%w{
undefined
commit
tree
blob
tag
undefined
ofs_delta
ref_delta
}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Bindata
#binstr, #byte, #bytes, #find_char, #hex, #int, #peek, #raw, #seek, #skip, #switch_source
Constructor Details
#initialize(index, input) ⇒ PackedObject
Returns a new instance of PackedObject.
27
28
29
30
|
# File 'lib/git-object-browser/models/packed_object.rb', line 27
def initialize(index, input)
super(input)
@index = index
end
|
Instance Attribute Details
Returns the value of attribute header.
13
14
15
|
# File 'lib/git-object-browser/models/packed_object.rb', line 13
def
end
|
#object ⇒ Object
Returns the value of attribute object.
14
15
16
|
# File 'lib/git-object-browser/models/packed_object.rb', line 14
def object
@object
end
|
#raw_data ⇒ Object
Returns the value of attribute raw_data.
13
14
15
|
# File 'lib/git-object-browser/models/packed_object.rb', line 13
def raw_data
@raw_data
end
|
Class Method Details
.path?(relpath) ⇒ Boolean
89
90
91
|
# File 'lib/git-object-browser/models/packed_object.rb', line 89
def self.path?(relpath)
return relpath =~ %r{\Aobjects/pack/pack-[0-9a-f]{40}\.pack\z}
end
|
Instance Method Details
#parse(offset) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/git-object-browser/models/packed_object.rb', line 32
def parse(offset)
parse_raw(offset)
input = "#{ @object_type } #{ @object_size }\0" + @raw_data
@object = GitObject.new(nil).parse_inflated(input)
self
end
|
56
57
58
59
60
61
|
# File 'lib/git-object-browser/models/packed_object.rb', line 56
def (offset)
seek(offset)
(type, size, ) = parse_type_and_size
type = TYPES[type]
{ :type => type, :size => size, :header_size => }
end
|
63
64
65
66
67
68
|
# File 'lib/git-object-browser/models/packed_object.rb', line 63
def (offset, )
(delta_offset, ) = parse_delta_offset
[:base_offset] = offset - delta_offset
[:header_size] +=
end
|
#parse_raw(offset) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/git-object-browser/models/packed_object.rb', line 39
def parse_raw(offset)
@offset = offset
= (offset)
if [:type] == 'ofs_delta'
obj_ofs_delta
elsif [:type] == 'ref_delta'
obj_ref_delta
else
@object_type = [:type]
@object_size = [:size]
@raw_data = zlib_inflate
end
[@object_type, @object_size]
end
|
70
71
72
73
74
|
# File 'lib/git-object-browser/models/packed_object.rb', line 70
def ()
[:base_sha1] = hex(20)
[:header_size] += 20
end
|
#to_hash ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/git-object-browser/models/packed_object.rb', line 76
def to_hash
return {
:offset => @offset,
:type => [:type],
:size => [:size],
:header_size => [:header_size],
:base_offset => [:base_offset],
:delta_commands => @delta_commands,
:base_size => @base_size,
:object => @object.to_hash,
}
end
|