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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/revocare/callback_data.rb +8 -3
- data/lib/revocare/cli.rb +1 -1
- data/lib/revocare/data_writer.rb +18 -11
- data/lib/revocare/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43ceb2584f78094a31fb9289b40ccd9bbf8650ddb9905bb9cf37004ccc1c9fc
|
4
|
+
data.tar.gz: 6d65f5b9409553aa60dd0193a641252af0e2581463ce84cade6bbc697f9e59e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
69
|
-
|
70
|
-
|
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
data/lib/revocare/data_writer.rb
CHANGED
@@ -7,10 +7,11 @@ module Revocare
|
|
7
7
|
SUPPORTED_FORMATS = [
|
8
8
|
GRAPHVIZ_FORMAT,
|
9
9
|
].freeze
|
10
|
-
|
10
|
+
DEFAULT_DIRECTORY = "./callbacks"
|
11
|
+
DEFAULT_EXTENSION = "pdf"
|
11
12
|
|
12
13
|
def initialize(data:, format: DEFAULT_FORMAT)
|
13
|
-
@
|
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
|
32
|
-
|
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
|
-
|
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
|
-
|
45
|
-
|
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
|
-
|
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, :
|
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
|
-
|
84
|
+
current_graph.add_node("#{name}#{index}", label: label || name, shape: shape)
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
data/lib/revocare/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|