Class: Gollum::Git::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/rjgit_adapter/git_layer_rjgit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blob) ⇒ Blob

Returns a new instance of Blob.



88
89
90
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 88

def initialize(blob)
  @blob = blob
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



76
77
78
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 76

def size
  @size
end

Class Method Details

.create(repo, options) ⇒ Object

Gollum::Git::Blob.create(repo, :id => @sha, :name => name, :size => @size, :mode => @mode)



79
80
81
82
83
84
85
86
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 79

def self.create(repo, options)
  blob = repo.find(options[:id], :blob)
  jblob = blob.jblob unless blob.nil?
  return nil if jblob.nil?
  blob = self.new(RJGit::Blob.new(repo.repo, options[:mode], options[:name], jblob))
  blob.set_size(options[:size]) if options[:size]
  return blob
end

Instance Method Details

#dataObject



105
106
107
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 105

def data
  @blob.data
end

#idObject



97
98
99
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 97

def id
  @blob.id
end


117
118
119
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 117

def is_symlink
  @blob.is_symlink?
end

#mime_typeObject



113
114
115
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 113

def mime_type
  @blob.mime_type
end

#modeObject



101
102
103
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 101

def mode
  @blob.mode
end

#nameObject



109
110
111
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 109

def name
  @blob.name
end

#set_size(size) ⇒ Object

Not required by gollum-lib. Should be private/protected?



93
94
95
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 93

def set_size(size)
  @size = size
end


121
122
123
124
125
126
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 121

def symlink_target(base_path = nil)
  target = @blob.data
  new_path = ::File.expand_path(::File.join('..', target), base_path)
  return new_path if ::File.file? new_path
  nil
end