culturecode_stagehand 0.10.2 → 0.11.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 631cfae3a83514e2678436cf359e33af77f49234
|
|
4
|
+
data.tar.gz: 40ad332a8e324c076e8cbff79d678657db0d58a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a52cace12d2485973e0443c2a44eee10a4c2df86f4c429b1db29ea3b8a7f2b9fb7830e325594016ea2e6851b95d2f54c37094dc85d2d750e91d896190015a66b
|
|
7
|
+
data.tar.gz: 05c33366d9c63aecce718f89a442bef8119b895f1bdd42066d81f738a46e7d0d89a6d6011125c398adff0e9c04737d8a4f21e836f5378ca48ed048c6cf9ec358
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'graphviz'
|
|
2
|
+
|
|
3
|
+
module Stagehand
|
|
4
|
+
module Auditor
|
|
5
|
+
class ChecklistVisualizer
|
|
6
|
+
def initialize(checklist, show_all_commits: false)
|
|
7
|
+
entries = checklist.affected_entries.select(&:commit_id)
|
|
8
|
+
|
|
9
|
+
@graph = GraphViz.new( :G, :type => :graph );
|
|
10
|
+
@commits = Hash.new {|hash, commit_id| hash[commit_id] = Stagehand::Staging::CommitEntry.find(commit_id) }
|
|
11
|
+
nodes = Hash.new
|
|
12
|
+
edges = []
|
|
13
|
+
|
|
14
|
+
# Detect edges
|
|
15
|
+
entries.group_by(&:key).each_value do |entries|
|
|
16
|
+
entries.combination(2).each do |entry_a, entry_b|
|
|
17
|
+
current_edge = [entry_a, entry_b]
|
|
18
|
+
next if edges.detect {|edge| edge.sort == current_edge.sort }
|
|
19
|
+
next if same_node?(entry_a, entry_b)
|
|
20
|
+
next if same_subject?(entry_a, entry_b)
|
|
21
|
+
edges << current_edge
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Create Subgraph nodes for commits with connections to other subjects
|
|
26
|
+
entries = edges.flatten.uniq unless show_all_commits
|
|
27
|
+
entries.group_by {|entry| commit_subject(entry) }.each do |subject, entries|
|
|
28
|
+
subgraph = create_subgraph(subject, @graph)
|
|
29
|
+
entries.each do |entry|
|
|
30
|
+
nodes[entry] = create_node(entry, subgraph)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Create edges
|
|
35
|
+
edges.each do |entry_a, entry_b|
|
|
36
|
+
create_edge(nodes[entry_a], nodes[entry_b], :label => edge_label(entry_a, entry_b))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def output(file_name, format: File.extname(file_name)[1..-1])
|
|
41
|
+
@graph.output(format => file_name)
|
|
42
|
+
File.open(file_name)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def create_subgraph(subject, graph)
|
|
48
|
+
graph.add_graph("cluster_#{subject}", :label => subject, :style => :filled, :color => :lightgrey)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def create_edge(node_a, node_b, options = {})
|
|
52
|
+
@graph.add_edges(node_a, node_b, options.reverse_merge(:color => :red, :fontcolor => :red))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def create_node(entry, graph)
|
|
56
|
+
graph.add_nodes(node_name(entry), :shape => :rect, :style => :filled, :fillcolor => :white)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def edge_label(entry_a, entry_b)
|
|
60
|
+
pretty_key(entry_a)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def same_node?(entry_a, entry_b)
|
|
64
|
+
node_name(entry_a) == node_name(entry_b)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def same_subject?(entry_a, entry_b)
|
|
68
|
+
commit_subject(entry_a) == commit_subject(entry_b)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def commit_subject(entry)
|
|
72
|
+
pretty_key(@commits[entry.commit_id])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def node_name(entry)
|
|
76
|
+
"Commit #{entry.commit_id}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def pretty_key(entry)
|
|
80
|
+
"#{entry.table_name.classify} #{entry.record_id}"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
data/lib/stagehand/auditor.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'stagehand/auditor/checklist_visualizer'
|
|
2
|
+
|
|
1
3
|
module Stagehand
|
|
2
4
|
module Auditor
|
|
3
5
|
extend self
|
|
@@ -64,6 +66,14 @@ module Stagehand
|
|
|
64
66
|
return output
|
|
65
67
|
end
|
|
66
68
|
|
|
69
|
+
def visualize(subject, output_file_name, options = {})
|
|
70
|
+
visualize_checklist(Staging::Checklist.new(subject), output_file_name, options)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def visualize_checklist(checklist, output_file_name, options = {})
|
|
74
|
+
ChecklistVisualizer.new(checklist, options).output(output_file_name)
|
|
75
|
+
end
|
|
76
|
+
|
|
67
77
|
private
|
|
68
78
|
|
|
69
79
|
# Incomplete End Operation that are not the last entry in their session
|
|
@@ -5,13 +5,13 @@ module Stagehand
|
|
|
5
5
|
CommitEntry.start_operations.pluck(:id).collect {|id| find(id) }
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def self.capture(subject_record = nil, &block)
|
|
8
|
+
def self.capture(subject_record = nil, except: [], &block)
|
|
9
9
|
start_operation = start_commit(subject_record)
|
|
10
10
|
init_session!(start_operation)
|
|
11
11
|
block.call(start_operation)
|
|
12
|
-
return end_commit(start_operation)
|
|
12
|
+
return end_commit(start_operation, except)
|
|
13
13
|
rescue => e
|
|
14
|
-
end_commit(start_operation)
|
|
14
|
+
end_commit(start_operation, except)
|
|
15
15
|
raise(e)
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -45,13 +45,12 @@ module Stagehand
|
|
|
45
45
|
|
|
46
46
|
# Sets the commit_id on all the entries between the start and end op.
|
|
47
47
|
# Returns the commit object for those entries
|
|
48
|
-
def self.end_commit(start_operation)
|
|
48
|
+
def self.end_commit(start_operation, except)
|
|
49
49
|
end_operation = CommitEntry.end_operations.create(:session => start_operation.session)
|
|
50
50
|
|
|
51
|
-
CommitEntry
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.update_all(:commit_id => start_operation.id)
|
|
51
|
+
scope = CommitEntry.where(:id => start_operation.id..end_operation.id, :session => start_operation.session)
|
|
52
|
+
scope = scope.where('table_name NOT IN (?) OR table_name IS NULL', except) if except.present?
|
|
53
|
+
scope.update_all(:commit_id => start_operation.id)
|
|
55
54
|
|
|
56
55
|
return new(start_operation.id)
|
|
57
56
|
end
|
|
@@ -9,8 +9,8 @@ module Stagehand
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
# Creates a stagehand commit to log database changes associated with the given record
|
|
12
|
-
def stage_changes(
|
|
13
|
-
Staging::Commit.capture(
|
|
12
|
+
def stage_changes(*args, &block)
|
|
13
|
+
Staging::Commit.capture(*args, &block)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Syncs the given record and all affected records to the production database
|
data/lib/stagehand/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: culturecode_stagehand
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nicholas Jakobsen
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-11-
|
|
12
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -39,6 +39,20 @@ dependencies:
|
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: ruby-graphviz
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
42
56
|
- !ruby/object:Gem::Dependency
|
|
43
57
|
name: rspec-rails
|
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -69,6 +83,7 @@ files:
|
|
|
69
83
|
- lib/stagehand.rb
|
|
70
84
|
- lib/stagehand/active_record_extensions.rb
|
|
71
85
|
- lib/stagehand/auditor.rb
|
|
86
|
+
- lib/stagehand/auditor/checklist_visualizer.rb
|
|
72
87
|
- lib/stagehand/cache.rb
|
|
73
88
|
- lib/stagehand/configuration.rb
|
|
74
89
|
- lib/stagehand/connection_adapter_extensions.rb
|
|
@@ -109,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
124
|
version: '0'
|
|
110
125
|
requirements: []
|
|
111
126
|
rubyforge_project:
|
|
112
|
-
rubygems_version: 2.
|
|
127
|
+
rubygems_version: 2.5.1
|
|
113
128
|
signing_key:
|
|
114
129
|
specification_version: 4
|
|
115
130
|
summary: Simplify the management of a sandbox database that can sync content to a
|