Module: Terraspace::Compiler::DirsConcern
- Extended by:
- ActiveSupport::Concern, Memoist
- 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
-
#select_stack?(type_dir, path) ⇒ Boolean
Examples: type_dir stacks path /home/ec2-user/environment/downloads/infra/app/stacks/demo.
- #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
48 49 50 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 48 def dirs(path) Dir.glob("#{Terraspace.root}/#{path}") end |
#local_paths(type_dir) ⇒ Object
44 45 46 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 44 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 32 |
# 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) next unless select_stack?(type_dir, 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 |
#select_stack?(type_dir, path) ⇒ Boolean
Examples:
type_dir stacks
path /home/ec2-user/environment/downloads/infra/app/stacks/demo
38 39 40 41 42 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 38 def select_stack?(type_dir, path) return true unless type_dir == "stacks" select = Terraspace::Compiler::Select.new(path) select.selected? end |
#stack_names ⇒ Object
52 53 54 |
# File 'lib/terraspace/compiler/dirs_concern.rb', line 52 def stack_names mod_names("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, .merge(consider_stacks: consider_stacks)) yield(mod) end end |