qonfig 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +12 -5
- data/lib/qonfig/commands/expose_json.rb +2 -2
- data/lib/qonfig/commands/expose_self.rb +33 -33
- data/lib/qonfig/commands/expose_yaml.rb +2 -2
- data/lib/qonfig/commands/load_from_env.rb +0 -2
- data/lib/qonfig/commands/load_from_json.rb +1 -2
- data/lib/qonfig/commands/load_from_self.rb +26 -26
- data/lib/qonfig/commands/load_from_yaml.rb +1 -2
- data/lib/qonfig/dsl.rb +4 -4
- data/lib/qonfig/errors.rb +13 -0
- data/lib/qonfig/loaders/end_data.rb +31 -0
- data/lib/qonfig/loaders.rb +22 -0
- data/lib/qonfig/plugins/toml/loaders.rb +23 -0
- data/lib/qonfig/plugins/toml.rb +1 -0
- data/lib/qonfig/version.rb +1 -1
- data/qonfig.gemspec +4 -3
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985a8b16d7fd6a86ec41fea68569c83f283e60f293ac8bca047ad4b0ca21b563
|
4
|
+
data.tar.gz: b94a684b24f696a67ce8c6a5ff2ceec98da628a9768ce6689fe1bd4a49ef130c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc879948b2e2a88aa1e207802d6cc7870944af239d67a0ab8e0c1dea21e8410eb0dd4d7063830f8ee0fd37cf7f0a2b61606d9fec6504918e1243128adacb70a3
|
7
|
+
data.tar.gz: ce80093052178e5d59c5b8f713029da8e74cc1ac14febcfc3fefd7023e0b37b2b1422638ac0ba4dc14e7b90b45a4094bde876274c757b8eea6df2194285c52cd
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.15.0] - 2019-09-02
|
5
|
+
### Added
|
6
|
+
- `:format`-option for `load_from_self` and `expose_self` commands thath identifies which data format
|
7
|
+
should be chosen for parsing;
|
8
|
+
|
4
9
|
## [0.14.0] - 2019-08-28
|
5
10
|
### Added
|
6
11
|
- `expose_json`
|
data/README.md
CHANGED
@@ -1329,14 +1329,17 @@ config.settings['RUN_CI'] # => '1'
|
|
1329
1329
|
### Load from \_\_END\_\_
|
1330
1330
|
|
1331
1331
|
- aka `load_from_self`
|
1332
|
-
-
|
1332
|
+
- `:format` - specify the format of data placed under the `__END__` instruction:
|
1333
|
+
- `format: :yaml` - **YAML** format (by default);
|
1334
|
+
- `format: :json` - **JSON** format;
|
1335
|
+
- `format: :toml` - **TOML** format (via `toml`-plugin);
|
1333
1336
|
|
1334
1337
|
```ruby
|
1335
1338
|
class Config < Qonfig::DataSet
|
1336
|
-
load_from_self # on the root
|
1339
|
+
load_from_self # on the root (format: :yaml is used by default)
|
1337
1340
|
|
1338
1341
|
setting :nested do
|
1339
|
-
load_from_self #
|
1342
|
+
load_from_self, format: :yaml # with explicitly identified YAML format
|
1340
1343
|
end
|
1341
1344
|
end
|
1342
1345
|
|
@@ -1373,11 +1376,14 @@ connection_timeout:
|
|
1373
1376
|
- aka `expose_self`;
|
1374
1377
|
- works in `expose_json` and `expose_yaml` manner, but with `__END__` instruction of the current file;
|
1375
1378
|
- `env:` - your environment name (must be a type of `String`, `Symbol` or `Numeric`);
|
1376
|
-
-
|
1379
|
+
- `:format` - specify the format of data placed under the `__END__` instruction:
|
1380
|
+
- `format: :yaml` - **YAML** format (by default);
|
1381
|
+
- `format: :json` - **JSON** format;
|
1382
|
+
- `format: :toml` - **TOML** format (via `toml`-plugin);
|
1377
1383
|
|
1378
1384
|
```ruby
|
1379
1385
|
class Config < Qonfig::DataSet
|
1380
|
-
expose_self env: :production
|
1386
|
+
expose_self env: :production, format: :yaml # with explicitly identified YAML format
|
1381
1387
|
|
1382
1388
|
# NOTE: for Rails-like applications you can use this:
|
1383
1389
|
expose_self env: Rails.env
|
@@ -1391,6 +1397,7 @@ config.settings.creds.user # => "D@iVeR" (from :production environment)
|
|
1391
1397
|
config.settings.creds.password # => "test123" (from :production environment)
|
1392
1398
|
|
1393
1399
|
__END__
|
1400
|
+
|
1394
1401
|
default: &default
|
1395
1402
|
log: false
|
1396
1403
|
api_enabled: true
|
@@ -124,7 +124,7 @@ class Qonfig::Commands::ExposeJSON < Qonfig::Commands::Base
|
|
124
124
|
|
125
125
|
raise(
|
126
126
|
Qonfig::IncompatibleJSONStructureError,
|
127
|
-
'JSON content
|
127
|
+
'JSON content must be a hash-like structure'
|
128
128
|
) unless json_data_slice.is_a?(Hash)
|
129
129
|
|
130
130
|
json_based_settings = build_data_set_klass(json_data_slice).new.settings
|
@@ -144,7 +144,7 @@ class Qonfig::Commands::ExposeJSON < Qonfig::Commands::Base
|
|
144
144
|
Qonfig::Loaders::JSON.load_file(file_path, fail_on_unexist: strict).tap do |json_data|
|
145
145
|
raise(
|
146
146
|
Qonfig::IncompatibleJSONStructureError,
|
147
|
-
'JSON content
|
147
|
+
'JSON content must be a hash-like structure'
|
148
148
|
) unless json_data.is_a?(Hash)
|
149
149
|
end
|
150
150
|
end
|
@@ -3,6 +3,12 @@
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.14.0
|
5
5
|
class Qonfig::Commands::ExposeSelf < Qonfig::Commands::Base
|
6
|
+
# @return [String, Symbol]
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
# @since 0.15.0
|
10
|
+
attr_reader :format
|
11
|
+
|
6
12
|
# @return [String]
|
7
13
|
#
|
8
14
|
# @api private
|
@@ -17,20 +23,24 @@ class Qonfig::Commands::ExposeSelf < Qonfig::Commands::Base
|
|
17
23
|
|
18
24
|
# @param caller_location [String]
|
19
25
|
# @option env [String, Symbol]
|
26
|
+
# @option format [String, Symbol]
|
20
27
|
#
|
21
28
|
# @api private
|
22
29
|
# @since 0.14.0
|
23
|
-
def initialize(caller_location, env:)
|
30
|
+
def initialize(caller_location, env:, format:)
|
24
31
|
unless env.is_a?(Symbol) || env.is_a?(String)
|
25
32
|
raise Qonfig::ArgumentError, ':env should be a string or a symbol'
|
26
33
|
end
|
27
34
|
|
28
|
-
if env.to_s.empty?
|
29
|
-
|
35
|
+
raise Qonfig::ArgumentError, ':env should be provided' if env.to_s.empty?
|
36
|
+
|
37
|
+
unless format.is_a?(String) || format.is_a?(Symbol)
|
38
|
+
raise Qonfig::ArgumentError, 'Format should be a symbol or a string'
|
30
39
|
end
|
31
40
|
|
32
41
|
@caller_location = caller_location
|
33
42
|
@env = env
|
43
|
+
@format = format.tap { Qonfig::Loaders.resolve(format) }
|
34
44
|
end
|
35
45
|
|
36
46
|
# @param data_set [Qonfig::DataSet]
|
@@ -40,21 +50,22 @@ class Qonfig::Commands::ExposeSelf < Qonfig::Commands::Base
|
|
40
50
|
# @api private
|
41
51
|
# @since 0.14.0
|
42
52
|
def call(data_set, settings)
|
43
|
-
|
44
|
-
|
53
|
+
self_placed_data = load_self_placed_end_data
|
54
|
+
env_based_data_slice =
|
55
|
+
self_placed_data[env] || self_placed_data[env.to_s] || self_placed_data[env.to_sym]
|
45
56
|
|
46
57
|
raise(
|
47
58
|
Qonfig::ExposeError,
|
48
59
|
"#{file_path} file does not contain settings with <#{env}> environment key!"
|
49
|
-
) unless
|
60
|
+
) unless env_based_data_slice
|
50
61
|
|
51
62
|
raise(
|
52
|
-
Qonfig::
|
53
|
-
'
|
54
|
-
) unless
|
63
|
+
Qonfig::IncompatibleEndDataStructureError,
|
64
|
+
'__END__-data content must be a hash-like structure'
|
65
|
+
) unless env_based_data_slice.is_a?(Hash)
|
55
66
|
|
56
|
-
|
57
|
-
settings.__append_settings__(
|
67
|
+
self_placed_settings = build_data_set_klass(env_based_data_slice).new.settings
|
68
|
+
settings.__append_settings__(self_placed_settings)
|
58
69
|
end
|
59
70
|
|
60
71
|
private
|
@@ -62,39 +73,28 @@ class Qonfig::Commands::ExposeSelf < Qonfig::Commands::Base
|
|
62
73
|
# @return [Hash]
|
63
74
|
#
|
64
75
|
# @raise [Qonfig::SelfDataNotFound]
|
65
|
-
# @raise [Qonfig::
|
76
|
+
# @raise [Qonfig::IncompatibleEndDataStructureError]
|
66
77
|
#
|
67
78
|
# @api private
|
68
79
|
# @since 0.14.0
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
raise(
|
73
|
-
Qonfig::SelfDataNotFoundError,
|
74
|
-
"Caller file does not exist! (location: #{caller_location})"
|
75
|
-
) unless File.exist?(caller_file)
|
76
|
-
|
77
|
-
data_match = IO.read(caller_file).match(/\n__END__\n(?<end_data>.*)/m)
|
78
|
-
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless data_match
|
79
|
-
|
80
|
-
end_data = data_match[:end_data]
|
81
|
-
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless end_data
|
80
|
+
def load_self_placed_end_data
|
81
|
+
end_data = Qonfig::Loaders::EndData.extract(caller_location)
|
82
|
+
settings_data = Qonfig::Loaders.resolve(format).load(end_data)
|
82
83
|
|
83
|
-
yaml_data = Qonfig::Loaders::YAML.load(end_data)
|
84
84
|
raise(
|
85
|
-
Qonfig::
|
86
|
-
'
|
87
|
-
) unless
|
85
|
+
Qonfig::IncompatibleEndDataStructureError,
|
86
|
+
'__END__-data must be a hash-like structure'
|
87
|
+
) unless settings_data.is_a?(Hash)
|
88
88
|
|
89
|
-
|
89
|
+
settings_data
|
90
90
|
end
|
91
91
|
|
92
|
-
# @param
|
92
|
+
# @param self_placed_settings [Hash]
|
93
93
|
# @return [Class<Qonfig::DataSet>]
|
94
94
|
#
|
95
95
|
# @api private
|
96
96
|
# @since 0.14.0
|
97
|
-
def build_data_set_klass(
|
98
|
-
Qonfig::DataSet::ClassBuilder.build_from_hash(
|
97
|
+
def build_data_set_klass(self_placed_settings)
|
98
|
+
Qonfig::DataSet::ClassBuilder.build_from_hash(self_placed_settings)
|
99
99
|
end
|
100
100
|
end
|
@@ -124,7 +124,7 @@ class Qonfig::Commands::ExposeYAML < Qonfig::Commands::Base
|
|
124
124
|
|
125
125
|
raise(
|
126
126
|
Qonfig::IncompatibleYAMLStructureError,
|
127
|
-
'YAML content
|
127
|
+
'YAML content must be a hash-like structure'
|
128
128
|
) unless yaml_data_slice.is_a?(Hash)
|
129
129
|
|
130
130
|
yaml_based_settings = build_data_set_klass(yaml_data_slice).new.settings
|
@@ -144,7 +144,7 @@ class Qonfig::Commands::ExposeYAML < Qonfig::Commands::Base
|
|
144
144
|
Qonfig::Loaders::YAML.load_file(file_path, fail_on_unexist: strict).tap do |yaml_data|
|
145
145
|
raise(
|
146
146
|
Qonfig::IncompatibleYAMLStructureError,
|
147
|
-
'YAML content
|
147
|
+
'YAML content must be a hash-like structure'
|
148
148
|
) unless yaml_data.is_a?(Hash)
|
149
149
|
end
|
150
150
|
end
|
@@ -63,9 +63,7 @@ class Qonfig::Commands::LoadFromENV < Qonfig::Commands::Base
|
|
63
63
|
# @since 0.2.0
|
64
64
|
def call(data_set, settings)
|
65
65
|
env_data = extract_env_data
|
66
|
-
|
67
66
|
env_based_settings = build_data_set_klass(env_data).new.settings
|
68
|
-
|
69
67
|
settings.__append_settings__(env_based_settings)
|
70
68
|
end
|
71
69
|
|
@@ -36,11 +36,10 @@ class Qonfig::Commands::LoadFromJSON < Qonfig::Commands::Base
|
|
36
36
|
|
37
37
|
raise(
|
38
38
|
Qonfig::IncompatibleJSONStructureError,
|
39
|
-
'JSON object
|
39
|
+
'JSON object must be a hash-like structure'
|
40
40
|
) unless json_data.is_a?(Hash)
|
41
41
|
|
42
42
|
json_based_settings = build_data_set_klass(json_data).new.settings
|
43
|
-
|
44
43
|
settings.__append_settings__(json_based_settings)
|
45
44
|
end
|
46
45
|
|
@@ -3,6 +3,12 @@
|
|
3
3
|
# @api private
|
4
4
|
# @since 0.2.0
|
5
5
|
class Qonfig::Commands::LoadFromSelf < Qonfig::Commands::Base
|
6
|
+
# @return [String, Symbol]
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
# @since 0.15.0
|
10
|
+
attr_reader :format
|
11
|
+
|
6
12
|
# @return [String]
|
7
13
|
#
|
8
14
|
# @api private
|
@@ -10,11 +16,17 @@ class Qonfig::Commands::LoadFromSelf < Qonfig::Commands::Base
|
|
10
16
|
attr_reader :caller_location
|
11
17
|
|
12
18
|
# @param caller_location [String]
|
19
|
+
# @option format [String, Symbol]
|
13
20
|
#
|
14
21
|
# @api private
|
15
22
|
# @since 0.2.0
|
16
|
-
def initialize(caller_location)
|
23
|
+
def initialize(caller_location, format:)
|
24
|
+
unless format.is_a?(String) || format.is_a?(Symbol)
|
25
|
+
raise Qonfig::ArgumentError, 'Format should be a symbol or a string'
|
26
|
+
end
|
27
|
+
|
17
28
|
@caller_location = caller_location
|
29
|
+
@format = format.tap { Qonfig::Loaders.resolve(format) }
|
18
30
|
end
|
19
31
|
|
20
32
|
# @param data_set [Qonfig::DataSet]
|
@@ -24,11 +36,10 @@ class Qonfig::Commands::LoadFromSelf < Qonfig::Commands::Base
|
|
24
36
|
# @api private
|
25
37
|
# @since 0.2.0
|
26
38
|
def call(data_set, settings)
|
27
|
-
|
28
|
-
|
29
|
-
yaml_based_settings = build_data_set_klass(yaml_data).new.settings
|
39
|
+
self_placed_end_data = load_self_placed_end_data
|
40
|
+
self_placed_settings = build_data_set_klass(self_placed_end_data).new.settings
|
30
41
|
|
31
|
-
settings.__append_settings__(
|
42
|
+
settings.__append_settings__(self_placed_settings)
|
32
43
|
end
|
33
44
|
|
34
45
|
private
|
@@ -40,35 +51,24 @@ class Qonfig::Commands::LoadFromSelf < Qonfig::Commands::Base
|
|
40
51
|
#
|
41
52
|
# @api private
|
42
53
|
# @since 0.2.0
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
raise(
|
47
|
-
Qonfig::SelfDataNotFoundError,
|
48
|
-
"Caller file does not exist! (location: #{caller_location})"
|
49
|
-
) unless File.exist?(caller_file)
|
50
|
-
|
51
|
-
data_match = IO.read(caller_file).match(/\n__END__\n(?<end_data>.*)/m)
|
52
|
-
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless data_match
|
53
|
-
|
54
|
-
end_data = data_match[:end_data]
|
55
|
-
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless end_data
|
54
|
+
def load_self_placed_end_data
|
55
|
+
end_data = Qonfig::Loaders::EndData.extract(caller_location)
|
56
|
+
settings_data = Qonfig::Loaders.resolve(format).load(end_data)
|
56
57
|
|
57
|
-
yaml_data = Qonfig::Loaders::YAML.load(end_data)
|
58
58
|
raise(
|
59
|
-
Qonfig::
|
60
|
-
'
|
61
|
-
) unless
|
59
|
+
Qonfig::IncompatibleEndDataStructureError,
|
60
|
+
'__END__-data must be a hash-like structure'
|
61
|
+
) unless settings_data.is_a?(Hash)
|
62
62
|
|
63
|
-
|
63
|
+
settings_data
|
64
64
|
end
|
65
65
|
|
66
|
-
# @param
|
66
|
+
# @param self_placed_settings [Hash]
|
67
67
|
# @return [Class<Qonfig::DataSet>]
|
68
68
|
#
|
69
69
|
# @api private
|
70
70
|
# @since 0.2.0
|
71
|
-
def build_data_set_klass(
|
72
|
-
Qonfig::DataSet::ClassBuilder.build_from_hash(
|
71
|
+
def build_data_set_klass(self_placed_settings)
|
72
|
+
Qonfig::DataSet::ClassBuilder.build_from_hash(self_placed_settings)
|
73
73
|
end
|
74
74
|
end
|
@@ -38,11 +38,10 @@ class Qonfig::Commands::LoadFromYAML < Qonfig::Commands::Base
|
|
38
38
|
|
39
39
|
raise(
|
40
40
|
Qonfig::IncompatibleYAMLStructureError,
|
41
|
-
'YAML content
|
41
|
+
'YAML content must be a hash-like structure'
|
42
42
|
) unless yaml_data.is_a?(Hash)
|
43
43
|
|
44
44
|
yaml_based_settings = build_data_set_klass(yaml_data).new.settings
|
45
|
-
|
46
45
|
settings.__append_settings__(yaml_based_settings)
|
47
46
|
end
|
48
47
|
|
data/lib/qonfig/dsl.rb
CHANGED
@@ -77,9 +77,9 @@ module Qonfig::DSL
|
|
77
77
|
#
|
78
78
|
# @api public
|
79
79
|
# @since 0.2.0
|
80
|
-
def load_from_self
|
80
|
+
def load_from_self(format: :yaml)
|
81
81
|
caller_location = caller(1, 1).first
|
82
|
-
commands << Qonfig::Commands::LoadFromSelf.new(caller_location)
|
82
|
+
commands << Qonfig::Commands::LoadFromSelf.new(caller_location, format: format)
|
83
83
|
end
|
84
84
|
|
85
85
|
# @option convert_values [Boolean]
|
@@ -139,8 +139,8 @@ module Qonfig::DSL
|
|
139
139
|
#
|
140
140
|
# @api public
|
141
141
|
# @since 0.14.0
|
142
|
-
def expose_self(env:)
|
142
|
+
def expose_self(env:, format: :yaml)
|
143
143
|
caller_location = caller(1, 1).first
|
144
|
-
commands << Qonfig::Commands::ExposeSelf.new(caller_location, env: env)
|
144
|
+
commands << Qonfig::Commands::ExposeSelf.new(caller_location, env: env, format: format)
|
145
145
|
end
|
146
146
|
end
|
data/lib/qonfig/errors.rb
CHANGED
@@ -81,6 +81,13 @@ module Qonfig
|
|
81
81
|
# @since 0.5.0
|
82
82
|
IncompatibleJSONStructureError = Class.new(Error)
|
83
83
|
|
84
|
+
# @see Qonfig::Commands::LoadFromSelf
|
85
|
+
# @see Qonfig::Commands::ExposeSelf
|
86
|
+
#
|
87
|
+
# @api public
|
88
|
+
# @since 0.15.0
|
89
|
+
IncompatibleEndDataStructureError = Class.new(Error)
|
90
|
+
|
84
91
|
# @see Qonfig::Loaders::YAML
|
85
92
|
#
|
86
93
|
# @api public
|
@@ -111,6 +118,12 @@ module Qonfig
|
|
111
118
|
# @since 0.7.0
|
112
119
|
ExposeError = Class.new(Error)
|
113
120
|
|
121
|
+
# @see Qonfig::Loaders
|
122
|
+
#
|
123
|
+
# @api public
|
124
|
+
# @since 0.15.0
|
125
|
+
UnsupportedLoaderFormatError = Class.new(Error)
|
126
|
+
|
114
127
|
# @see Qonfig::Plugin::TOMLFormat
|
115
128
|
#
|
116
129
|
# @api public
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.15.0
|
5
|
+
module Qonfig::Loaders::EndData
|
6
|
+
class << self
|
7
|
+
# @param caller_location [String]
|
8
|
+
# @return [String]
|
9
|
+
#
|
10
|
+
# @raise [Qonfig::SelfDataNotFoundError]
|
11
|
+
#
|
12
|
+
# @api private
|
13
|
+
# @since 0.15.0
|
14
|
+
def extract(caller_location)
|
15
|
+
caller_file = caller_location.split(':').first
|
16
|
+
|
17
|
+
raise(
|
18
|
+
Qonfig::SelfDataNotFoundError,
|
19
|
+
"Caller file does not exist! (location: #{caller_location})"
|
20
|
+
) unless File.exist?(caller_file)
|
21
|
+
|
22
|
+
data_match = IO.read(caller_file).match(/\n__END__\n(?<end_data>.*)/m)
|
23
|
+
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless data_match
|
24
|
+
|
25
|
+
end_data = data_match[:end_data]
|
26
|
+
raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless end_data
|
27
|
+
|
28
|
+
end_data
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/qonfig/loaders.rb
CHANGED
@@ -6,4 +6,26 @@ module Qonfig::Loaders
|
|
6
6
|
require_relative 'loaders/basic'
|
7
7
|
require_relative 'loaders/json'
|
8
8
|
require_relative 'loaders/yaml'
|
9
|
+
require_relative 'loaders/end_data'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# @param format [String, Symbol]
|
13
|
+
# @return [Module]
|
14
|
+
#
|
15
|
+
# @raise [Qonfig::UnsupportedLoaderFormatError]
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
# @since 0.15.0
|
19
|
+
def resolve(format)
|
20
|
+
case format.to_s
|
21
|
+
when 'yaml', 'yml'
|
22
|
+
Qonfig::Loaders::YAML
|
23
|
+
when 'json'
|
24
|
+
Qonfig::Loaders::JSON
|
25
|
+
else
|
26
|
+
raise(Qonfig::UnsupportedLoaderFormatError, "<#{format}> format is not supported.")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
alias_method :[], :resolve
|
30
|
+
end
|
9
31
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
# @since 0.15.0
|
5
|
+
module Qonfig::Loaders
|
6
|
+
class << self
|
7
|
+
prepend(Module.new do
|
8
|
+
# @param format [String, Symbol]
|
9
|
+
# @return [Module]
|
10
|
+
#
|
11
|
+
# @raise [Qonfig::UnsupportedLoaderFormatError]
|
12
|
+
#
|
13
|
+
# @see Qonfig::Loaders.resolve
|
14
|
+
#
|
15
|
+
# @api private
|
16
|
+
# @since 0.15.0
|
17
|
+
def resolve(format)
|
18
|
+
return Qonfig::Loaders::TOML if format.to_s == 'toml'
|
19
|
+
super(format)
|
20
|
+
end
|
21
|
+
end)
|
22
|
+
end
|
23
|
+
end
|
data/lib/qonfig/plugins/toml.rb
CHANGED
@@ -15,6 +15,7 @@ class Qonfig::Plugins::TOML < Qonfig::Plugins::Abstract
|
|
15
15
|
) unless const_defined?('::TomlRB')
|
16
16
|
|
17
17
|
require_relative 'toml/tomlrb_fixes'
|
18
|
+
require_relative 'toml/loaders'
|
18
19
|
require_relative 'toml/loaders/toml'
|
19
20
|
require_relative 'toml/uploaders/toml'
|
20
21
|
require_relative 'toml/commands/load_from_toml'
|
data/lib/qonfig/version.rb
CHANGED
data/qonfig.gemspec
CHANGED
@@ -14,9 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.email = ['iamdaiver@icloud.com']
|
15
15
|
spec.summary = 'Config object'
|
16
16
|
spec.description = 'Config. Defined as a class. Used as an instance. ' \
|
17
|
-
'Support for inheritance and composition. ' \
|
18
|
-
'
|
19
|
-
'
|
17
|
+
'Support for inheritance and composition. Lazy instantiation. Thread-safe. ' \
|
18
|
+
'Command-style DSL. Validation layer. ' \
|
19
|
+
'Support for YAML, TOML, JSON, __END__, ENV. ' \
|
20
|
+
'Extremely simple to define. Extremely simple to use.'
|
20
21
|
spec.homepage = 'https://github.com/0exp/qonfig'
|
21
22
|
spec.license = 'MIT'
|
22
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qonfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -109,8 +109,9 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Config. Defined as a class. Used as an instance. Support for inheritance
|
112
|
-
and composition. Lazy instantiation. Thread-safe. Command-style DSL.
|
113
|
-
|
112
|
+
and composition. Lazy instantiation. Thread-safe. Command-style DSL. Validation
|
113
|
+
layer. Support for YAML, TOML, JSON, __END__, ENV. Extremely simple to define. Extremely
|
114
|
+
simple to use.
|
114
115
|
email:
|
115
116
|
- iamdaiver@icloud.com
|
116
117
|
executables: []
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- lib/qonfig/errors.rb
|
157
158
|
- lib/qonfig/loaders.rb
|
158
159
|
- lib/qonfig/loaders/basic.rb
|
160
|
+
- lib/qonfig/loaders/end_data.rb
|
159
161
|
- lib/qonfig/loaders/json.rb
|
160
162
|
- lib/qonfig/loaders/yaml.rb
|
161
163
|
- lib/qonfig/plugins.rb
|
@@ -167,6 +169,7 @@ files:
|
|
167
169
|
- lib/qonfig/plugins/toml/commands/load_from_toml.rb
|
168
170
|
- lib/qonfig/plugins/toml/data_set.rb
|
169
171
|
- lib/qonfig/plugins/toml/dsl.rb
|
172
|
+
- lib/qonfig/plugins/toml/loaders.rb
|
170
173
|
- lib/qonfig/plugins/toml/loaders/toml.rb
|
171
174
|
- lib/qonfig/plugins/toml/tomlrb_fixes.rb
|
172
175
|
- lib/qonfig/plugins/toml/uploaders/toml.rb
|