Class: Bauble::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/bauble/application.rb

Overview

A Bauble application

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, code_dir:, stacks: [], skip_gem_layer: false, s3_backend: nil) ⇒ Application

Returns a new instance of Application.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bauble/application.rb', line 28

def initialize(name:, code_dir:, stacks: [], skip_gem_layer: false, s3_backend: nil)
  # passed arguments
  @name = name
  @shared_code_dir = code_dir
  @stacks = []
  @skip_gem_layer = skip_gem_layer
  @s3_backend = s3_backend

  # init others
  @resources = []

  # add gem layer by defalt
  add_gem_layer unless skip_gem_layer

  # create a default stack if none passed
  stacks = ['dev'] if stacks.empty?
  stacks.each do |stack|
    Stack.new(self, stack)
  end
  @current_stack = @stacks[0]
end

Instance Attribute Details

#bundle_hashObject

Returns the value of attribute bundle_hash.



13
14
15
# File 'lib/bauble/application.rb', line 13

def bundle_hash
  @bundle_hash
end

#code_dirObject

Returns the value of attribute code_dir.



13
14
15
# File 'lib/bauble/application.rb', line 13

def code_dir
  @code_dir
end

#configObject

Returns the value of attribute config.



13
14
15
# File 'lib/bauble/application.rb', line 13

def config
  @config
end

#current_stackObject

Returns the value of attribute current_stack.



13
14
15
# File 'lib/bauble/application.rb', line 13

def current_stack
  @current_stack
end

#gem_layer_hashObject

Returns the value of attribute gem_layer_hash.



13
14
15
# File 'lib/bauble/application.rb', line 13

def gem_layer_hash
  @gem_layer_hash
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/bauble/application.rb', line 13

def name
  @name
end

#resourcesObject

Returns the value of attribute resources.



13
14
15
# File 'lib/bauble/application.rb', line 13

def resources
  @resources
end

#s3_backendObject

Returns the value of attribute s3_backend.



13
14
15
# File 'lib/bauble/application.rb', line 13

def s3_backend
  @s3_backend
end

#shared_code_dirObject

Returns the value of attribute shared_code_dir.



13
14
15
# File 'lib/bauble/application.rb', line 13

def shared_code_dir
  @shared_code_dir
end

#shared_code_hashObject

Returns the value of attribute shared_code_hash.



13
14
15
# File 'lib/bauble/application.rb', line 13

def shared_code_hash
  @shared_code_hash
end

#skip_gem_layerObject

Returns the value of attribute skip_gem_layer.



13
14
15
# File 'lib/bauble/application.rb', line 13

def skip_gem_layer
  @skip_gem_layer
end

#stacksObject

Returns the value of attribute stacks.



13
14
15
# File 'lib/bauble/application.rb', line 13

def stacks
  @stacks
end

Instance Method Details

#add_resource(resource) ⇒ Object



70
71
72
# File 'lib/bauble/application.rb', line 70

def add_resource(resource)
  @resources << resource
end

#add_stack(stack) ⇒ Object



74
75
76
# File 'lib/bauble/application.rb', line 74

def add_stack(stack)
  @stacks << stack
end

#bundleObject



64
65
66
67
68
# File 'lib/bauble/application.rb', line 64

def bundle
  create_bundle_hashes
  create_shared_code
  @resources.each(&:bundle)
end

#change_current_stack(stack_name) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/bauble/application.rb', line 54

def change_current_stack(stack_name)
  stack = @stacks.find { |st| st.name == stack_name }
  unless stack
    Bauble::Cli::Logger.error "Unknown stack #{stack_name}"
    exit(1)
  end

  @current_stack = stack
end

#templateObject



50
51
52
# File 'lib/bauble/application.rb', line 50

def template
  @template ||= synthesize_template
end