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.



63
64
65
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 63

def initialize(blob)
  @blob = blob
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



51
52
53
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 51

def size
  @size
end

Class Method Details

.create(repo, options) ⇒ Object

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



54
55
56
57
58
59
60
61
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 54

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



80
81
82
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 80

def data
  @blob.data
end

#idObject



72
73
74
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 72

def id
  @blob.id
end


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

def is_symlink
  @blob.is_symlink?
end

#mime_typeObject



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

def mime_type
  @blob.mime_type
end

#modeObject



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

def mode
  @blob.mode
end

#nameObject



84
85
86
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 84

def name
  @blob.name
end

#set_size(size) ⇒ Object

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



68
69
70
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 68

def set_size(size)
  @size = size
end


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

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