Class: Fiveruns::Dash::SCM

Inherits:
Object show all
Includes:
Typable
Defined in:
lib/fiveruns/dash/scm.rb

Direct Known Subclasses

GitSCM, SvnSCM

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Typable

included

Constructor Details

#initialize(path) ⇒ SCM

Returns a new instance of SCM.



29
30
31
32
# File 'lib/fiveruns/dash/scm.rb', line 29

def initialize(path)
  @path = path
  require_binding
end

Class Method Details

.best_match(scm_paths) ⇒ Object



25
26
27
# File 'lib/fiveruns/dash/scm.rb', line 25

def self.best_match( scm_paths )
  scm_paths.max{|a,b| a.split("/").length <=> b.split("/").length}
end

.matching(startpath) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fiveruns/dash/scm.rb', line 6

def self.matching(startpath)
  scm_hash = {}
  types.each do |name, klass|
    if path = locate_upwards(startpath, ".#{name}")
      Fiveruns::Dash.logger.info "SCM: Found #{name} in #{path}"
      scm_hash[path] = klass
    end
  end
  winning_path = best_match(scm_hash.keys)
  return nil if winning_path.nil?
  Fiveruns::Dash.logger.info "SCM: Using #{scm_hash[winning_path].name} in #{winning_path}" 
  begin
    scm_hash[winning_path].new(winning_path)
  rescue Exception => e
    Fiveruns::Dash.logger.warn "WARNING: #{e.message}"
    nil
  end
end

Instance Method Details

#revisionObject

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/fiveruns/dash/scm.rb', line 38

def revision
  raise NotImplementedError, 'Abstract'
end

#timeObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/fiveruns/dash/scm.rb', line 34

def time
  raise NotImplementedError, 'Abstract'
end