Sha256: 04855be514d64460158960ac040e029df5df1708487b2e10bc5d3acfac81cdc8
Contents?: true
Size: 925 Bytes
Versions: 3
Compression:
Stored size: 925 Bytes
Contents
require "open3" 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 # Thanks: https://stackoverflow.com/questions/2355866/ruby-how-to-determine-if-file-being-read-is-binary-or-text def text_file?(filename) file_type, status = Open3.capture2e("file", filename) status.success? && file_type.include?("text") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
terraspace-0.6.21 | lib/terraspace/compiler/strategy/mod.rb |
terraspace-0.6.20 | lib/terraspace/compiler/strategy/mod.rb |
terraspace-0.6.19 | lib/terraspace/compiler/strategy/mod.rb |