Module: Dotcrypt

Defined in:
lib/dotcrypt.rb,
lib/dotcrypt/version.rb

Defined Under Namespace

Modules: Jsonnet, Serializers Classes: Error, Flattener

Constant Summary collapse

DEFAULT_NAME =
".env.jsonnet"
VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.find_dotcryptObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dotcrypt.rb', line 35

def self.find_dotcrypt
  dir = Dir.getwd
  loop do
    raise ".env.jsonnet is noot found" if dir == "/"

    path = File.join(dir, DEFAULT_NAME)

    return path if File.exist?(path)

    dir = File.expand_path("..", dir)
  end
end

.setup(path: find_dotcrypt) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/dotcrypt.rb', line 26

def self.setup(path: find_dotcrypt)
  Dotcrypt::Jsonnet.load_from(path).then do |c|
    Dotcrypt::Flattener.call(c).then do |f|
      ENV.merge!(f)
      return f
    end
  end
end