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.6.0"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:

  • path (String)

    The path to a git repository.

Yield Parameters:

  • _self (Ed)

    Yields self, if a block is given.



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

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| ... } ⇒ void

This method returns an undefined value.

Examples:

Ed.configure do |config|
  config.fork = true
end

Yield Parameters:



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

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

Instance Method Details

#before(stage, &block) {|path| ... } ⇒ void

This method returns an undefined value.

Parameters:

Yield Parameters:

  • path (String)

    The path to the repository on local disk.



59
60
61
# File 'lib/ed.rb', line 59

def before stage, &block
  add_observer(:before_filter, &block)
end

#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.



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

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

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