cmap 0.3.0 → 0.4.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 +4 -4
- data/lib/cmap/edges_to_queries.rb +5 -4
- data/lib/cmap/graph_to_sql.rb +5 -4
- data/lib/cmap/propositions_to_sql.rb +3 -2
- data/lib/cmap/subquery_expander.rb +3 -2
- data/lib/cmap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c1aa04d3a2f907856c9b8ee5585bfad160f5537
|
4
|
+
data.tar.gz: 73a72a40cc5dded9d995413e09c76024968b7482
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 562e1751d18d1f84671c6b4d6137cfcb4c12ef4739157f6b51cecdb563cbf08b6d64b32d42c4e580d0e994680d6455b9de511051de89637617eba8958560adb5
|
7
|
+
data.tar.gz: 42f17d5ef2eeff14a77f461c9d1f61c894296873174b9b85d396d02f5b436822aa5c644c94f79626060840b6da53b84313966c8e955459bf954f02f341b1efd0
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Cmap; class EdgesToQueries
|
2
2
|
|
3
|
-
attr_reader :edges, :table_name, :subquery_expander
|
3
|
+
attr_reader :edges, :table_name, :schema_name, :subquery_expander
|
4
4
|
|
5
|
-
def initialize(edges, table_name, subquery_expander)
|
5
|
+
def initialize(edges, table_name, schema_name, subquery_expander)
|
6
6
|
@edges = edges
|
7
7
|
@table_name = table_name
|
8
|
+
@schema_name = schema_name
|
8
9
|
@subquery_expander = subquery_expander
|
9
10
|
end
|
10
11
|
|
@@ -22,7 +23,7 @@ module Cmap; class EdgesToQueries
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def add_columns_queries
|
25
|
-
unique_edges.map {|e| "alter table #{table_name} add column #{e.destination_vertex} int2;"}
|
26
|
+
unique_edges.map {|e| "alter table #{schema_name}.#{table_name} add column #{e.destination_vertex} int2;"}
|
26
27
|
end
|
27
28
|
|
28
29
|
def grouped_edges
|
@@ -36,7 +37,7 @@ module Cmap; class EdgesToQueries
|
|
36
37
|
def updates
|
37
38
|
u = (grouped_edges[false] || []).map {|e| "#{e.destination_vertex}=(#{e.value})::int"}.join(", ")
|
38
39
|
return [] if u.empty?
|
39
|
-
["update #{table_name} set #{u};"]
|
40
|
+
["update #{schema_name}.#{table_name} set #{u};"]
|
40
41
|
end
|
41
42
|
|
42
43
|
end; end
|
data/lib/cmap/graph_to_sql.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module Cmap; class GraphToSql
|
2
2
|
|
3
|
-
attr_reader :table_name, :graph, :subquery_gsubs
|
3
|
+
attr_reader :table_name, :schema_name, :graph, :subquery_gsubs
|
4
4
|
|
5
|
-
def initialize(table_name, graph, subquery_gsubs = [])
|
5
|
+
def initialize(table_name, schema_name, graph, subquery_gsubs = [])
|
6
6
|
@table_name = table_name
|
7
|
+
@schema_name = schema_name
|
7
8
|
@graph = graph
|
8
9
|
@subquery_gsubs = subquery_gsubs
|
9
10
|
end
|
10
11
|
|
11
12
|
def queries
|
12
13
|
sorted_grouped_edges.inject([]) do |memo, (_, edges)|
|
13
|
-
memo += (EdgesToQueries.new(edges, table_name, subquery_expander).queries)
|
14
|
+
memo += (EdgesToQueries.new(edges, table_name, schema_name, subquery_expander).queries)
|
14
15
|
memo
|
15
16
|
end
|
16
17
|
end
|
@@ -18,7 +19,7 @@ module Cmap; class GraphToSql
|
|
18
19
|
private
|
19
20
|
|
20
21
|
def subquery_expander
|
21
|
-
SubqueryExpander.new(table_name: table_name, subquery_gsubs: subquery_gsubs)
|
22
|
+
SubqueryExpander.new(table_name: table_name, schema_name: schema_name, subquery_gsubs: subquery_gsubs)
|
22
23
|
end
|
23
24
|
|
24
25
|
def sorted_grouped_edges
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Cmap; class PropositionsToSql
|
2
2
|
|
3
|
-
attr_reader :propositions_path, :table_name, :subquery_gsubs
|
3
|
+
attr_reader :propositions_path, :table_name, :schema_name, :subquery_gsubs
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@propositions_path = args.fetch(:propositions_path)
|
7
7
|
@table_name = args.fetch(:table_name)
|
8
|
+
@schema_name = args.fetch(:schema_name)
|
8
9
|
@subquery_gsubs = args.fetch(:subquery_gsubs, [])
|
9
10
|
end
|
10
11
|
|
@@ -25,7 +26,7 @@ module Cmap; class PropositionsToSql
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def graph_to_sql
|
28
|
-
GraphToSql.new(table_name, sanitized_graph, subquery_gsubs)
|
29
|
+
GraphToSql.new(table_name, schema_name, sanitized_graph, subquery_gsubs)
|
29
30
|
end
|
30
31
|
|
31
32
|
end; end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Cmap; class SubqueryExpander
|
2
2
|
|
3
|
-
attr_reader :table_name, :subquery_gsubs
|
3
|
+
attr_reader :table_name, :schema_name, :subquery_gsubs
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@table_name = args.fetch(:table_name)
|
7
|
+
@schema_name = args.fetch(:schema_name)
|
7
8
|
@subquery_gsubs = args.fetch(:subquery_gsubs, [])
|
8
9
|
end
|
9
10
|
|
@@ -13,7 +14,7 @@ module Cmap; class SubqueryExpander
|
|
13
14
|
|
14
15
|
def query(edge)
|
15
16
|
r = edge.value
|
16
|
-
replacements = [["+table_name+", table_name], ["+destination_vertex+", edge.destination_vertex], ["+origin_vertex+", edge.origin_vertex]]
|
17
|
+
replacements = [["+table_name+", table_name], ["+schema_name+", schema_name], ["+destination_vertex+", edge.destination_vertex], ["+origin_vertex+", edge.origin_vertex]]
|
17
18
|
(subquery_gsubs + replacements).each {|gsub| r = r.gsub(*gsub)}
|
18
19
|
r
|
19
20
|
end
|
data/lib/cmap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MrPowers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|