ruby_vault 0.1.0.pre.2 → 0.1.0.pre.3

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: 517ba1189e0acf38b729072d2f4a79ff4d22e0d7630d22d7933d0e33eb2ef04f
4
- data.tar.gz: e70f30492b24464cf6505ac87fc040070c9915abb08a8696d66b3caa41440c31
3
+ metadata.gz: 19e8aadca9a6285c7decb702603d6a0ef61aa6b644a46c236ac96ce3ad9a6310
4
+ data.tar.gz: 8bff21c678170fb4187d171c859756cec283e3d546d0b1ae3a02248f76d6393a
5
5
  SHA512:
6
- metadata.gz: d1aa3226f32c5f59acdfba7d0cfab67e71e10d8cbe9912f45ac18a54cca8df93912ebfe09b3897b8a47687e4301a818b01b6778a3ae1c2ac89cfa7564a3f445d
7
- data.tar.gz: 83577b10a67ea70167fdb434ebaa3fb81c55538a82a2e748f6b0ac2fff857f5f78984a356a488fdae00e65e4bc100e989e0d84c2a168aef7d211d0c0cfce441a
6
+ metadata.gz: 81c23a4e58bb4954f769c3dda63196fa7af0b06736cbf79f566cd1b88555eb31a55f2635a3d8961067d265bc8245350bb8e4f513d5a3479d6d4c3aa8439fd74b
7
+ data.tar.gz: 209e56bdf568f52332287e19c9190694995482a35c1fa5c79186f81e3fe920edad50cbd2bbdf2bd4499f7c9c1417b9e805f1e99495e4307665daa35c8203be2e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_vault (0.1.0.pre.2)
4
+ ruby_vault (0.1.0.pre.3)
5
5
  immutable-struct (~> 2.4)
6
6
  lino (~> 3.0)
7
7
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyVault
4
+ module Options
5
+ DEFINITIONS = [].freeze
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'name'
4
+
5
+ module RubyVault
6
+ module Options
7
+ class Factory
8
+ def initialize(definitions)
9
+ @definitions = definitions
10
+ end
11
+
12
+ def resolve(names, parameters)
13
+ names
14
+ .map { |name| Name.new(name) }
15
+ .inject([]) do |options, name|
16
+ options + resolve_name(name, parameters)
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def resolve_name(name, parameters)
23
+ @definitions.find { |d| d.matches?(name) }.build(parameters)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'immutable-struct'
4
+
5
+ module RubyVault
6
+ module Options
7
+ class Name < ImmutableStruct.new(:name)
8
+ def initialize(name)
9
+ super(name: name.to_s)
10
+ end
11
+
12
+ def name
13
+ "-#{without_prefix}"
14
+ end
15
+
16
+ alias to_s name
17
+
18
+ def as_singular_key
19
+ snake_case.to_sym
20
+ end
21
+
22
+ def as_plural_key
23
+ "#{snake_case}s".to_sym
24
+ end
25
+
26
+ private
27
+
28
+ def without_prefix
29
+ @name.sub(/^-+/, '')
30
+ end
31
+
32
+ def snake_case
33
+ without_prefix.gsub('-', '_')
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'options/factory'
4
+
5
+ module RubyVault
6
+ module Options
7
+ end
8
+ end
9
+
10
+ require_relative 'options/definitions'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyVault
4
- VERSION = '0.1.0.pre.2'
4
+ VERSION = '0.1.0.pre.3'
5
5
  end
data/lib/ruby_vault.rb CHANGED
@@ -1,3 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ruby_vault/options'
3
4
  require 'ruby_vault/version'
5
+ require 'logger'
6
+
7
+ module RubyVault
8
+ class << self
9
+ def configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ def reset!
14
+ @configuration = nil
15
+ end
16
+ end
17
+
18
+ class Configuration
19
+ attr_accessor :binary, :logger, :options, :stdin, :stdout, :stderr
20
+
21
+ def default_logger
22
+ logger = Logger.new($stdout)
23
+ logger.level = Logger::INFO
24
+ logger
25
+ end
26
+
27
+ def default_options
28
+ Options::Factory.new(Options::DEFINITIONS)
29
+ end
30
+
31
+ def initialize
32
+ @binary = 'terraform'
33
+ @logger = default_logger
34
+ @options = default_options
35
+ @stdin = ''
36
+ @stdout = $stdout
37
+ @stderr = $stderr
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.2
4
+ version: 0.1.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: immutable-struct
@@ -279,6 +279,10 @@ files:
279
279
  - bin/console
280
280
  - bin/setup
281
281
  - lib/ruby_vault.rb
282
+ - lib/ruby_vault/options.rb
283
+ - lib/ruby_vault/options/definitions.rb
284
+ - lib/ruby_vault/options/factory.rb
285
+ - lib/ruby_vault/options/name.rb
282
286
  - lib/ruby_vault/version.rb
283
287
  - ruby_vault.gemspec
284
288
  homepage: https://github.com/infrablocks/ruby_vault