Class: Git::Object::AbstractObject
- Inherits:
-
Object
- Object
- Git::Object::AbstractObject
- Defined in:
- lib/git/object.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#objectish ⇒ Object
Returns the value of attribute objectish.
-
#size ⇒ Object
Returns the value of attribute size.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#archive(file = nil, opts = {}) ⇒ Object
creates an archive of this object (tree).
- #blob? ⇒ Boolean
- #commit? ⇒ Boolean
-
#contents(&block) ⇒ Object
Get the object’s contents.
- #contents_array ⇒ Object
- #diff(objectish) ⇒ Object
- #grep(string, path_limiter = nil, opts = {}) ⇒ Object
-
#initialize(base, objectish) ⇒ AbstractObject
constructor
A new instance of AbstractObject.
- #log(count = 30) ⇒ Object
- #sha ⇒ Object
- #tag? ⇒ Boolean
- #to_s ⇒ Object
- #tree? ⇒ Boolean
Constructor Details
#initialize(base, objectish) ⇒ AbstractObject
Returns a new instance of AbstractObject.
12 13 14 15 16 17 18 19 |
# File 'lib/git/object.rb', line 12 def initialize(base, objectish) @base = base @objectish = objectish.to_s @contents = nil @trees = nil @size = nil @sha = nil end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
10 11 12 |
# File 'lib/git/object.rb', line 10 def mode @mode end |
#objectish ⇒ Object
Returns the value of attribute objectish.
10 11 12 |
# File 'lib/git/object.rb', line 10 def objectish @objectish end |
#size ⇒ Object
Returns the value of attribute size.
10 11 12 |
# File 'lib/git/object.rb', line 10 def size @size end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/git/object.rb', line 10 def type @type end |
Instance Method Details
#archive(file = nil, opts = {}) ⇒ Object
creates an archive of this object (tree)
65 66 67 |
# File 'lib/git/object.rb', line 65 def archive(file = nil, opts = {}) @base.lib.archive(@objectish, file, opts) end |
#blob? ⇒ Boolean
71 |
# File 'lib/git/object.rb', line 71 def blob?; false; end |
#commit? ⇒ Boolean
73 |
# File 'lib/git/object.rb', line 73 def commit?; false; end |
#contents(&block) ⇒ Object
Get the object’s contents. If no block is given, the contents are cached in memory and returned as a string. If a block is given, it yields an IO object (via IO::popen) which could be used to read a large file in chunks.
Use this for large files so that they are not held in memory.
35 36 37 38 39 40 41 |
# File 'lib/git/object.rb', line 35 def contents(&block) if block_given? @base.lib.object_contents(@objectish, &block) else @contents ||= @base.lib.object_contents(@objectish) end end |
#contents_array ⇒ Object
43 44 45 |
# File 'lib/git/object.rb', line 43 def contents_array self.contents.split("\n") end |
#diff(objectish) ⇒ Object
56 57 58 |
# File 'lib/git/object.rb', line 56 def diff(objectish) Git::Diff.new(@base, @objectish, objectish) end |
#grep(string, path_limiter = nil, opts = {}) ⇒ Object
51 52 53 54 |
# File 'lib/git/object.rb', line 51 def grep(string, path_limiter = nil, opts = {}) opts = {:object => sha, :path_limiter => path_limiter}.merge(opts) @base.lib.grep(string, opts) end |
#log(count = 30) ⇒ Object
60 61 62 |
# File 'lib/git/object.rb', line 60 def log(count = 30) Git::Log.new(@base, count).object(@objectish) end |
#sha ⇒ Object
21 22 23 |
# File 'lib/git/object.rb', line 21 def sha @sha ||= @base.lib.revparse(@objectish) end |
#tag? ⇒ Boolean
75 |
# File 'lib/git/object.rb', line 75 def tag?; false; end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/git/object.rb', line 47 def to_s @objectish end |
#tree? ⇒ Boolean
69 |
# File 'lib/git/object.rb', line 69 def tree?; false; end |