给大家推荐一个用ruby写的控制YML文件的工具
https://github.com/hakehuang/yml_merger
可以用这个工具来简单实现一个只读的本地文件数据库。
gem install yam_merger
gem install deep_merge
yml_merger
This is a tool that helps to organize the YML in different files.
install
gem install yml_merger
gem install deep_merge
usage:
Please refer to the test.
create a yml file as below
records/test.yml
__load__:
more.yml
<your yml content>
require 'yml_merger'
@entry_yml = "test.yml"
@search_path = (Pathname.new(File.dirname(__FILE__)).realpath + 'records/').to_s
merge_unit = YML_Merger.new(
@entry_yml, @search_path
)
merged_data = merge_unit.process()
puts "creating './merged_data.yml'"
File.write('./merged_data.yml', YAML.dump(merged_data))
the test.yml and more.yml content are merged together
YML oraginzations:
you can using a tree toplogic to orgainize you application, the YML files can be catalogies to three types:
-
the root node which is the entry point of a tree yml
-
the branch node which is the branch pint of a tree yml
-
the leaf node which is the leaf node of a tree.
we recommand that each leaf node shall be uniq feature. and branch node defines the branch shared feature with hierarchy.
merging rules:
- load
indicated some other YML file will be added, this enalbes user to separate yml definitions to different file
__load__
- a.yml
- b.yml
- http://yourhost/c.yml
my_definitions:
...
- add
using to refer to a external hash like
a:
__add__:
- b
...
b:
...
means hash a will include hash be by deep_merge
- common
this will be processed after all YML files are loaded and merged into a plain hash
a:
__common__:
common_settings:
...
b:
c:
then common settings will be processed and result as below
a:
b:
common_settings:
c:
common_settings:
- hierarchy:
this will be processed during yml file loadding.
file a.yml
__load__:
- b.yml
a:
some_attr:
__hierarchy__:
hiearchy_attr:
...
ta:
...
file b:
a:
some_attr:
other_attr:
...
then the merged result is:
a:
some_attr:
other_attr:
hiearchy_attr:
...
...
ta:
hiearchy_attr:
...
...
- remove
this will be processed after merged all yml files
file a.yml
__load__:
- b.yml
a:
some_attr:
__remove__:
special_attr:
...
ta:
...
file b:
a:
some_attr:
special_attr:
...
other_attr:
...
then the merged result is:
a:
some_attr:
other_attr:
...
ta:
...
- replace
this will be processed after merged all yml files
file a.yml
__load__:
- b.yml
a:
some_attr:
__replace__:
special_attr:
settings_new:
...
ta:
...
file b:
a:
some_attr:
special_attr:
settings_old:
...
other_attr:
...
then the merged result is:
a:
some_attr:
special_attr:
settings_new:
...
other_attr:
...
ta:
...
- pre-process-merge
this is deprecated feature, you can use common or hierarchy instead
a:
node:
mode: pre-process-merge
attribute: required
pre_process_node:
msg: this is preprocessing parts
pre_process_node:
...
the processing result will be
a:
pre_process_node:
msg: this is preprocessing parts
...
- post-process-app
a:
mode: post-process-app
attribute: required
...
b:
...
c:
mode: post-process-app
attribute: required
...
process result
a:
...
c:
...
this is use to select one or more nodes from a pre-defined node list e.g
file a.yml
__load__
- b.yml
a:
attribute: required
c:
attribute: required
file b.yml
__common__
mode: post-process-app
a:
...
b:
...
c:
...
'''
the result will be
```yaml
a:
...
c:
...
- post-process-lib
a:
mode: post-process-lib
node_1:
attribute: required
...
node_2:
...
node_3:
attribute: required
process result
a:
node_1:
...
node_3:
...
this is use to select one or more nodes from a pre-defined node list e.g
file a.yml
__load__
- b.yml
a:
f1:
attribute: required
f3:
attribute: required
file b.yml
a:
mode: post-process-lib
f1:
...
f2:
...
f3:
...
f4:
...
f5:
...
...
'''
the result will be
```yaml
a:
f1:
f3:
merge process
@filestructure = process_file(@ENTRY_YML)
merge_by_add(@filestructure)
merge_by_common(@filestructure)
delete_node(@filestructure,'__common__')
delete_node(@filestructure,'__load__')
#delete_node(@filestructure,'__add__')
post_process(@filestructure)
相关推荐
yaml/yml 的dependency工具包 yet anathor markup language 又是一个标记语言 .233333 读法“腋毛” --------------------------------- 配置文件格式: aa: 11 bb:(空格)22 cc: dd: 44 (空格) ee: 55...
yml_comparer YML比较器 这是Java实现YML提供块的比较 用法: yml_comparer <old> 结果由<OfferId><r><n><m><p> ,其中 OfferId是要约的ID r表示要约已在删除的信号 在添加了n要约的信号 在修改了要约的m信号 p...
yml_tools Drupal 7 模块允许将产品从商店导出到 YML (Yandex.Market)。 支持 Ubercart 和 Drupal Commerce 商店。 基于 YML 导出 ( )。 去做: 添加字段映射支持完整模式在 cron 上生成 XML 文件验证生成的文件
yml 剧本 利用ansible自动化运维工具 批量化部署 zabbix 监控服务
config__xdc.yml
springboot+Jpa+JDBC做前后台交后的所需yml文件
ppyoloe_crn_x_300e_coco_blvhop.yml
关于yml的介绍,java对yml的解析,yml的规范的详解。
yml 解析器php 对象中的 xml (yandex xml) 解析器
天气预报机器人数据集, nlu.yml city.yml response.yml
fast_rotors_test.yml
application.yml
Spring Boot中yml配置文件的使用一些规则,一些注意点等等~
kubectl apply -f kube-flannel.yml
docker swarm部署分布式微服务编排文件示例
idea读取YML配置文件readApplication,本demo适用于刚入坑gradle,教程比较基础详细,教程地址:https://mp.csdn.net/postedit/80379357
https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml
逆向开发解析apktool.yml 可能会用到,解析yml、yaml可能会用到
1_bootstrap.yml