tty-config 0.4.0 → 0.5.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 +18 -1
- data/LICENSE.txt +1 -1
- data/README.md +217 -150
- data/lib/tty-config.rb +1 -1
- data/lib/tty/config.rb +311 -66
- data/lib/tty/config/dependency_loader.rb +1 -1
- data/lib/tty/config/generator.rb +5 -5
- data/lib/tty/config/marshaller.rb +13 -3
- data/lib/tty/config/marshaller_registry.rb +4 -2
- data/lib/tty/config/marshallers/hcl_marshaller.rb +3 -0
- data/lib/tty/config/marshallers/ini_marshaller.rb +4 -1
- data/lib/tty/config/marshallers/java_props_marshaller.rb +3 -0
- data/lib/tty/config/marshallers/json_marshaller.rb +3 -0
- data/lib/tty/config/marshallers/toml_marshaller.rb +3 -0
- data/lib/tty/config/marshallers/yaml_marshaller.rb +3 -0
- data/lib/tty/config/version.rb +3 -3
- metadata +21 -33
data/lib/tty/config/generator.rb
CHANGED
@@ -11,7 +11,7 @@ module TTY
|
|
11
11
|
# the file content
|
12
12
|
#
|
13
13
|
# @api public
|
14
|
-
def self.generate(data, separator:
|
14
|
+
def self.generate(data, separator: "=")
|
15
15
|
content = []
|
16
16
|
values = {}
|
17
17
|
sections = {}
|
@@ -24,7 +24,7 @@ module TTY
|
|
24
24
|
(val.is_a?(Array) && val.first.is_a?(Hash))
|
25
25
|
sections[key] = val
|
26
26
|
elsif val.is_a?(Array)
|
27
|
-
values[key] = val.join(
|
27
|
+
values[key] = val.join(",")
|
28
28
|
else
|
29
29
|
values[key] = val
|
30
30
|
end
|
@@ -34,7 +34,7 @@ module TTY
|
|
34
34
|
values.each do |key, val|
|
35
35
|
content << "#{key} #{separator} #{val}"
|
36
36
|
end
|
37
|
-
content <<
|
37
|
+
content << "" unless values.empty?
|
38
38
|
|
39
39
|
# sections
|
40
40
|
sections.each do |section, object|
|
@@ -45,10 +45,10 @@ module TTY
|
|
45
45
|
object = object.reduce({}, :merge!)
|
46
46
|
end
|
47
47
|
object.each do |key, val|
|
48
|
-
val = val.join(
|
48
|
+
val = val.join(",") if val.is_a?(Array)
|
49
49
|
content << "#{key} #{separator} #{val}" if val
|
50
50
|
end
|
51
|
-
content <<
|
51
|
+
content << ""
|
52
52
|
end
|
53
53
|
content.join("\n")
|
54
54
|
end
|
@@ -16,7 +16,7 @@ module TTY
|
|
16
16
|
|
17
17
|
module ExtensionsStore
|
18
18
|
def ext
|
19
|
-
@
|
19
|
+
@_ext ||= []
|
20
20
|
end
|
21
21
|
|
22
22
|
# Set a list of extensions
|
@@ -27,11 +27,21 @@ module TTY
|
|
27
27
|
# @api public
|
28
28
|
def extension(*extensions)
|
29
29
|
if extensions[0].is_a?(Array)
|
30
|
-
@
|
30
|
+
@_ext = extensions[0]
|
31
31
|
else
|
32
|
-
@
|
32
|
+
@_ext = extensions
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
# Copy extensions to a subclass
|
37
|
+
#
|
38
|
+
# @param [Object] subclass
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
def inherited(subclass)
|
42
|
+
super
|
43
|
+
subclass.instance_variable_set(:@_ext, @_ext.dup)
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
# Marshal object into a given format
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module TTY
|
4
4
|
class Config
|
5
5
|
class MarshallerRegistry
|
6
|
-
|
6
|
+
# All registered marshallers
|
7
|
+
#
|
8
|
+
# @api private
|
7
9
|
attr_reader :marshallers
|
8
10
|
|
9
11
|
# @api private
|
@@ -24,7 +26,7 @@ module TTY
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def registered?(name_or_object)
|
27
|
-
marshallers.key?(name_or_object) || marshallers.
|
29
|
+
marshallers.key?(name_or_object) || marshallers.value?(name_or_object)
|
28
30
|
end
|
29
31
|
|
30
32
|
def register(name, object)
|
@@ -6,6 +6,9 @@ require_relative "../marshaller"
|
|
6
6
|
module TTY
|
7
7
|
class Config
|
8
8
|
module Marshallers
|
9
|
+
# Responsible for marshalling content from and into INI format
|
10
|
+
#
|
11
|
+
# @api public
|
9
12
|
class INIMarshaller
|
10
13
|
include TTY::Config::Marshaller
|
11
14
|
|
@@ -19,7 +22,7 @@ module TTY
|
|
19
22
|
|
20
23
|
def unmarshal(content)
|
21
24
|
ini = IniFile.new(content: content).to_h
|
22
|
-
global = ini.delete(
|
25
|
+
global = ini.delete("global")
|
23
26
|
ini.merge!(global)
|
24
27
|
end
|
25
28
|
end # INIMarshaller
|
data/lib/tty/config/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.5'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.5'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,14 +28,14 @@ dependencies:
|
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: '3.0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '3.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
@@ -58,58 +44,59 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.2
|
47
|
+
version: '0.2'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.2
|
54
|
+
version: '0.2'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: inifile
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.0
|
61
|
+
version: '3.0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.0
|
68
|
+
version: '3.0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rhcl
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.1
|
75
|
+
version: '0.1'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.1
|
82
|
+
version: '0.1'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: java-properties
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
89
|
+
version: '0.3'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
111
|
-
description:
|
112
|
-
terminal
|
96
|
+
version: '0.3'
|
97
|
+
description: A highly customisable application configuration interface for building
|
98
|
+
terminal tools. It supports many file formats such as YAML, JSON, TOML, INI, HCL
|
99
|
+
and Java Properties.
|
113
100
|
email:
|
114
101
|
- piotr@piotrmurach.com
|
115
102
|
executables: []
|
@@ -117,6 +104,7 @@ extensions: []
|
|
117
104
|
extra_rdoc_files:
|
118
105
|
- README.md
|
119
106
|
- CHANGELOG.md
|
107
|
+
- LICENSE.txt
|
120
108
|
files:
|
121
109
|
- CHANGELOG.md
|
122
110
|
- LICENSE.txt
|
@@ -145,7 +133,7 @@ metadata:
|
|
145
133
|
documentation_uri: https://www.rubydoc.info/gems/tty-config
|
146
134
|
homepage_uri: https://ttytoolkit.org
|
147
135
|
source_code_uri: https://github.com/piotrmurach/tty-config
|
148
|
-
post_install_message:
|
136
|
+
post_install_message:
|
149
137
|
rdoc_options: []
|
150
138
|
require_paths:
|
151
139
|
- lib
|
@@ -161,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
149
|
version: '0'
|
162
150
|
requirements: []
|
163
151
|
rubygems_version: 3.1.2
|
164
|
-
signing_key:
|
152
|
+
signing_key:
|
165
153
|
specification_version: 4
|
166
|
-
summary:
|
167
|
-
|
154
|
+
summary: A highly customisable application configuration interface for building terminal
|
155
|
+
tools.
|
168
156
|
test_files: []
|