Module: Ghoul::Repository

Included in:
Application
Defined in:
lib/ghoul/lib/repository.rb

Defined Under Namespace

Classes: NoCommits

Instance Method Summary collapse

Instance Method Details

#commit_from_repository(repository, commit_id) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/ghoul/lib/repository.rb', line 23

def commit_from_repository(repository, commit_id)
  if commit_id == "trunk"
    commit = repository(repository).commits.first or raise NoCommits
  else
    commit = repository(repository).commit(params[:commit])
  end
  return commit
end

#create_repository(name) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/ghoul/lib/repository.rb', line 32

def create_repository(name)
  path = File.join(repos_path, name)
  if File.exist?(path)
   return  false
  end
  Grit::Repo.init_bare(path)
end

#repos_pathObject



3
4
5
6
7
# File 'lib/ghoul/lib/repository.rb', line 3

def repos_path
  home = ENV['HOME']
  repos_path = File.join(home, "repos")
  return repos_path
end

#repos_path_exists?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/ghoul/lib/repository.rb', line 9

def repos_path_exists?
  File.directory? repos_path
end

#repositoriesObject



18
19
20
21
# File 'lib/ghoul/lib/repository.rb', line 18

def repositories
  directory_entries = Dir.entries(repos_path)
  return directory_entries.find_all { |r| File.directory?( File.join(repos_path, r) ) }
end

#repository(name) ⇒ Object



13
14
15
16
# File 'lib/ghoul/lib/repository.rb', line 13

def repository(name)
  path = File.join(repos_path, name)
  return Grit::Repo.new(path, :is_bare => true)
end