Class: Ed::Repository

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, copy = true) ⇒ Repository

Returns a new instance of Repository.

Parameters:

  • path (String, #to_s)

    The URI to a git repository.

  • copy (Boolean) (defaults to: true)

    If true, a copy of the repository is created.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ed/repository.rb', line 25

def initialize path, copy = true
  if copy
    @path = copy!(path.to_s)
    @copy = true
  else
    @path = path.to_s
    @copy = false
  end

  parent = Process.pid

  ObjectSpace.define_finalizer(self) do
    if parent == Process.pid
      FileUtils.rm_rf(@path)
    end
  end
end

Instance Attribute Details

#copyBoolean (readonly) Also known as: copy?

Returns Has the repository been copied?.

Returns:

  • (Boolean)

    Has the repository been copied?



15
16
17
# File 'lib/ed/repository.rb', line 15

def copy
  @copy
end

#pathString (readonly)

Returns The path to the repository on local disk.

Returns:

  • (String)

    The path to the repository on local disk.



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

def path
  @path
end

Instance Method Details

#checkout(*args) ⇒ void

This method returns an undefined value.

Parameters:

  • *options (String)

    The same commands given to ‘git checkout’



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

def checkout *args
  git "checkout", *args
end