Class: Bob::SCM::Abstract

Inherits:
Object show all
Defined in:
lib/bob/scm/abstract.rb

Direct Known Subclasses

Git

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, branch) ⇒ Abstract

Returns a new instance of Abstract.



6
7
8
9
# File 'lib/bob/scm/abstract.rb', line 6

def initialize(uri, branch)
  @uri = Addressable::URI.parse(uri)
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



4
5
6
# File 'lib/bob/scm/abstract.rb', line 4

def branch
  @branch
end

#uriObject (readonly)

Returns the value of attribute uri.



4
5
6
# File 'lib/bob/scm/abstract.rb', line 4

def uri
  @uri
end

Instance Method Details

#info(commit_id) ⇒ Object

Get some information about the specified commit. Returns a hash with:

:author

Commit author’s name and email

:message

Commit message

:committed_at

Commit date (as a Time object)

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/bob/scm/abstract.rb', line 32

def info(commit_id)
  raise NotImplementedError
end

#with_commit(commit_id) ⇒ Object

Checkout the code into working_dir at the specified revision and call the passed block



13
14
15
16
17
# File 'lib/bob/scm/abstract.rb', line 13

def with_commit(commit_id)
  update_code
  checkout(commit_id)
  yield
end

#working_dirObject

Directory where the code will be checked out. Make sure the user running Bob is allowed to write to this directory (or you’ll get a Errno::EACCESS)



21
22
23
24
25
# File 'lib/bob/scm/abstract.rb', line 21

def working_dir
  @working_dir ||= "#{Bob.directory}/#{path_from_uri}".tap do |path|
    FileUtils.mkdir_p path
  end
end