Class: Grundstein::Generator::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/grundstein/generator/repository.rb

Overview

Manages the generator repository. Implemented as a singleton (see instance method). It uses git to keep the repository up to date. It will check the repo out to ‘~/.grundstein’. It also creates a file in this directory named ‘last_update’ where the timestamp of the last update is kept. If this time stamp is too long ago, it will update the repo.

Use this class by using the instance method: Generator::Repository.instance

Constant Summary collapse

OUTDATED_THRESHOLD =

day(s)

1

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



17
18
19
20
# File 'lib/grundstein/generator/repository.rb', line 17

def self.instance
  @instance ||= Repository.new(File.expand_path("~/.grundstein"))
  return @instance
end

Instance Method Details

#generator_path(name) ⇒ Object



36
37
38
# File 'lib/grundstein/generator/repository.rb', line 36

def generator_path(name)
  return File.join(generators_path, name)
end

#generatorsObject

Iteratates through all generators and yields the block with the |name, desc|.



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

def generators
  result = []
  Dir.foreach(generators_path) do |dir|
    next if dir.start_with?('.', '#')
    result << dir
  end
  return result
end

#generators_pathObject



32
33
34
# File 'lib/grundstein/generator/repository.rb', line 32

def generators_path
  return File.join(@path, 'generators')
end