Class: Redmine::Scm::Adapters::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/scm/adapters/abstract_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Entry

Returns a new instance of Entry.



348
349
350
351
352
353
354
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 348

def initialize(attributes={})
  self.name = attributes[:name] if attributes[:name]
  self.path = attributes[:path] if attributes[:path]
  self.kind = attributes[:kind] if attributes[:kind]
  self.size = attributes[:size].to_i if attributes[:size]
  self.lastrev = attributes[:lastrev]
end

Instance Attribute Details

#changesetObject

Returns the value of attribute changeset.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def changeset
  @changeset
end

#kindObject

Returns the value of attribute kind.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def kind
  @kind
end

#lastrevObject

Returns the value of attribute lastrev.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def lastrev
  @lastrev
end

#nameObject

Returns the value of attribute name.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def name
  @name
end

#pathObject

Returns the value of attribute path.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def path
  @path
end

#sizeObject

Returns the value of attribute size.



346
347
348
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 346

def size
  @size
end

Instance Method Details

#authorObject



368
369
370
371
372
373
374
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 368

def author
  if changeset
    changeset.author.to_s
  elsif lastrev
    Redmine::CodesetUtil.replace_invalid_utf8(lastrev.author.to_s.split('<').first)
  end
end

#is_dir?Boolean

Returns:

  • (Boolean)


360
361
362
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 360

def is_dir?
  self.kind == 'dir'
end

#is_file?Boolean

Returns:

  • (Boolean)


356
357
358
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 356

def is_file?
  self.kind == 'file'
end

#is_text?Boolean

Returns:

  • (Boolean)


364
365
366
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 364

def is_text?
  Redmine::MimeType.is_type?('text', name)
end