Class: GitReport::Project

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Project

Returns a new instance of Project.



6
7
8
9
10
11
# File 'lib/project.rb', line 6

def initialize path = nil
  path ||= '.'
  @project = Git.open(path)
  @log = GitReport::Log.new(@project)
  @branch = GitReport::CurrentBranch.new(@project)
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



4
5
6
# File 'lib/project.rb', line 4

def branch
  @branch
end

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/project.rb', line 4

def log
  @log
end

#projectObject

Returns the value of attribute project.



4
5
6
# File 'lib/project.rb', line 4

def project
  @project
end

Instance Method Details

#branchnameObject

returns the branch name



44
45
46
# File 'lib/project.rb', line 44

def branchname
  @branchname ||= self.branch.name
end

#dataObject

returns projects core data as a hash for transfer of a commit batch



49
50
51
# File 'lib/project.rb', line 49

def data
  @data ||= aggregate
end

#identifierObject

returns the projects first commits hash as an identifier



34
35
36
# File 'lib/project.rb', line 34

def identifier
  @identifier ||= self.revlist.last
end

#nameObject

returns the local name of the project extracted from the project directory



19
20
21
# File 'lib/project.rb', line 19

def name
  @name ||= @project.dir.path.match(/.*\/(.*)$/).nil? ? "unknown" : $1
end

#pathObject

returns the local project directory



14
15
16
# File 'lib/project.rb', line 14

def path
  @path ||= @project.dir.path
end

#remote_branchesObject

returns an array of names of all remote branches



29
30
31
# File 'lib/project.rb', line 29

def remote_branches
  @remote_branches ||= @project.branches.remote.map(&:full)
end

#remotesObject

returns an array of remote objects of the project



24
25
26
# File 'lib/project.rb', line 24

def remotes
  @remotes ||= @project.remotes
end

#revlistObject

returns the projects rev-list



39
40
41
# File 'lib/project.rb', line 39

def revlist
  (`git rev-list --all`).split("\n")
end