yaml_master 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: cb0a154bcbcb74fe6f9a31c2fd0a1421ef2efa06
4
- data.tar.gz: 1f2e031848a95f68234958b80e68fbcfff1e8db6
3
+ metadata.gz: 4a52e9659a1cab26545e88d254d109176f21e720
4
+ data.tar.gz: a89a4cdf70880d00765860765c84a6d1c45c3ae9
5
5
  SHA512:
6
- metadata.gz: 1975b6a4eeb3860c01b75b000fd907d4011144b12b70f87c24059091dc866959c9991ecedf79dfb36846a4bc74caf1ccfbb7b79ee353f5e39f7c6c1df591bf26
7
- data.tar.gz: e51646544a3c2c937ffd9dbbe50955ffc47568813d9dce2bd5576b5439c967646e2010bb472724369949772e2f6b76d48e59c1605bf09c58178d33f09feba4b2
6
+ metadata.gz: 1d644176ec9b8a3e1f5f897e0f5af21c16a7b041544effa4c5fe95ee35fa2d94cc6b24634e7e22eaf278791410aaa9c24e841de0caf512f84775ebce19b947a2
7
+ data.tar.gz: 326b8d9b4a10c319ff2d0f1329ee344618df64de6c0a3d25cf54b588bf5d2f1e26765539c83c78da855b4b09f52e825597b9bf13b654a04913620e2ea936ddcf
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/joker1007/yaml_master.svg)](https://travis-ci.org/joker1007/yaml_master)
4
4
 
5
5
  This gem is helper of yaml file generation from single master yaml file.
6
+ And this gem has some useful helpers. For example `!include`
6
7
 
7
8
  ## Installation
8
9
 
@@ -25,14 +26,15 @@ Or install it yourself as:
25
26
  ### command help
26
27
  ```
27
28
  Usage: yaml_master [options]
28
- -m, --master master yaml file
29
- -k, --key single generate target key (in data: block)
30
- -o, --output output filename for single generate target
31
- -a, --all target all key (defined in yaml_master: block)
32
- -p, --properties set property (--properties="NAME=VALUE,NAME=VALUE" or -p "NAME=VALUE" -p "NAME=VALUE")
33
- -h, --help display this help
34
- -v, --verbose verbose mode
35
- --version print the version
29
+ -m, --master=MASTER_FILE master yaml file
30
+ -k, --key=KEY single generate target key (in data: block)
31
+ -o, --output=OUTPUT output filename for single generate target
32
+ -a, --all target all key (defined in yaml_master: block)
33
+ -d, --dump dump evaluated master yaml
34
+ -p, --properties=PROPERTIES set property (--properties="NAME=VALUE,NAME=VALUE" or -p "NAME=VALUE" -p "NAME=VALUE")
35
+ -v, --verbose verbose mode
36
+ --version Print version
37
+ -h, --help Prints this help
36
38
  ```
37
39
 
38
40
  ### Support YAML tags
@@ -108,7 +110,7 @@ data:
108
110
  table: my_table
109
111
  mode: insert
110
112
 
111
- tag_sample
113
+ tag_sample:
112
114
  included: !include included.yml
113
115
  master_path: !master_path
114
116
  user_home: !user_home
@@ -253,6 +255,65 @@ read_file_if_exist_nothing:
253
255
  read_file_if_exist2: 'dummy '
254
256
  ```
255
257
 
258
+ ## Raw Dump
259
+
260
+ Any yaml file can use yaml_master feature.
261
+
262
+ ```yaml
263
+ # tag_sample.yml
264
+
265
+ included: !include included.yml
266
+ master_path: !master_path
267
+ user_home: !user_home
268
+ env: !env HOME
269
+ properties: !properties foo
270
+ read_file_if_exist: !read_file_if_exist sample.txt
271
+ read_file_if_exist_nothing: !read_file_if_exist nothing.txt
272
+ ```
273
+
274
+ ```sh
275
+ % yaml_master -m tag_sample.yml --dump
276
+ ```
277
+
278
+ output
279
+
280
+ ```yaml
281
+ included:
282
+ xyz: hoge
283
+ db:
284
+ adapter: mysql2
285
+ encoding: utf8
286
+ database: development
287
+ pool: 5
288
+ host:
289
+ username: root
290
+ password:
291
+ socket: "/tmp/mysql.sock"
292
+ abc:
293
+ - 1
294
+ - 2.3
295
+ - a: 1
296
+ b: 2
297
+ included2:
298
+ - foo: bar
299
+ - hoge: fuga
300
+ - :abc:
301
+ - 1
302
+ - 2
303
+ - 3
304
+ master_path: "/home/joker/.ghq/github.com/joker1007/yaml_master/spec/sample.yml"
305
+ master_path2: "/home/joker/.ghq/github.com/joker1007/yaml_master/spec/sample.yml"
306
+ user_home: "/home/joker"
307
+ user_home2: "/home/joker"
308
+ env: "/home/joker"
309
+ properties: '24'
310
+ read_file_if_exist: 'dummy
311
+
312
+ '
313
+ read_file_if_exist_nothing:
314
+ read_file_if_exist2: 'dummy '
315
+ ```
316
+
256
317
  ## How to use with Docker
257
318
 
258
319
  ```sh
@@ -29,22 +29,22 @@ class YamlMaster
29
29
  parser.handler = YamlMaster::YAMLTreeBuilder.new(@master_path, @properties, parser)
30
30
  @tree = parser.parse(yaml).handler.root
31
31
  @master = @tree.to_ruby[0]
32
-
33
- raise "yaml_master key is necessary on toplevel" unless @master["yaml_master"]
34
- raise "data key is necessary on toplevel" unless @master["data"]
35
32
  end
36
33
 
37
- def generate(key, output = nil, options = {})
38
- yaml = YAML.dump(fetch_data_from_master(key))
34
+ def dump(output = nil, options = {})
35
+ yaml = @tree.to_yaml
39
36
  write_to_output(yaml, output, options[:verbose])
40
37
  end
41
38
 
42
- def dump(output = nil, options = {})
43
- yaml = @tree.to_yaml
39
+ def generate(key, output = nil, options = {})
40
+ raise "data key is necessary on toplevel" unless @master["data"]
41
+ yaml = YAML.dump(fetch_data_from_master(key))
44
42
  write_to_output(yaml, output, options[:verbose])
45
43
  end
46
44
 
47
45
  def generate_all(options = {})
46
+ raise "yaml_master key is necessary on toplevel" unless @master["yaml_master"]
47
+ raise "data key is necessary on toplevel" unless @master["data"]
48
48
  @master["yaml_master"].each do |key, output|
49
49
  generate(key, output, options)
50
50
  end
@@ -1,3 +1,3 @@
1
1
  class YamlMaster
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler