Class: Subversion::ExternalsContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/svn-command/subversion.rb

Overview

Represents an “externals container”, which is a directory that has the svn:externals property set to something useful. Each ExternalsContainer contains a set of “entries”, which are the actual directories listed in the svn:externals property and are “pulled into” the directory.

Defined Under Namespace

Classes: ExternalItem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_dir) ⇒ ExternalsContainer

Returns a new instance of ExternalsContainer.



454
455
456
457
458
# File 'lib/svn-command/subversion.rb', line 454

def initialize(external_dir)
  @container_dir = File.expand_path(external_dir)
  @entries = Subversion.get_property("externals", @container_dir)
  #p @entries
end

Instance Attribute Details

#container_dirObject (readonly)

Returns the value of attribute container_dir.



451
452
453
# File 'lib/svn-command/subversion.rb', line 451

def container_dir
  @container_dir
end

#entriesObject (readonly)

Returns the value of attribute entries.



452
453
454
# File 'lib/svn-command/subversion.rb', line 452

def entries
  @entries
end

Instance Method Details

#==(other) ⇒ Object



487
488
489
# File 'lib/svn-command/subversion.rb', line 487

def ==(other)
  self.container_dir == other.container_dir
end

#entries_structsObject



464
465
466
467
468
469
# File 'lib/svn-command/subversion.rb', line 464

def entries_structs
  entries.chomp.enum(:each_line).map { |line|
    line =~ /^(\S+)\s*(\S+)/
    ExternalItem.new($1, $2)
  }
end

#has_entries?Boolean

Returns:

  • (Boolean)


460
461
462
# File 'lib/svn-command/subversion.rb', line 460

def has_entries?
  @entries.size > 0
end

#to_sObject



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/svn-command/subversion.rb', line 471

def to_s
  entries_structs = entries_structs()
  longest_item_name = 
    [
      entries_structs.map { |entry|
        entry.name.size
      }.max,
      25
    ].max
  
  container_dir.bold + "\n" +
    entries_structs.map { |entry|
      "  * " + entry.name.ljust(longest_item_name + 1) + entry.repository_path + "\n"
    }.join
end