Class: Ufo::Layering::Layer
- Inherits:
-
Object
- Object
- Ufo::Layering::Layer
- Extended by:
- Memoist
- Includes:
- Ufo::Layering, Utils::Logging, Utils::Pretty
- Defined in:
- lib/ufo/layering/layer.rb
Instance Method Summary collapse
- #add_ext!(paths) ⇒ Object
-
#initialize(task_definition) ⇒ Layer
constructor
A new instance of Layer.
-
#layer_levels(prefix = nil) ⇒ Object
adds prefix and to each layer pair that has base and Ufo.env.
-
#main_layers ⇒ Object
interface method.
- #paths ⇒ Object
- #show_layers(paths) ⇒ Object
Methods included from Utils::Pretty
#pretty_home, #pretty_path, #pretty_time
Methods included from Utils::Logging
Methods included from Ufo::Layering
#layers, #post_layers, #pre_layers
Constructor Details
#initialize(task_definition) ⇒ Layer
Returns a new instance of Layer.
21 22 23 |
# File 'lib/ufo/layering/layer.rb', line 21 def initialize(task_definition) @task_definition = task_definition end |
Instance Method Details
#add_ext!(paths) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/ufo/layering/layer.rb', line 63 def add_ext!(paths) paths.map! do |path| path = path.sub(/\/$/,'') if path.ends_with?('/') "#{path}.rb" end paths end |
#layer_levels(prefix = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ufo/layering/layer.rb', line 46 def layer_levels(prefix=nil) levels = ["", "base", Ufo.env] levels << "#{Ufo.env}-#{Ufo.extra}" if Ufo.extra levels.map! do |i| # base layer has prefix of '', reject with blank so it doesnt produce '//' [prefix, i].reject(&:blank?).join('/') end levels.map! { |level| level.sub(/\/$/,'') } # strip trailing slash # levels.unshift(prefix) # unless prefix.blank? # IE: params/us-west-2.txt levels end |
#main_layers ⇒ Object
interface method
59 60 61 |
# File 'lib/ufo/layering/layer.rb', line 59 def main_layers [''] end |
#paths ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ufo/layering/layer.rb', line 25 def paths # core = full_layers(".ufo/vars") # app = full_layers(".ufo/vars/#{Ufo.app}") core = layer_levels(".ufo/vars") role = layer_levels(".ufo/vars/#{@task_definition.role}") app = layer_levels(".ufo/vars/#{Ufo.app}") app_role = layer_levels(".ufo/vars/#{Ufo.app}/#{@task_definition.role}") paths = core + role + app + app_role add_ext!(paths) paths.map! { |p| "#{Ufo.root}/#{p}" } show_layers(paths) paths end |
#show_layers(paths) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ufo/layering/layer.rb', line 71 def show_layers(paths) logger.debug "Layers:" paths.each do |path| if ENV['UFO_LAYERS_ALL'] logger.info " #{pretty_path(path)}" elsif Ufo.config.layering.show logger.info " #{pretty_path(path)}" if File.exist?(path) end end end |