Class: Lono::Generate
Constant Summary
collapse
- @@parameters =
Use class variable to cache this only runs once across all classes. base.rb, diff.rb, preview.rb
nil
Instance Method Summary
collapse
#initialize, #reinitialize, #template_path
#find_blueprint_root, #set_blueprint_root
Instance Method Details
#all ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/lono/generate.rb', line 5
def all
return @@parameters if @@parameters
ensure_s3_bucket_exist unless generate_only?
pre_generate
generate_templates post_generate
upload unless generate_only?
@@parameters = param_generator.generate check_for_errors
@@parameters
end
|
#build_scripts ⇒ Object
51
52
53
|
# File 'lib/lono/generate.rb', line 51
def build_scripts
Lono::Script::Build.new(@options).run
end
|
#check_files ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/lono/generate.rb', line 103
def check_files
errors = []
unless File.exist?(template_path)
errors << "Template file missing: could not find #{template_path}"
end
errors
end
|
#check_for_errors ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'lib/lono/generate.rb', line 94
def check_for_errors
errors = check_files
unless errors.empty?
puts "Please double check the command you ran. There were some errors."
puts "ERROR: #{errors.join("\n")}".color(:red)
exit
end
end
|
#ensure_s3_bucket_exist ⇒ Object
45
46
47
48
49
|
# File 'lib/lono/generate.rb', line 45
def ensure_s3_bucket_exist
bucket = Lono::S3::Bucket.new
return if bucket.exist?
bucket.deploy
end
|
#generate_only? ⇒ Boolean
19
20
21
|
# File 'lib/lono/generate.rb', line 19
def generate_only?
ENV['LONO_GENERATE_ONLY'] || @options[:generate_only]
end
|
#generate_templates ⇒ Object
60
61
62
63
|
# File 'lib/lono/generate.rb', line 60
def generate_templates
Lono::Template::Generator.new(@options).run inject_configsets
end
|
#inject_configsets ⇒ Object
#param_generator ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/lono/generate.rb', line 35
def param_generator
o = {
regenerate: true,
allow_not_exists: true,
}.merge(@options)
o = HashWithIndifferentAccess.new(o)
Lono::Param::Generator.new(o)
end
|
#post_generate ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/lono/generate.rb', line 27
def post_generate
return if @options[:noop]
return if @options[:source]
build_files post_process_template
end
|
#post_process_template ⇒ Object
#pre_generate ⇒ Object
23
24
25
|
# File 'lib/lono/generate.rb', line 23
def pre_generate
build_scripts
end
|
#upload ⇒ Object
75
76
77
78
79
|
# File 'lib/lono/generate.rb', line 75
def upload
upload_files
upload_scripts
upload_templates
end
|
#upload_scripts ⇒ Object
85
86
87
|
# File 'lib/lono/generate.rb', line 85
def upload_scripts
Lono::Script::Upload.new(@options).run
end
|
#upload_templates ⇒ Object