Sha256: 3ef13126f7c870312e4ccb18da0a33aeb309f1ca514e416861651b684364e752
Contents?: true
Size: 788 Bytes
Versions: 1
Compression:
Stored size: 788 Bytes
Contents
# frozen_string_literal: true require "json" require "yaml" require "zeitwerk" require "jsonnet" require "thor" loader = Zeitwerk::Loader.for_gem loader.inflector.inflect( "env" => "ENV", "json" => "JSON", "yaml" => "YAML" ) loader.setup module Dotcrypt DEFAULT_NAME = ".env.jsonnet" class Error < StandardError end 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 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dotcrypt-0.2.0 | lib/dotcrypt.rb |