Class: Rubolite::Admin

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

Constant Summary collapse

InvalidPath =
Class.new(Exception)
InvalidGitRepo =
Class.new(Exception)
InvalidRepo =
Class.new(Exception)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Admin

Returns a new instance of Admin.



9
10
11
# File 'lib/rubolite/admin.rb', line 9

def initialize(path=nil)
  @path = path if path && valid_path?(path)
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/rubolite/admin.rb', line 7

def path
  @path
end

#reposObject (readonly)

Returns the value of attribute repos.



7
8
9
# File 'lib/rubolite/admin.rb', line 7

def repos
  @repos
end

Instance Method Details

#add_repo(repo) ⇒ Object Also known as: <<

Raises:



28
29
30
31
# File 'lib/rubolite/admin.rb', line 28

def add_repo(repo)
  raise InvalidRepo, "Repo not type of Rubolite::Repo, got #{repo.class}" unless repo.kind_of?(Repo)
  (@repos ||= []) << repo
end

#clientObject



50
51
52
# File 'lib/rubolite/admin.rb', line 50

def client
  @client ||= Client.new(self)
end

#gitObject



42
43
44
# File 'lib/rubolite/admin.rb', line 42

def git
  @git ||= Git.open(path)
end

#parserObject



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

def parser
  @parser ||= Parser.new("#{path}/conf/gitolite.conf")
end

#repo_originObject



46
47
48
# File 'lib/rubolite/admin.rb', line 46

def repo_origin
  @repo_origin ||= git.remote("origin")
end

#reset!Object



13
14
15
16
17
18
19
20
21
# File 'lib/rubolite/admin.rb', line 13

def reset!
  @parser = nil
  @writer = nil
  @git = nil
  @repo_origin = nil
  @client = nil

  self
end

#writerObject



38
39
40
# File 'lib/rubolite/admin.rb', line 38

def writer
  @writer ||= parser.writer
end