Sha256: 5c2ce8dbc099bcd3fefa57741356b6484cb4114aafe95f9b0409aa3e209edd70

Contents?: true

Size: 724 Bytes

Versions: 37

Compression:

Stored size: 724 Bytes

Contents

module Terraspace::Compiler::Strategy
  class Mod < AbstractBase
    def run
      klass = strategy_class(@src_path)
      strategy = klass.new(@mod, @src_path) # IE: Terraspace::Compiler::Strategy::Mod::Rb.new
      strategy.run
    end

    def strategy_class(path)
      ext = File.extname(path).sub('.','')
      return Mod::Pass if ext.empty? # infinite loop without this
      return Mod::Pass if Terraspace.pass_file?(path) or !text_file?(path)
      # Fallback to Mod::Tf for all other files. ERB useful for terraform.tfvars
      "Terraspace::Compiler::Strategy::Mod::#{ext.camelize}".constantize rescue Mod::Pass
    end

  private
    def text_file?(filename)
      TextFile.new(filename).check
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
terraspace-2.2.4 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.2.3 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.2.2 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.2.1 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.2.0 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.7 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.6 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.5 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.4 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.3 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.2 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.1 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.1.0 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.0.3 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.0.2 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.0.1 lib/terraspace/compiler/strategy/mod.rb
terraspace-2.0.0 lib/terraspace/compiler/strategy/mod.rb
terraspace-1.1.7 lib/terraspace/compiler/strategy/mod.rb
terraspace-1.1.6 lib/terraspace/compiler/strategy/mod.rb
terraspace-1.1.5 lib/terraspace/compiler/strategy/mod.rb