Class: ProjMgr::Scm

Inherits:
Object
  • Object
show all
Defined in:
lib/projmgr/scm.rb

Overview

A parent class for interacting with a source code repository

Author:

Direct Known Subclasses

Cvs, Git, Svn

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project = nil, path = nil, root = nil, url = nil) ⇒ Scm

Creates a instance of a SCM repository

Parameters:

  • project (defaults to: nil)

    name of the project

  • path (defaults to: nil)

    path to the project

  • root (defaults to: nil)

    path back to the root

  • url (defaults to: nil)

    url of the repo for checkout/etc



21
22
23
24
25
26
# File 'lib/projmgr/scm.rb', line 21

def initialize project=nil, path=nil, root=nil, url=nil
	@project = project
	@path = path
	@root = root
	@url = url
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



11
12
13
# File 'lib/projmgr/scm.rb', line 11

def path
  @path
end

#projectObject

Returns the value of attribute project.



11
12
13
# File 'lib/projmgr/scm.rb', line 11

def project
  @project
end

#rootObject

Returns the value of attribute root.



11
12
13
# File 'lib/projmgr/scm.rb', line 11

def root
  @root
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/projmgr/scm.rb', line 11

def url
  @url
end

Instance Method Details

#inspectString

Overloaded inspect

Returns:

  • (String)

    A representation of the class as a string



46
47
48
# File 'lib/projmgr/scm.rb', line 46

def inspect
	return "Project: #{@project}\n" + "Path: #{@path}\n" + "Root: #{@root}\n" + "Url: #{@url}\n"
end

#path_exists?Boolean

Checks to see if a path exists

Returns:

  • (Boolean)

    True or False based on if the @path exists



31
32
33
# File 'lib/projmgr/scm.rb', line 31

def path_exists?
	return File.exists?(File.expand_path(@path))
end

#project_parent_directoryString

Retrieves the parent directory of a path

Returns:

  • (String)

    parent directory of the @path variable



38
39
40
41
# File 'lib/projmgr/scm.rb', line 38

def project_parent_directory
	pn = Pathname.new @path	
	return pn.parent.to_s
end