revocare 0.1.1 → 0.2.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
  SHA256:
3
- metadata.gz: 8f929fa681bc6b0ada88fd4ff25836596e9994e1559b14bfc5c4f529a6beff99
4
- data.tar.gz: ae32cfc85a2bdca4d5dd23eb21dbc4184cbdf2fe1e5c9ae459695c33cd3e99fb
3
+ metadata.gz: e43ceb2584f78094a31fb9289b40ccd9bbf8650ddb9905bb9cf37004ccc1c9fc
4
+ data.tar.gz: 6d65f5b9409553aa60dd0193a641252af0e2581463ce84cade6bbc697f9e59e6
5
5
  SHA512:
6
- metadata.gz: 5678ed93ba7a0e5f691f0bf2d0cce4f7c68733a9d8ed13e569dce1b314ea70c5426da08fca50ddb3fc5d77e76d641e8ea8cdfe7cc2d07f350950c3f39e4cf72b
7
- data.tar.gz: bc95dbf169d33c8de843ab0585a58630694cf2fa1d796041cd44c895dbe506e3cb76d6b1a1db4530122c6474dccf938e81ce2fce51ff871478e27b42fa1f2dda
6
+ metadata.gz: 25281b5ad2fed87409376d50df06f9d1c79bca374ca25fac74610dcecfeebab29287fd83e08034033cacd94922cd62c99bc1deb32f85da7b81133da03f356718
7
+ data.tar.gz: e2e30482a99d39910ea928c4f47b1af946048424bccead1fc5a4856b7a376828325561ba9489f9f056ddd028e43a97805ca3e714d4bd9078422654842f7d854b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # `revocare`
2
2
 
3
+ ## [0.2.1] (Unreleased)
4
+ - Properly handle custom validators
5
+ - Show validator class name instead of underscore-d name
6
+
7
+ ## [0.2.0]
8
+ - Create a directory to hold all files. Also, create a file for each model rather than a single file for all models. This vastly improves readability.
9
+
3
10
  ## [0.1.1]
4
11
  - Make each callback name and chain node unique as to not share nodes between models
5
12
  - Properly order callback methods in which they will be executed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- revocare (0.1.1)
4
+ revocare (0.2.1)
5
5
  activerecord (>= 5.2, < 7.1)
6
6
  activesupport (>= 5.2, < 7.1)
7
7
  ruby-graphviz (~> 1.2)
@@ -65,9 +65,14 @@ module Revocare
65
65
 
66
66
  def extract_methods(callback_filter)
67
67
  if callback_filter.is_a?(ActiveModel::Validator)
68
- name = callback_filter.class.name.demodulize.underscore
69
- callback_filter.attributes.map do |attr|
70
- [name, attr].join(":")
68
+ name = callback_filter.class.name.demodulize
69
+
70
+ if callback_filter.respond_to?(:attributes)
71
+ callback_filter.attributes.map do |attribute|
72
+ [name, attribute].join(":")
73
+ end
74
+ else
75
+ [name]
71
76
  end
72
77
  else
73
78
  [callback_filter.to_s]
data/lib/revocare/cli.rb CHANGED
@@ -30,7 +30,7 @@ module Revocare
30
30
  def call
31
31
  data = Revocare::CallbackData.to_a
32
32
  writer = Revocare::DataWriter.new(data: data)
33
- writer.write_to_file
33
+ writer.write_to_directory
34
34
  end
35
35
  end
36
36
  end
@@ -7,10 +7,11 @@ module Revocare
7
7
  SUPPORTED_FORMATS = [
8
8
  GRAPHVIZ_FORMAT,
9
9
  ].freeze
10
- DEFAULT_FILENAME = "callbacks.pdf"
10
+ DEFAULT_DIRECTORY = "./callbacks"
11
+ DEFAULT_EXTENSION = "pdf"
11
12
 
12
13
  def initialize(data:, format: DEFAULT_FORMAT)
13
- @graph = GraphViz.new(:G, type: :digraph)
14
+ @graphs = []
14
15
  @data = data
15
16
  @format = format
16
17
  validate_format!
@@ -28,31 +29,37 @@ module Revocare
28
29
  @format
29
30
  end
30
31
 
31
- def write_to_file(filename: DEFAULT_FILENAME)
32
- extension = File.extname(filename).tr(".", "").to_sym
32
+ def write_to_directory(extension: DEFAULT_EXTENSION)
33
+ FileUtils.mkdir_p(DEFAULT_DIRECTORY)
33
34
 
34
35
  if format == GRAPHVIZ_FORMAT
35
36
  data.each_with_index do |model_data, index|
36
- model_node = add_model_node(model_data[:model])
37
+ @current_graph = GraphViz.new(:G, type: :digraph)
38
+
39
+ model_name = model_data[:model]
40
+ model_node = add_model_node(model_name)
41
+
37
42
  model_data[:callbacks].each do |callback|
38
43
  name, chain = callback.values_at(:callback_name, :callback_chain)
39
44
  name_node = add_callback_node(name, index)
45
+
40
46
  method_nodes = chain.each_with_index.map do |method, order|
41
47
  add_callback_chain_node(method, index, order)
42
48
  end
43
49
 
44
- graph.add_edge(model_node, name_node)
45
- graph.add_edges(name_node, method_nodes)
50
+ current_graph.add_edge(model_node, name_node)
51
+ current_graph.add_edges(name_node, method_nodes)
46
52
  end
47
- end
48
53
 
49
- graph.output(extension => filename)
54
+ filename = "#{DEFAULT_DIRECTORY}/#{model_name.downcase}.#{extension}"
55
+ current_graph.output(extension => filename)
56
+ end
50
57
  end
51
58
  end
52
59
 
53
60
  private
54
61
 
55
- attr_reader :data, :graph
62
+ attr_reader :data, :graphs, :current_graph
56
63
 
57
64
  def validate_format!
58
65
  if !SUPPORTED_FORMATS.include?(@format)
@@ -74,7 +81,7 @@ module Revocare
74
81
  end
75
82
 
76
83
  def add_node(name, index, shape, label = nil)
77
- graph.add_node("#{name}#{index}", label: label || name, shape: shape)
84
+ current_graph.add_node("#{name}#{index}", label: label || name, shape: shape)
78
85
  end
79
86
  end
80
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Revocare
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revocare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Ewing
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-21 00:00:00.000000000 Z
11
+ date: 2023-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord