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.
61 62 63 64 65 66 67 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 61 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.
54 55 56 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 54 def id @id end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
52 53 54 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 52 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
53 54 55 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 53 def name @name end |
Class Method Details
.create(repo, options) ⇒ Object
56 57 58 59 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 56 def self.create(repo, ) blob = repo.git.lookup([:id]) self.new(blob, ) end |
Instance Method Details
#data ⇒ Object
69 70 71 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 69 def data @content ||= @blob.content end |
#is_symlink ⇒ Object
73 74 75 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 73 def is_symlink @mode == 0120000 end |
#mime_type ⇒ Object
77 78 79 80 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 77 def mime_type guesses = MIME::Types.type_for(self.name) rescue [] guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE end |
#size ⇒ Object
82 83 84 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 82 def size @size || @blob.size end |
#symlink_target(base_path = nil) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 86 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 |