vrt 0.4.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vrt/map.rb +15 -8
- data/lib/vrt/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f22ed952810213fc68ae4da65da024233dd76f6c
|
4
|
+
data.tar.gz: c517cd4bdc30fb87c1a985b8fe0167ed95eaf5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1537e271c74309332c3df8110936f2c8101aaed8f50bd14fd8b7ea74c2db6cf0f7ebcf3560055fac99037b35bcd1a51e71a000c133ed6c0f44c9e56ea6788d
|
7
|
+
data.tar.gz: 4c5cf89fe55f63c035bc6b15e9e00d2a43ffe05eac36ad935e31f7467d8200f327bb2e5fa5c5ec28f0c2553d41ce78aa3c9da9fca25fce4eee9f3045c6f48f38
|
data/lib/vrt/map.rb
CHANGED
@@ -11,21 +11,22 @@ module VRT
|
|
11
11
|
def initialize(version = nil)
|
12
12
|
@version = version || VRT.current_version
|
13
13
|
@structure = build_structure
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@_found_nodes = {}
|
15
|
+
@_lineages = {}
|
16
|
+
@_valid_vrt_ids = {}
|
17
|
+
@_valid_identifiers = {}
|
16
18
|
end
|
17
19
|
|
18
20
|
def find_node(string, max_depth: 'variant')
|
19
|
-
@
|
21
|
+
@_found_nodes[string + max_depth] ||= walk_node_tree(string, max_depth: max_depth)
|
20
22
|
end
|
21
23
|
|
22
|
-
def valid?(
|
23
|
-
|
24
|
-
node == 'other' || find_node(node)
|
24
|
+
def valid?(vrt_id)
|
25
|
+
@_valid_vrt_ids[vrt_id] ||= valid_identifier?(vrt_id) && !find_node(vrt_id).nil?
|
25
26
|
end
|
26
27
|
|
27
28
|
def get_lineage(string, max_depth: 'variant')
|
28
|
-
@
|
29
|
+
@_lineages[string + max_depth] ||= construct_lineage(string, max_depth)
|
29
30
|
end
|
30
31
|
|
31
32
|
# Returns list of top level categories in the shape:
|
@@ -39,9 +40,16 @@ module VRT
|
|
39
40
|
|
40
41
|
private
|
41
42
|
|
43
|
+
def valid_identifier?(vrt_id)
|
44
|
+
# At least one string of lowercase or _, plus up to 2 more with stops
|
45
|
+
@_valid_identifiers[vrt_id] ||= vrt_id =~ /other|\A[a-z_]+(\.[a-z_]+){0,2}\z/
|
46
|
+
end
|
47
|
+
|
42
48
|
def construct_lineage(string, max_depth)
|
49
|
+
return unless valid_identifier?(string)
|
43
50
|
lineage = ''
|
44
51
|
walk_node_tree(string, max_depth: max_depth) do |ids, node, level|
|
52
|
+
return unless node
|
45
53
|
lineage += node.name
|
46
54
|
lineage += ' > ' unless level == ids.length
|
47
55
|
end
|
@@ -50,7 +58,6 @@ module VRT
|
|
50
58
|
|
51
59
|
def walk_node_tree(string, max_depth: 'variant')
|
52
60
|
id_tokens = string.split('.').map(&:to_sym)
|
53
|
-
return nil if id_tokens.size > 3
|
54
61
|
ids = id_tokens.take(DEPTH_MAP[max_depth])
|
55
62
|
node = @structure[ids[0]]
|
56
63
|
ids.each_index do |idx|
|
data/lib/vrt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vrt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barnett Klane
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0.48'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: pry
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
71
85
|
description:
|
72
86
|
email:
|
73
87
|
- barnett@bugcrowd.com
|