Module: Terraspace::Compiler::DirsConcern
- Extended by:
- ActiveSupport::Concern, Memoist
- Included in:
- All::Preview, Builder, Terraform::Cloud::Syncer, Terraform::RemoteState::Marker::Output
- Defined in:
- lib/terraspace/compiler/dirs_concern.rb
Instance Method Summary collapse
- #cache_dirs ⇒ Object
- #dirs(path) ⇒ Object
- #local_paths(type_dir) ⇒ Object
- #mod_names(type_dir) ⇒ Object
- #stack_names ⇒ Object
- #with_each_mod(type_dir) ⇒ Object
Instance Method Details
#cache_dirs ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 6 def cache_dirs cache_dirs = [] with_each_mod("stacks") do |mod| cache_dirs << mod.cache_dir end cache_dirs end |
#dirs(path) ⇒ Object
38 39 40 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 38 def dirs(path) Dir.glob("#{Terraspace.root}/#{path}") end |
#local_paths(type_dir) ⇒ Object
34 35 36 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 34 def local_paths(type_dir) dirs("app/#{type_dir}/*") + dirs("vendor/#{type_dir}/*") end |
#mod_names(type_dir) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 22 def mod_names(type_dir) names, built = [], [] local_paths(type_dir).each do |path| next unless File.directory?(path) mod_name = File.basename(path) next if built.include?(mod_name) # ensures modules in app folder take higher precedence than vendor folder names << mod_name end names end |
#stack_names ⇒ Object
42 43 44 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 42 def stack_names mod_names("stacks") - Terraspace.config.all.ignore_stacks end |
#with_each_mod(type_dir) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 14 def with_each_mod(type_dir) mod_names(type_dir).each do |mod_name| consider_stacks = type_dir == "stacks" mod = Terraspace::Mod.new(mod_name, @options.merge(consider_stacks: consider_stacks)) yield(mod) end end |