Class: LearnLab::VCS

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_lab/vcs.rb

Overview

Adapter for the Version Control System.

Instance Method Summary collapse

Constructor Details

#initialize(directory, &block) ⇒ VCS

Returns a new instance of VCS.

[View source]

7
8
9
10
11
12
13
14
# File 'lib/learn_lab/vcs.rb', line 7

def initialize(directory, &block)
  @repo = Git.open(directory)
rescue StandardError => e
  msg = "You don't appear to be in a Learn lesson's directory. Please " \
        'cd to an appropriate directory and try again.'

  block_given? ? block.call(msg, e) : raise(LearnLab::Error.new(msg))
end

Instance Method Details

#remote_urlObject

[View source]

16
17
18
# File 'lib/learn_lab/vcs.rb', line 16

def remote_url
  @repo.remote.url
end

#working_directoryObject

[View source]

20
21
22
# File 'lib/learn_lab/vcs.rb', line 20

def working_directory
  @repo.dir.path
end