module TerraspaceBundler::Mod::Concerns::StackConcern
Public Instance Methods
all_stacks()
click to toggle source
# File lib/terraspace_bundler/mod/concerns/stack_concern.rb, line 17 def all_stacks stack = TerraspaceBundler::Exporter::Stacks::Stack.new(self) # to get the mod src path expr = "#{stack.examples_folder}/*" dirs = Dir.glob(expr).select { |path| File.directory?(path) } dirs.map do |dir| example = File.basename(dir) # Set name so multiple app/stacks are created instead of just one app/stack/MOD { name: example, src: example, } end end
all_stacks?(*stacks)
click to toggle source
# File lib/terraspace_bundler/mod/concerns/stack_concern.rb, line 13 def all_stacks?(*stacks) stacks.flatten == [:all] end
normalize_stacks(option)
click to toggle source
Normalizes stack options to an Array of Hashes or just a single Hash
# File lib/terraspace_bundler/mod/concerns/stack_concern.rb, line 32 def normalize_stacks(option) defaults = TB.config.stack_options.dup result = case option when String [defaults.merge(src: option)] when Array option.map! {|s| normalize_stacks(s) } else # Hash [defaults.merge!(option)] end result.flatten end
stacks()
click to toggle source
# File lib/terraspace_bundler/mod/concerns/stack_concern.rb, line 3 def stacks stacks = @props[:stacks] || @props[:stack] return unless stacks if all_stacks?(stacks) stacks = all_stacks end normalize_stacks(stacks) end
Also aliased as: stack