visualize_packs 0.5.4 → 0.5.5

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
  SHA256:
3
- metadata.gz: 01f6c9f4bc79fee9a854283bdae4b57d12fa2a29fc53c1610765ef137f69dd68
4
- data.tar.gz: bfb38e97af2696a7ee295341782905340a1458cc62004cd58b077a3caeb1d514
3
+ metadata.gz: b4ade528fc794c71afb2470d457f31d72b2456b85a484f2b328ca1c73e7fc2cf
4
+ data.tar.gz: 239feaba7ced4136ac77625e6ed1632a031492e86ca6d1c0d025976b23e31300
5
5
  SHA512:
6
- metadata.gz: 39ee40c6a79f5c883ee1f14ebe9c964fedb65281aadf7ee43163f07a3f9e8f1401379baaf4efd0ccaedb7593d7ab18e28ff8d743e076da6a0028844b2180bb47
7
- data.tar.gz: '0997b1cdf11c0095cb2a0bc00ba0dcd04b9ce58a1aff50b9fd106181806d0be3f36df316111946a2c1719014899043c173216dea0f4bd3301f99fdb5d1d6f368'
6
+ metadata.gz: 18a67a3b983c99f4d273a8e32e390a63bb0fa0398c7da51d4552fee73eedda0e77debfe45a3e196cae5b8d0e370124f7eeb82d202f4daba7b68bb90fb5b15708
7
+ data.tar.gz: 60e06eaacba3c796ee9045223d47203f63b19e83664c58b9db69696c591f68169f217bc8172287fcb9cc61befaa2008c4a337e486febd0477b6a0b8d14100520
data/bin/visualize_packs CHANGED
@@ -10,11 +10,25 @@ require_relative '../lib/options'
10
10
 
11
11
  options = Options.new
12
12
 
13
+ supported_todo_types = %w[
14
+ privacy
15
+ architecture
16
+ visibility
17
+ dependency
18
+ ].sort.freeze
19
+
20
+ def validated_list(o, valid_arguments)
21
+ list = o.to_s.split(",").uniq
22
+ raise OptionParser::InvalidArgument, o unless (list - valid_arguments).empty?
23
+ list
24
+ end
25
+
13
26
  OptionParser.new do |opt|
14
27
  opt.on('--no-legend', "Don't show legend") { |o| options.show_legend = false }
15
28
  opt.on('--no-layers', "Don't show architectural layers") { |o| options.show_layers = false }
16
29
  opt.on('--no-dependencies', "Don't show accepted dependencies") { |o| options.show_dependencies = false }
17
30
  opt.on('--no-todos', "Don't show package todos") { |o| options.show_todos = false }
31
+ opt.on('--only-todo-types=privacy,architecture,etc', "Show only these types of todos (supported types: #{supported_todo_types.join(', ')})") { |o| options.only_todo_types = validated_list(o, supported_todo_types) }
18
32
  opt.on('--no-privacy', "Don't show privacy enforcement") { |o| options.show_privacy = false }
19
33
  opt.on('--no-teams', "Don't show team colors") { |o| options.show_teams = false }
20
34
 
data/lib/graph.dot.erb CHANGED
@@ -81,10 +81,14 @@ digraph package_diagram {
81
81
  <%- end -%>
82
82
  <%- if options.show_todos -%>
83
83
  <%- all_packages.each do |package| -%>
84
- <%- violations_by_package = package.violations.group_by(&:to_package_name) -%>
84
+ <%- filtered_violations = package.violations -%>
85
+ <%- if options.only_todo_types.any? -%>
86
+ <%- filtered_violations = filtered_violations.select { options.only_todo_types.include?(_1.type) } -%>
87
+ <%- end -%>
88
+ <%- violations_by_package = filtered_violations.group_by(&:to_package_name) -%>
85
89
  <%- violations_by_package.keys.each do |violations_to_package| -%>
86
- <%- violation_types = violations_by_package[violations_to_package].group_by(&:type) -%>
87
- <%- violation_types.keys.each do |violation_type| -%>
90
+ <%- todo_types = violations_by_package[violations_to_package].group_by(&:type) -%>
91
+ <%- todo_types.keys.each do |violation_type| -%>
88
92
  <%- if show_edge.call(package.name, violations_to_package) -%>
89
93
  "<%= package.name -%>" -> "<%= violations_to_package -%>"<%= violation_type == 'privacy' ? ':private' : '' -%> [ color=darkred style=dashed
90
94
  constraint=false
@@ -100,7 +104,7 @@ digraph package_diagram {
100
104
  <%- end -%>
101
105
  <%-
102
106
  max_edge_width = 10
103
- edge_width = (violation_types[violation_type].count / max_violation_count.to_f * max_edge_width).to_i
107
+ edge_width = (todo_types[violation_type].count / max_violation_count.to_f * max_edge_width).to_i
104
108
  -%>
105
109
  penwidth=<%= edge_width -%>
106
110
  ]
data/lib/options.rb CHANGED
@@ -8,6 +8,7 @@ class Options < T::Struct
8
8
  prop :show_layers, T::Boolean, default: true
9
9
  prop :show_dependencies, T::Boolean, default: true
10
10
  prop :show_todos, T::Boolean, default: true
11
+ prop :only_todo_types, T::Array[String], default: []
11
12
  prop :show_privacy, T::Boolean, default: true
12
13
  prop :show_teams, T::Boolean, default: true
13
14
 
@@ -62,11 +62,12 @@ module VisualizePacks
62
62
  options.show_layers ? nil : "hiding layers",
63
63
  options.show_dependencies ? nil : "hiding dependencies",
64
64
  options.show_todos ? nil : "hiding todos",
65
+ options.only_todo_types.empty? ? nil : "only #{limited_sentence(options.only_todo_types)} todos",
65
66
  options.show_privacy ? nil : "hiding privacy",
66
67
  options.show_teams ? nil : "hiding teams",
67
68
  options.roll_nested_todos_into_top_level ? "hiding nested packs" : nil,
68
69
  options.show_nested_relationships ? nil : "hiding nested relationships",
69
- options.exclude_packs.empty? ? nil : "excluding pack#{options.exclude_packs.size > 1 ? 's' : ''}: #{exclude_packs_info(options.exclude_packs)}",
70
+ options.exclude_packs.empty? ? nil : "excluding pack#{options.exclude_packs.size > 1 ? 's' : ''}: #{limited_sentence(options.exclude_packs)}",
70
71
  ].compact.join(', ').strip
71
72
  main_title = "#{app_name}: #{focus_info}#{skipped_info != '' ? ' - ' + skipped_info : ''}"
72
73
  sub_title = ""
@@ -76,14 +77,11 @@ module VisualizePacks
76
77
  "<<b>#{main_title}</b>#{sub_title}>"
77
78
  end
78
79
 
79
- def self.exclude_packs_info(exclude_packs)
80
- case exclude_packs.size
81
- when 1
82
- exclude_packs.first
83
- when 2
84
- exclude_packs.join(" and ")
80
+ def self.limited_sentence(list)
81
+ if list.size <= 2
82
+ list.join(" and ")
85
83
  else
86
- "#{exclude_packs[0, 2].join(", ")}, and #{exclude_packs.size - 2} more."
84
+ "#{list[0, 2].join(", ")}, and #{list.size - 2} more"
87
85
  end
88
86
  end
89
87
 
@@ -120,11 +118,11 @@ module VisualizePacks
120
118
  all_packages.each do |package|
121
119
  violations_by_package = package.violations.group_by(&:to_package_name)
122
120
  violations_by_package.keys.each do |violations_to_package|
123
- violation_types = violations_by_package[violations_to_package].group_by(&:type)
124
- violation_types.keys.each do |violation_type|
121
+ todo_types = violations_by_package[violations_to_package].group_by(&:type)
122
+ todo_types.keys.each do |violation_type|
125
123
  if show_edge.call(package.name, violations_to_package)
126
124
  key = "#{package.name}->#{violations_to_package}:#{violation_type}"
127
- violation_counts[key] = violation_types[violation_type].count
125
+ violation_counts[key] = todo_types[violation_type].count
128
126
  # violation_counts[key] += 1
129
127
  end
130
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visualize_packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers