Class: Jack::Create
- Inherits:
-
Object
show all
- Includes:
- Util
- Defined in:
- lib/jack/create.rb
Instance Method Summary
collapse
Methods included from Util
#app_name_convention, #aws_bin, #check_aws_setup, #confirm, #eb, #eb_base_flags, #eb_bin, #ensure_folder_exist, #get_answer, #get_region, #prerequisites, #settings, #sh
Constructor Details
#initialize(options = {}) ⇒ Create
Returns a new instance of Create.
7
8
9
10
11
12
|
# File 'lib/jack/create.rb', line 7
def initialize(options={})
@options = options
@root = options[:root] || '.'
@env_name = options[:env_name]
@app_name = options[:app] || app_name_convention(@env_name)
end
|
Instance Method Details
#app_exist? ⇒ Boolean
26
27
28
29
30
|
# File 'lib/jack/create.rb', line 26
def app_exist?
return true if @options[:noop]
r = eb.describe_applications
r.applications.collect(&:application_name).include?(@app_name)
end
|
#build_command ⇒ Object
37
38
39
40
41
|
# File 'lib/jack/create.rb', line 37
def build_command
@cfg = upload_cfg
flags = settings.create_flags
"#{eb_bin} create#{eb_base_flags} --sample --nohang #{flags} #{@cfg}#{cname}#{@env_name}"
end
|
#cname ⇒ Object
51
52
53
|
# File 'lib/jack/create.rb', line 51
def cname
"--cname #{@env_name} "
end
|
#create_app ⇒ Object
20
21
22
23
24
|
# File 'lib/jack/create.rb', line 20
def create_app
eb.create_application(
application_name: @app_name
) unless app_exist?
end
|
#create_env ⇒ Object
32
33
34
35
|
# File 'lib/jack/create.rb', line 32
def create_env
command = build_command
sh(command, @options)
end
|
#run ⇒ Object
14
15
16
17
18
|
# File 'lib/jack/create.rb', line 14
def run
prerequisites
create_app
create_env
end
|
#upload_cfg ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/jack/create.rb', line 43
def upload_cfg
@upload = Config::Apply.new(@options)
if @upload.local_cfg_exist?
@upload.upload
cfg = "--cfg #{@upload.upload_name} "
end
end
|