Class: Gitti::GitMirror

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ GitMirror

Returns a new instance of GitMirror.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/gitti/mirror.rb', line 14

def initialize( path )
  raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitMirror class - sorry"   unless Dir.exist?( path )
  ## todo/check:  check for more dirs and files e.g.
  ##  /info,/objects,/refs, /hooks, HEAD, config, description -- why? why not?
  raise ArgumentError, "dir >#{path}/objects< not found; dir MUST already be initialized with git for GitMirror class - sorry"  unless Dir.exist?( "#{path}/objects" )
  @path = path
end

Class Method Details

.open(path, &blk) ⇒ Object



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

def self.open( path, &blk )
  new( path ).open( &blk )
end

.update(path) ⇒ Object

all-in-one convenience shortcut



8
9
10
# File 'lib/gitti/mirror.rb', line 8

def self.update( path )    ### all-in-one convenience shortcut
  new( path).open { |mirror| mirror.update }
end

Instance Method Details

#open(&blk) ⇒ Object



23
24
25
26
27
# File 'lib/gitti/mirror.rb', line 23

def open( &blk )
  Dir.chdir( @path ) do
    blk.call( self )
  end
end

#updateObject



29
# File 'lib/gitti/mirror.rb', line 29

def update()           Git.update; end