-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ PATH | |
specs: | ||
dotcrypt (0.1.0) | ||
dhall (~> 0.5.0) | ||
thor (~> 1.2.0) | ||
zeitwerk (~> 2.6.0) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
let some_variable = "some value" | ||
let some_variable = "some value'" | ||
in { | ||
some_string = some_variable, | ||
some_record = { | ||
some_string = some_variable, | ||
some_naturals = [1,2,3], | ||
some_doubles = [1.2, 2.3], | ||
some_strings = ["value1", "value2"], | ||
-- some_records = [ | ||
-- { | ||
-- key = "value" | ||
-- }, | ||
-- { | ||
-- key = "value" | ||
-- } | ||
-- ], | ||
some_nil = None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
# frozen_string_literal: true | ||
|
||
require "dotcrypt" | ||
|
||
Dotcrypt::Cli::App.start(ARGV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
require "json" | ||
|
||
require "zeitwerk" | ||
|
||
require "dhall" | ||
require "thor" | ||
|
||
loader = Zeitwerk::Loader.for_gem | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Dotcrypt::Cli::App < Thor | ||
include Dotcrypt::Cli::Commands::Load | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dotcrypt::Cli::Commands::Load | ||
def self.included(thor) | ||
thor.class_eval do | ||
desc "load DHALL", "loads dhall file" | ||
# option :name, type: :string, default: ENV.fetch("NAME", nil) | ||
def load(file = "example.dhall") | ||
config = Dotcrypt::Dhall.load(File.read(file)) | ||
|
||
print(Dotcrypt::Serializers::Env.call(config)) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "shellwords" | ||
|
||
class Dotcrypt::Serializers::Env < Dotcrypt::Serializers::Serializer | ||
def call | ||
Dotcrypt::Flattener.call(@config).reduce("") do |result, (k, v)| | ||
result + (v.nil? ? "" : "export #{k}='#{escape(v)}'\n") | ||
end | ||
end | ||
|
||
private | ||
|
||
def escape(val) = val.gsub("'", %q('"'"')) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Dotcrypt::Serializers::Serializer | ||
def self.call(...) = new(...).call | ||
|
||
def initialize(config) | ||
@config = config | ||
end | ||
|
||
def call = raise NotImplementedError | ||
end |