knife-undev 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca04a83132b4acf4ab9dff31685a44a9250c6637
4
- data.tar.gz: 03d189c3f30bce8b449671bf73f55e12d5d5159c
3
+ metadata.gz: ee3859bb9ebaf13604c3dea0ee4cecbd92a85901
4
+ data.tar.gz: 6450b2a74accd0842836ed86880b0ab2c3326c19
5
5
  SHA512:
6
- metadata.gz: 8a942a39807dfe9abd63550510a0fd4128206fe79b4b52675f7edb11b6278ed5696c7801e98d306ae15595299e912a9c8d61b6c4dd7de00cc94824bf6550a631
7
- data.tar.gz: 66601c053a2b0b485c6c749a58122f5e205d10df6a73ad61834019eaa0896e012ed5a5592bf61d170a0e79eb5976c9494c9cc98de8f966ac90d5af48ea9b2f9c
6
+ metadata.gz: 1f6a58475ff094de062036cb32d8b520f58a72c3dc0b7ffcd239a321d13302b5e764dcc08ff8fffdfcd35d1b786d165b194963d946945b0e89e4169b3c0194b6
7
+ data.tar.gz: 114eb0fe6aa65640d0aa9a94f100f79c2332680133dbcf3dc4746d463471f64dfae420162f6751578efd23b22740c1ba9ba6d139dc648d7d6b4b4fdd18c4b035
@@ -9,6 +9,7 @@ module Knife
9
9
  def initialize(filename, klass = 'role')
10
10
  @filename = filename
11
11
  @klass = klass
12
+ @comment_counter = 0
12
13
  end
13
14
 
14
15
  def to_yml
@@ -24,6 +25,10 @@ module Knife
24
25
  hash.delete(key) if hash[key].nil? || hash[key].empty?
25
26
  end
26
27
 
28
+ def comment(hash, value='')
29
+ hash["#comment_#{@comment_counter+=1}"] = ""
30
+ end
31
+
27
32
  def role_to_yml
28
33
  r = Chef::Role.new
29
34
  r.from_file(@filename)
@@ -35,8 +40,15 @@ module Knife
35
40
  safe_delete(hash, 'run_list')
36
41
  result_hash['name'] = hash.delete('name')
37
42
  result_hash['description'] = hash.delete('description')
43
+ comment(result_hash)
38
44
  result_hash['env_run_lists'] = hash.delete('env_run_lists')
39
- puts result_hash.merge(hash).to_yaml
45
+ comment(result_hash)
46
+ result_hash.merge(hash).to_yaml.each_line do |line|
47
+ puts '' if line.match /#comment_\d+/
48
+ next if line.match /#comment_\d+/
49
+ next if line == '---'
50
+ puts line
51
+ end
40
52
  end
41
53
 
42
54
  def env_to_yml
@@ -49,7 +61,9 @@ module Knife
49
61
  safe_delete(hash, 'default_attributes')
50
62
  safe_delete(hash, 'cookbook_versions')
51
63
  safe_delete(hash, 'description')
52
- puts hash.to_yaml
64
+ hash.to_yaml.each_line do |line|
65
+ next if line == '---'
66
+ end
53
67
  end
54
68
 
55
69
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Undev
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-undev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev Dmitry