dotcrypt 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf5e931d953d89033342214657a99900f104bb378a43b3c2afe080c427a0ceee
4
- data.tar.gz: 221c50d756c96d0a78141efcf6c43767faa1cdad1f56eb21f42fe3077be0f32e
3
+ metadata.gz: 4b24c31b9acd45de3b473e8479ee752e0392fe34f2e66ee3f6b39759b15bf487
4
+ data.tar.gz: c54a1ebbee56f32e27f7f0dfb9aad26d8158648abcf6e95e7029035d58798c20
5
5
  SHA512:
6
- metadata.gz: bead67e12addb394181060d64cac9a507ccd9930584cb8168ae0ec02d549b9424ad5634b2ad842e8c9b252aea32143e8e0709a75cfa18baeefd729c050d0accc
7
- data.tar.gz: b2ebbeed298c8b1ee631f89401dd9d7fe070b5066414ee19d90d0e3701c7775535ea15393eb6115bee8ccf617e7db4e800c52a717584cd0dadfd9460da0d89c4
6
+ metadata.gz: 43aab882593c8c4820407ec4162156da5ea497c392f7b4d58e3b5d4b60dd623024bc105a61f3070c17de4c431577632b9e80d2c3ed678932050c5aeac399674a
7
+ data.tar.gz: a119ce9f2d3e7eea65c0d25efb36dab5945b3a6cd3d57a55d3fe99de1f56467634c363f88131b7ef0459acb56527c5dde0d5440f5222a0dd33a571518a251b02
data/.env.jsonnet ADDED
@@ -0,0 +1,11 @@
1
+ local some_variable = "some value'";
2
+
3
+ {
4
+ some_string: some_variable,
5
+ some_record: {
6
+ some_string: some_variable,
7
+ some_naturals: [1, 2, 3],
8
+ some_doubles: [1.2, 2.3],
9
+ some_strings: ['value1', 'value2']
10
+ },
11
+ }
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotcrypt (0.1.2)
4
+ dotcrypt (0.2.0)
5
5
  bootsnap (~> 1.15.0)
6
- dhall (~> 0.5.0)
6
+ jsonnet (~> 0.5.0)
7
7
  thor (~> 1.2.0)
8
8
  zeitwerk (~> 2.6.0)
9
9
 
@@ -12,35 +12,23 @@ GEM
12
12
  specs:
13
13
  ast (2.4.2)
14
14
  backport (1.2.0)
15
- base32 (0.3.4)
16
15
  benchmark (0.2.0)
17
16
  bootsnap (1.15.0)
18
17
  msgpack (~> 1.2)
19
- cbor (0.5.9.6)
20
18
  childprocess (4.1.0)
21
- citrus (3.0.2)
22
- dhall (0.5.5)
23
- base32 (~> 0.3.2)
24
- cbor (~> 0.5.9.3)
25
- citrus (~> 3.0)
26
- lazy_object (>= 0.0.1, < 0.2.0)
27
- multihashes (~> 0.2.0)
28
- promise.rb (~> 0.7.4)
29
- value_semantics (~> 3.0)
30
19
  diff-lcs (1.5.0)
31
20
  e2mmap (0.1.0)
32
21
  iniparse (1.5.0)
33
22
  jaro_winkler (1.5.4)
34
23
  json (2.6.2)
24
+ jsonnet (0.5.2)
25
+ mini_portile2 (>= 2.2.0)
35
26
  kramdown (2.4.0)
36
27
  rexml
37
28
  kramdown-parser-gfm (1.1.0)
38
29
  kramdown (~> 2.0)
39
- lazy_object (0.1.0)
30
+ mini_portile2 (2.8.1)
40
31
  msgpack (1.6.0)
41
- multicodecs (0.2.1)
42
- multihashes (0.2.0)
43
- multicodecs (>= 0.2.0, < 1)
44
32
  nokogiri (1.13.10-x86_64-linux)
45
33
  racc (~> 1.4)
46
34
  overcommit (0.59.1)
@@ -50,7 +38,6 @@ GEM
50
38
  parallel (1.22.1)
51
39
  parser (3.1.3.0)
52
40
  ast (~> 2.4.1)
53
- promise.rb (0.7.4)
54
41
  racc (1.6.2)
55
42
  rainbow (3.1.1)
56
43
  rake (13.0.6)
@@ -107,7 +94,6 @@ GEM
107
94
  thor (1.2.1)
108
95
  tilt (2.0.11)
109
96
  unicode-display_width (2.3.0)
110
- value_semantics (3.6.1)
111
97
  webrick (1.7.0)
112
98
  yard (0.9.28)
113
99
  webrick (~> 1.7.0)
@@ -5,7 +5,7 @@ module Dotcrypt::Cli::Commands::Exec
5
5
  thor.class_eval do
6
6
  include Dotcrypt::Cli::Commands::Globals
7
7
 
8
- desc "exec COMMAND", "exec command a command with dhall env"
8
+ desc "exec COMMAND", "exec command a command with env"
9
9
 
10
10
  def exec(*command) = Handler.new(command, **options).call
11
11
  end
@@ -24,7 +24,7 @@ module Dotcrypt::Cli::Commands::Exec
24
24
  private
25
25
 
26
26
  def env
27
- @env ||= Dotcrypt::Dhall.load_from(@options[:file]).then do |c|
27
+ @env ||= Dotcrypt::Jsonnet.load_from(@options[:file]).then do |c|
28
28
  # TODO: validate variable names
29
29
  Dotcrypt::Flattener.call(c, separator: @options[:separator])
30
30
  end
@@ -10,8 +10,8 @@ module Dotcrypt::Cli::Commands::Globals
10
10
 
11
11
  option :file, aliases: :f,
12
12
  type: :string,
13
- default: ".env.dhall",
14
- desc: "Dhall file to read."
13
+ default: ".env.jsonnet",
14
+ desc: "Jsonnet file to read."
15
15
  end
16
16
  end
17
17
  end
@@ -5,7 +5,7 @@ module Dotcrypt::Cli::Commands::Show
5
5
  thor.class_eval do
6
6
  include Dotcrypt::Cli::Commands::Globals
7
7
 
8
- desc "show", "converts a dhall file into various formats"
8
+ desc "show", "converts a jsonnet file into various formats"
9
9
 
10
10
  option :output, aliases: :o,
11
11
  type: :string,
@@ -32,7 +32,7 @@ module Dotcrypt::Cli::Commands::Show
32
32
  private
33
33
 
34
34
  def config
35
- @config ||= Dotcrypt::Dhall.load_from(@options[:file]).then do |c|
35
+ @config ||= Dotcrypt::Jsonnet.load_from(@options[:file]).then do |c|
36
36
  next Dotcrypt::Flattener.call(c, separator: @options[:separator]) if @options[:flatten]
37
37
 
38
38
  c
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotcrypt::Jsonnet
4
+ class << self
5
+ def load(code) = Jsonnet.evaluate(code)
6
+
7
+ def load_from(file) = load(File.read(file))
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dotcrypt
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/dotcrypt.rb CHANGED
@@ -4,7 +4,7 @@ require "json"
4
4
  require "yaml"
5
5
 
6
6
  require "zeitwerk"
7
- require "dhall"
7
+ require "jsonnet"
8
8
  require "thor"
9
9
 
10
10
  loader = Zeitwerk::Loader.for_gem
@@ -17,6 +17,31 @@ loader.inflector.inflect(
17
17
 
18
18
  loader.setup
19
19
 
20
- class Dotcrypt::Error < StandardError
21
- # Your code goes here...
20
+ module Dotcrypt
21
+ DEFAULT_NAME = ".env.jsonnet"
22
+
23
+ class Error < StandardError
24
+ end
25
+
26
+ def self.setup(path: find_dotcrypt)
27
+ Dotcrypt::Jsonnet.load_from(path).then do |c|
28
+ Dotcrypt::Flattener.call(c).then do |f|
29
+ ENV.merge!(f)
30
+ return f
31
+ end
32
+ end
33
+ end
34
+
35
+ def self.find_dotcrypt
36
+ dir = Dir.getwd
37
+ loop do
38
+ raise ".env.jsonnet is noot found" if dir == "/"
39
+
40
+ path = File.join(dir, DEFAULT_NAME)
41
+
42
+ return path if File.exist?(path)
43
+
44
+ dir = File.expand_path("..", dir)
45
+ end
46
+ end
22
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotcrypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-02 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.15.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: dhall
28
+ name: jsonnet
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -74,7 +74,7 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".env.dhall"
77
+ - ".env.jsonnet"
78
78
  - ".overcommit.yml"
79
79
  - ".rspec"
80
80
  - ".rubocop.yml"
@@ -92,9 +92,8 @@ files:
92
92
  - lib/dotcrypt/CLI/commands/globals.rb
93
93
  - lib/dotcrypt/CLI/commands/show.rb
94
94
  - lib/dotcrypt/core_ext/hash.rb
95
- - lib/dotcrypt/dhall.rb
96
- - lib/dotcrypt/dhall/as_hash.rb
97
95
  - lib/dotcrypt/flattener.rb
96
+ - lib/dotcrypt/jsonnet.rb
98
97
  - lib/dotcrypt/serializers.rb
99
98
  - lib/dotcrypt/serializers/env.rb
100
99
  - lib/dotcrypt/serializers/json.rb
data/.env.dhall DELETED
@@ -1,11 +0,0 @@
1
- let some_variable = "some value'"
2
- in {
3
- some_string = some_variable,
4
- some_record = {
5
- some_string = some_variable,
6
- some_naturals = [1,2,3],
7
- some_doubles = [1.2, 2.3],
8
- some_strings = ["value1", "value2"],
9
- some_nil = None
10
- }
11
- }
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dotcrypt::Dhall::AsHash
4
- refine ::Dhall::Record do
5
- def as_hash(*)
6
- to_h.transform_values(&:as_hash)
7
- end
8
- end
9
-
10
- refine ::Dhall::List do
11
- def as_hash(*)
12
- to_a.map(&:as_hash)
13
- end
14
- end
15
-
16
- refine ::Dhall::Text do
17
- def as_hash(*)
18
- to_s
19
- end
20
- end
21
-
22
- refine ::Dhall::Natural do
23
- def as_hash(*)
24
- to_i
25
- end
26
- end
27
-
28
- refine ::Dhall::Double do
29
- def as_hash(*)
30
- to_f
31
- end
32
- end
33
-
34
- refine ::Dhall::Builtins::None do
35
- def as_hash(*)
36
- nil
37
- end
38
- end
39
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dotcrypt::Dhall
4
- using Dotcrypt::Dhall::AsHash
5
-
6
- class << self
7
- def load(dhall)
8
- Dhall.load(dhall).sync.as_hash
9
- end
10
-
11
- def load_from(file)
12
- load(File.read(file))
13
- end
14
- end
15
- end