Class: Polytrix::Implementor
Defined Under Namespace
Classes: GitOptions
Instance Attribute Summary
Attributes included from Executor
#env, #executor
Instance Method Summary
collapse
Methods included from Executor
#execute
#find_file, #relativize
included
#ansi2html, #escape_html, #highlight, #slugify
Constructor Details
Returns a new instance of Implementor.
32
33
34
35
|
# File 'lib/polytrix/implementor.rb', line 32
def initialize(data)
data[:basedir] = File.absolute_path(data[:basedir])
super
end
|
Instance Method Details
#bootstrap ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/polytrix/implementor.rb', line 58
def bootstrap
banner "Bootstrapping #{name}"
fail "Implementor #{name} has not been cloned" unless cloned?
execute('./scripts/bootstrap', cwd: basedir, prefix: name)
rescue ExecutionError => e
if e.cause.is_a? Errno::ENOENT
logger.warn "Skipping bootstrapping for #{name}, no script/bootstrap exists"
else
raise e
end
end
|
#build_challenge(challenge_data) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/polytrix/implementor.rb', line 72
def build_challenge(challenge_data)
challenge_data[:basedir] ||= basedir
challenge_data[:implementor] ||= self
challenge_data[:suite] ||= ''
begin
challenge_data[:source_file] ||= find_file basedir, challenge_data[:name]
challenge_data[:source_file] = relativize(challenge_data[:source_file], challenge_data[:basedir])
rescue Errno::ENOENT
challenge_data[:source_file] = nil
end
Challenge.new challenge_data
end
|
#clone ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/polytrix/implementor.rb', line 41
def clone
if git.nil? || git.repo.nil?
logger.info 'Skipping clone because there are no git options'
return
end
branch = git.branch ||= 'master'
target_dir = git.to ||= basedir
if File.exist? target_dir
logger.info "Skipping clone because #{target_dir} already exists"
else
clone_cmd = "git clone #{git.repo} -b #{branch} #{target_dir}"
logger.info "Cloning: #{clone_cmd}"
execute clone_cmd
end
end
|
#cloned? ⇒ Boolean
85
86
87
|
# File 'lib/polytrix/implementor.rb', line 85
def cloned?
File.directory? basedir
end
|