Class: Clenver::Runner
- Inherits:
-
Object
show all
- Includes:
- Logging
- Defined in:
- lib/clenver/runner.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
configure_logger_for, #logger, logger_for
Constructor Details
#initialize(path, dst) ⇒ Runner
Returns a new instance of Runner.
13
14
15
16
17
|
# File 'lib/clenver/runner.rb', line 13
def initialize(path, dst)
@path = path
@dst = dst
@yaml = parse_config
end
|
Instance Attribute Details
#dst ⇒ Object
Returns the value of attribute dst.
12
13
14
|
# File 'lib/clenver/runner.rb', line 12
def dst
@dst
end
|
#path ⇒ Object
Returns the value of attribute path.
12
13
14
|
# File 'lib/clenver/runner.rb', line 12
def path
@path
end
|
#yaml ⇒ Object
Returns the value of attribute yaml.
12
13
14
|
# File 'lib/clenver/runner.rb', line 12
def yaml
@yaml
end
|
Instance Method Details
#create_cmd_exec ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/clenver/runner.rb', line 49
def create_cmd_exec
e = []
for c in yaml['run']
e << CommandExecutor.new(c)
end
return e
end
|
#create_links ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/clenver/runner.rb', line 41
def create_links
l = []
for src, links in yaml['links']
l << Link.new(src, links)
end
return l
end
|
#create_package_manager(type) ⇒ Object
28
29
30
|
# File 'lib/clenver/runner.rb', line 28
def create_package_manager(type)
PackageManger.new(type, yaml[type].join(' '))
end
|
#create_repository(uri) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/clenver/runner.rb', line 32
def create_repository(uri)
logger.debug("content:#{yaml[uri]}")
if yaml[uri].is_a?(Hash)
Repository.new(uri, yaml[uri])
else
Repository.new(uri)
end
end
|
#parse_config ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/clenver/runner.rb', line 19
def parse_config
begin
Psych.load_file("#{path}")
rescue Psych::SyntaxError => ex
logger.error("#{path}: syntax error : #{ex.message}")
exit 1
end
end
|
#start ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/clenver/runner.rb', line 57
def start
p = Project.new(File.basename("#{path}", ".yml"), yaml, dst)
if yaml.is_a?(Hash)
for k,v in yaml do
logger.info("key:#{k}")
logger.info("value:#{v}")
if k == 'apt' or k == 'gem'
p.pkg_mgr << create_package_manager(k)
end
if k.match /(http|https|git).+/
p.repos << create_repository(k)
end
if k == 'links'
p.links = create_links
end
if k == 'run'
p.cmd_exec = create_cmd_exec
end
end
else
logger.error("#{path} is not a valid clenver configuration")
exit 2
end
p.init
end
|