strada 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/LICENSE +21 -0
- data/lib/strada/version.rb +1 -1
- data/lib/strada.rb +21 -21
- data/strada.gemspec +17 -9
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41300d7c5eb1f56f0631a7820e9985c5acc0727dbb8db6b2b97a9850a2610351
|
4
|
+
data.tar.gz: 39f971b1074a5dcbf1b107427ff8bbe6a9b05c1dec498c58135b1e71b162d59e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f67d1199c690c9bfb36f3cfd29f022a5300839532f4ae7cc37ce946cc24deeeca4bc767a9392adcdc952dae3efaf26bfb81f07230ac4b6e5183fbfb4ef9f0596
|
7
|
+
data.tar.gz: 06cc0d0b95db050c3e14d3eadfe238e2247016418533292633cc63bab172c37e1785fac4e4eeced7d5abe9df19afff009f8f8950f8e495a0fffbd1d711f21d80
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Gemfile.lock
|
2
|
-
|
2
|
+
*gem
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 WENWU YAN
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/lib/strada/version.rb
CHANGED
data/lib/strada.rb
CHANGED
@@ -123,9 +123,29 @@ class Strada
|
|
123
123
|
no_config
|
124
124
|
end
|
125
125
|
|
126
|
+
# 将 JSON|YAML|TOML 等数据格式转换为 RUBY 数据结构
|
127
|
+
def from(adapter, config)
|
128
|
+
name = "from_" + adapter
|
129
|
+
send name, config
|
130
|
+
end
|
131
|
+
|
132
|
+
# 将 RUBY 数据结构转换为 JSON|YAML|TOML 对象
|
133
|
+
def to(adapter, config)
|
134
|
+
name = "to_" + adapter
|
135
|
+
send name, config
|
136
|
+
end
|
137
|
+
|
138
|
+
# 基础的配置标致名称
|
139
|
+
def meta_name
|
140
|
+
path = caller_locations[-1].path
|
141
|
+
File.basename path, File.extname(path)
|
142
|
+
rescue
|
143
|
+
raise NoName, "can't figure out name, specify explicitly"
|
144
|
+
end
|
145
|
+
|
126
146
|
private
|
127
|
-
# 加载配置文件
|
128
147
|
def load_cfg(dir)
|
148
|
+
# 加载配置文件
|
129
149
|
@file = File.join dir, @cfg_file
|
130
150
|
file = File.read @file
|
131
151
|
ConfigStruct.new(from(@adapter, file), key_to_s: @key_to_s)
|
@@ -153,26 +173,6 @@ class Strada
|
|
153
173
|
# 将合并后的 HASH 数据结构转换为配置对象
|
154
174
|
ConfigStruct.new hash
|
155
175
|
end
|
156
|
-
|
157
|
-
# 将 JSON|YAML|TOML 等数据格式转换为 RUBY 数据结构
|
158
|
-
def from(adapter, string)
|
159
|
-
name = "from_" + adapter
|
160
|
-
send name, string
|
161
|
-
end
|
162
|
-
|
163
|
-
# 将 RUBY 数据结构转换为 JSON|YAML|TOML 对象
|
164
|
-
def to(adapter, config)
|
165
|
-
name = "to_" + adapter
|
166
|
-
send name, config
|
167
|
-
end
|
168
|
-
|
169
|
-
# 基础的配置标致名称
|
170
|
-
def meta_name
|
171
|
-
path = caller_locations[-1].path
|
172
|
-
File.basename path, File.extname(path)
|
173
|
-
rescue
|
174
|
-
raise NoName, "can't figure out name, specify explicitly"
|
175
|
-
end
|
176
176
|
end
|
177
177
|
|
178
178
|
# 增加 HASH 方法
|
data/strada.gemspec
CHANGED
@@ -2,15 +2,23 @@
|
|
2
2
|
|
3
3
|
require_relative "lib/strada/version"
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
s.licenses
|
8
|
-
s.platform
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.homepage
|
12
|
-
s.summary
|
13
|
-
s.description
|
5
|
+
s.name = "strada"
|
6
|
+
s.version = Strada::VERSION
|
7
|
+
s.licenses = ["MIT"]
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["WENWU.YAN"]
|
10
|
+
s.email = "968826@gmail.com"
|
11
|
+
s.homepage = "http://github.com/ciscolive/strada"
|
12
|
+
s.summary = "configuration library"
|
13
|
+
s.description = "configuration library with object access to YAML/JSON/TOML backends"
|
14
|
+
|
15
|
+
s.required_ruby_version = ">= 2.6.0"
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
17
|
+
|
18
|
+
s.metadata["homepage_uri"] = s.homepage
|
19
|
+
s.metadata["source_code_uri"] = "https://github.com/ciscolive/strada"
|
20
|
+
s.metadata["changelog_uri"] = "https://github.com/ciscolive/strada/blob/main/README.md"
|
21
|
+
|
14
22
|
s.files = `git ls-files`.split("\n")
|
15
23
|
s.require_path = "lib"
|
16
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strada
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WENWU.YAN
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- ".idea/vcs.xml"
|
27
27
|
- ".rubocop.yml"
|
28
28
|
- Gemfile
|
29
|
+
- LICENSE
|
29
30
|
- README.md
|
30
31
|
- Rakefile
|
31
32
|
- lib/strada.rb
|
@@ -38,7 +39,10 @@ files:
|
|
38
39
|
homepage: http://github.com/ciscolive/strada
|
39
40
|
licenses:
|
40
41
|
- MIT
|
41
|
-
metadata:
|
42
|
+
metadata:
|
43
|
+
homepage_uri: http://github.com/ciscolive/strada
|
44
|
+
source_code_uri: https://github.com/ciscolive/strada
|
45
|
+
changelog_uri: https://github.com/ciscolive/strada/blob/main/README.md
|
42
46
|
post_install_message:
|
43
47
|
rdoc_options: []
|
44
48
|
require_paths:
|
@@ -47,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
51
|
requirements:
|
48
52
|
- - ">="
|
49
53
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
54
|
+
version: 2.6.0
|
51
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
56
|
requirements:
|
53
57
|
- - ">="
|