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

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

Overview

Since:

  • 0.5.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Entry

Returns a new instance of Entry



322
323
324
325
326
327
328
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 322

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

Since:

  • 2.1.0



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def changeset
  @changeset
end

#kindObject

Returns the value of attribute kind



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def kind
  @kind
end

#lastrevObject

Returns the value of attribute lastrev



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def lastrev
  @lastrev
end

#nameObject

Returns the value of attribute name



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def name
  @name
end

#pathObject

Returns the value of attribute path



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def path
  @path
end

#sizeObject

Returns the value of attribute size



320
321
322
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 320

def size
  @size
end

Instance Method Details

#authorObject

Since:

  • 2.1.0



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

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)


334
335
336
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 334

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

#is_file?Boolean

Returns:

  • (Boolean)


330
331
332
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 330

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

#is_text?Boolean

Returns:

  • (Boolean)


338
339
340
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 338

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