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

Constant Summary collapse

VERSION =
"0.7.0"

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, if a block parameter is given.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ed.rb', line 39

def initialize path, &block
  @repo = Ed::Repository.new(path)

  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:



23
24
25
# File 'lib/ed.rb', line 23

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.



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ed.rb', line 77

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.



61
62
63
# File 'lib/ed.rb', line 61

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