Sha256: fecb2f0d30ede7c9b5daa830ffbbbd74a9bc19ac825454703d9c76955eaa388a

Contents?: true

Size: 1.65 KB

Versions: 12

Compression:

Stored size: 1.65 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

    # Terraspace.argv provides consistency when terraspace is being called by rspec-terrspace test harness
    # So use Terraspace.argv instead of ARGV constant
    def argv=(argv)
      @@argv = argv
    end

    def argv
      @@argv
    end

    @@check_project = true
    def check_project
      @@check_project
    end

    # allow testing frameworks to disable
    def check_project=(v)
      @@check_project = v
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
terraspace-1.1.1 lib/terraspace/core.rb
terraspace-1.1.0 lib/terraspace/core.rb
terraspace-1.0.6 lib/terraspace/core.rb
terraspace-1.0.5 lib/terraspace/core.rb
terraspace-1.0.4 lib/terraspace/core.rb
terraspace-1.0.3 lib/terraspace/core.rb
terraspace-1.0.2 lib/terraspace/core.rb
terraspace-1.0.1 lib/terraspace/core.rb
terraspace-1.0.0 lib/terraspace/core.rb
terraspace-0.7.2 lib/terraspace/core.rb
terraspace-0.7.1 lib/terraspace/core.rb
terraspace-0.7.0 lib/terraspace/core.rb