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
pre_generate
generate_templates post_generate
upload_templates
@@parameters = param_generator.generate check_for_errors
@@parameters
end
|
#build_files ⇒ Object
52
53
54
|
# File 'lib/lono/generate.rb', line 52
def build_files
Lono::AppFile::Build.new(@options).run
end
|
#build_scripts ⇒ Object
48
49
50
|
# File 'lib/lono/generate.rb', line 48
def build_scripts
Lono::Script::Build.new(@options).run
end
|
#check_files ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/lono/generate.rb', line 85
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
76
77
78
79
80
81
82
83
|
# File 'lib/lono/generate.rb', line 76
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
42
43
44
45
46
|
# File 'lib/lono/generate.rb', line 42
def ensure_s3_bucket_exist
bucket = Lono::S3::Bucket.new
return if bucket.exist?
bucket.deploy
end
|
#generate_templates ⇒ Object
#param_generator ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/lono/generate.rb', line 32
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
23
24
25
26
27
28
29
30
|
# File 'lib/lono/generate.rb', line 23
def post_generate
return if @options[:noop]
return if @options[:source]
build_files post_process_template
upload_files
upload_scripts
end
|
#post_process_template ⇒ Object
#pre_generate ⇒ Object
19
20
21
|
# File 'lib/lono/generate.rb', line 19
def pre_generate
build_scripts
end
|
#upload_files ⇒ Object
72
73
74
|
# File 'lib/lono/generate.rb', line 72
def upload_files
Lono::AppFile::Upload.new(@options).upload
end
|
#upload_scripts ⇒ Object
68
69
70
|
# File 'lib/lono/generate.rb', line 68
def upload_scripts
Lono::Script::Upload.new(@options).run
end
|
#upload_templates ⇒ Object