itamae 1.1.9 → 1.1.10

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: e40f10bed229f296509ad2b47f6aa02b349d4d47
4
- data.tar.gz: fb80dfa8b7e4037e3b30e3bc6f0e635f907bb73b
3
+ metadata.gz: 616cfc3511d0ccaed6104add74b3502120fc80a5
4
+ data.tar.gz: fdec38243e8406d3646df667690fd19129ff61cd
5
5
  SHA512:
6
- metadata.gz: 1d290bf712650279b32aa100f4b3386614454c038aac972ce7e7bd2747f45a43797b8c34102a0017ac213a89b721dc1601119c9828987f26bcd8523e5b704f00
7
- data.tar.gz: 28ae455b9dbbb47ede2ede766f5139f06808993aabf19d7dcb8256840735eef6266cebe8f33fac0b8b11584bb642f0be63eb156bd359d7a215d6e61e82ac2fa7
6
+ metadata.gz: 22cec5cb03fe430522b6afbd3f2159ff626f79cc8787d398224d69a6a78dd9ef801c937e0a056cd015d840113080a9b42b4c0afe60c268e87007173f34501b5b
7
+ data.tar.gz: 300eead221e03c2e58c6604e150a6d1149646d826bfb1266fb527ceeed8dcdef0ad88790a70c6c2b0bf2b8775ea464b5f9ba3e7d809e33b3a29ffc5113d85e59
@@ -1,3 +1,9 @@
1
+ ## v1.1.10
2
+
3
+ Feature
4
+
5
+ - `--dot` option to write dependency graph of recipes (Experimental)
6
+
1
7
  ## v1.1.9
2
8
 
3
9
  Improvements
@@ -15,6 +15,7 @@ module Itamae
15
15
  end
16
16
 
17
17
  desc "local RECIPE [RECIPE...]", "Run Itamae locally"
18
+ option :dot, type: :string, default: nil, desc: "Only write dependency graph in DOT", banner: "PATH"
18
19
  option :node_json, type: :string, aliases: ['-j']
19
20
  option :node_yaml, type: :string, aliases: ['-y']
20
21
  option :dry_run, type: :boolean, aliases: ['-n']
@@ -28,6 +29,7 @@ module Itamae
28
29
  end
29
30
 
30
31
  desc "ssh RECIPE [RECIPE...]", "Run Itamae via ssh"
32
+ option :dot, type: :string, default: nil, desc: "Only write dependency graph in DOT", banner: "PATH"
31
33
  option :node_json, type: :string, aliases: ['-j']
32
34
  option :node_yaml, type: :string, aliases: ['-y']
33
35
  option :dry_run, type: :boolean, aliases: ['-n']
@@ -39,11 +39,17 @@ module Itamae
39
39
  end.flatten
40
40
  end
41
41
 
42
- def recipes
42
+ def recipes(options = {})
43
+ options = {recursive: true}.merge(options)
44
+
43
45
  self.select do |item|
44
46
  item.is_a?(Recipe)
45
47
  end.map do |recipe|
46
- [recipe] + recipe.children.recipes
48
+ if options[:recursive]
49
+ [recipe] + recipe.children.recipes
50
+ else
51
+ recipe
52
+ end
47
53
  end.flatten
48
54
  end
49
55
 
@@ -57,5 +63,28 @@ module Itamae
57
63
  end
58
64
  end
59
65
  end
66
+
67
+ # returns dependencies graph in DOT
68
+ def deps_in_dot
69
+ result = ""
70
+ result << "digraph recipes {\n"
71
+ result << _deps_in_dot
72
+ result << "}"
73
+
74
+ result
75
+ end
76
+
77
+ def _deps_in_dot
78
+ result = ""
79
+
80
+ recipes(recursive: false).each do |recipe|
81
+ recipe.children.recipes(recursive: false).each do |child_recipe|
82
+ result << %{ "#{recipe.path}" -> "#{child_recipe.path}";\n}
83
+ end
84
+ result << recipe.children._deps_in_dot
85
+ end
86
+
87
+ result
88
+ end
60
89
  end
61
90
  end
@@ -12,6 +12,15 @@ module Itamae
12
12
 
13
13
  runner = self.new(node_from_options(options))
14
14
  runner.load_recipes(recipe_files)
15
+
16
+ if dot_file = options[:dot]
17
+ Logger.info "Writing dependency graph in DOT to #{dot_file}..."
18
+ open(dot_file, 'w') do |f|
19
+ f.write(runner.children.deps_in_dot)
20
+ end
21
+ return
22
+ end
23
+
15
24
  runner.run(dry_run: options[:dry_run])
16
25
  end
17
26
 
@@ -1 +1 @@
1
- 1.1.9
1
+ 1.1.10
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai