Class: Ed

Inherits:
Object
  • Object
show all
Includes:
Observe
Defined in:
lib/ed.rb,
lib/ed/version.rb

Defined Under Namespace

Modules: Config, Env Classes: Delegator, Repository, RepositoryCopy

Constant Summary collapse

VERSION =
"0.8.2"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) {|_self| ... } ⇒ Ed

Parameters:

  • path (String)

    The path to a git repository.

  • &block (Proc)

    Executed in the scope of Delegator.

Yield Parameters:

  • _self (Ed)

    Yields self in the calling scope, if a block parameter is given.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ed.rb', line 43

def initialize path, &block
  if Ed::Repository.remote?(path) || Ed::Config.copy_repository?
    @repo = Ed::RepositoryCopy.new(path)
  else
    @repo = Ed::Repository.new(path)
  end

  if block_given?
    if block.arity == 1
      yield self
    else
      delegator = Ed::Delegator.new(self)
      delegator.instance_eval(&block)
    end
  end
end

Class Method Details

.configure {|config| ... } ⇒ Object

Examples:


Ed::Config.change do |config|
  config.should_fork = true
end

Yield Parameters:



27
28
29
# File 'lib/ed.rb', line 27

def self.configure &block
  Ed::Config.change(&block)
end

Instance Method Details

#commit(commit, &block) {|path| ... } ⇒ void Also known as: tag, branch

This method returns an undefined value.

Parameters:

  • commit (String)

    A valid git commit, or git commit reference(tag or branch name).

  • block (Proc)

    Executed while the repository has switched to commit.

Yield Parameters:

  • path (String)

    The path to the repository on local disk.



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ed.rb', line 85

def commit commit, &block
  if Ed::Config.should_fork?
    pid = fork do
      switch(commit, &block)
    end

    Process.wait(pid)
  else
    switch(commit, &block)
  end
end

#setup(&block) {|path| ... } ⇒ void

This method returns an undefined value.

Parameters:

Yield Parameters:

  • path (String)

    The path to the repository on local disk.



69
70
71
# File 'lib/ed.rb', line 69

def setup &block
  add_observer(:setup_block, &block)
end