/
garlic.rb
37 lines (32 loc) · 924 Bytes
/
garlic.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require "garlic/session"
require "garlic/configurator"
require "garlic/repo"
require "garlic/target"
require "garlic/generator"
require "garlic/shell"
module Garlic
include Generator
module Version
Major = 0
Minor = 1
Tiny = 9
String = [Major, Minor, Tiny].join('.')
end
# return the current garlic session
def garlic(config = nil, &block)
@garlic ||= Garlic::Session.new(self)
load_config(config)
@garlic.configure(&block) if block_given?
@garlic
end
# load config from
def load_config(config = nil)
unless @garlic_config_file
@garlic_config_file = config || "garlic.rb"
unless File.exists?(@garlic_config_file)
raise "garlic requries a configuration file (can't find #{@garlic_config_file}), try:\n garlic generate [#{available_templates.join('|')}] > garlic.rb"
end
eval File.read(@garlic_config_file)
end
end
end