Sha256: 055c7e0aa061458167d3b69369afaee2ed5088f80c2e200650c47b2da6c41e53

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

module Terraspace
  module Core
    extend Memoist

    def env
      ENV['TS_ENV'] || "dev"
    end
    memoize :env

    @@root = nil
    def root
      @@root ||= ENV['TS_ROOT'] || Dir.pwd
    end

    # allow testing frameworks to switch roots
    def root=(v)
      @@root = v
    end

    def cache_root
      ENV['TS_CACHE_ROOT'] || config.build.cache_root || "#{root}/.terraspace-cache"
    end
    memoize :cache_root

    def tmp_root
      ENV['TS_TMP_ROOT'] || "/tmp/terraspace"
    end
    memoize :tmp_root

    def log_root
      "#{root}/log"
    end

    def configure(&block)
      App.instance.configure(&block)
    end

    # Generally, use the Terraspace.config instead of App.instance.config since it guarantees the load_project_config call
    def config
      App.instance.load_project_config
      App.instance.config
    end
    memoize :config

    @@logger = nil
    def logger
      @@logger ||= config.logger
    end

    # allow different logger when running up all
    def logger=(v)
      @@logger = v
    end

    def pass_file?(path)
      pass_files = config.build.pass_files + config.build.default_pass_files
      pass_files.uniq.detect do |i|
        i.is_a?(Regexp) ? path =~ i : path.include?(i)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
terraspace-0.6.11 lib/terraspace/core.rb
terraspace-0.6.10 lib/terraspace/core.rb
terraspace-0.6.9 lib/terraspace/core.rb
terraspace-0.6.8 lib/terraspace/core.rb
terraspace-0.6.7 lib/terraspace/core.rb
terraspace-0.6.6 lib/terraspace/core.rb