Class: Gollum::Git::Blob
- Inherits:
-
Object
- Object
- Gollum::Git::Blob
- Defined in:
- lib/rugged_adapter/git_layer_rugged.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(blob, options = {}) ⇒ Blob
constructor
A new instance of Blob.
- #is_symlink ⇒ Object
- #mime_type ⇒ Object
- #size ⇒ Object
- #symlink_target(base_path = nil) ⇒ Object
Constructor Details
#initialize(blob, options = {}) ⇒ Blob
Returns a new instance of Blob.
62 63 64 65 66 67 68 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 62 def initialize(blob, = {}) @blob = blob @mode = [:mode] @name = [:name] @size = [:size] @id = blob.oid end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
55 56 57 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 55 def id @id end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
53 54 55 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 53 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
54 55 56 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 54 def name @name end |
Class Method Details
.create(repo, options) ⇒ Object
57 58 59 60 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 57 def self.create(repo, ) blob = repo.git.lookup([:id]) self.new(blob, ) end |
Instance Method Details
#data ⇒ Object
70 71 72 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 70 def data @content ||= @blob.content end |
#is_symlink ⇒ Object
74 75 76 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 74 def is_symlink @mode == 0120000 end |
#mime_type ⇒ Object
78 79 80 81 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 78 def mime_type guesses = MIME::Types.type_for(self.name) rescue [] guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE end |
#size ⇒ Object
83 84 85 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 83 def size @size || @blob.size end |
#symlink_target(base_path = nil) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 87 def symlink_target(base_path = nil) target = data new_path = ::File.(::File.join('..', target), base_path) return new_path if ::File.file? new_path nil end |