Class: Terraspace::Compiler::Perform::Skip

Inherits:
Object
  • Object
show all
Defined in:
lib/terraspace/compiler/perform/skip.rb

Instance Method Summary collapse

Constructor Details

#initialize(mod, src_path) ⇒ Skip

Returns a new instance of Skip.



3
4
5
# File 'lib/terraspace/compiler/perform/skip.rb', line 3

def initialize(mod, src_path)
  @mod, @src_path = mod, src_path
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/terraspace/compiler/perform/skip.rb', line 7

def check?
  return true unless File.file?(@src_path)

  # skip certain folders
  check_dirs?(
    "config/args",
    "config/helpers",
    "config/hooks",
    "test",
    "tfvars",
  )
end

#check_dir?(name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/terraspace/compiler/perform/skip.rb', line 24

def check_dir?(name)
  @src_path.include?("#{@mod.root}/#{name}/")
end

#check_dirs?(*names) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/terraspace/compiler/perform/skip.rb', line 20

def check_dirs?(*names)
  names.flatten.detect { |name| check_dir?(name) }
end