bel_parser 1.0.0.alpha.35-java → 1.0.0.alpha.36-java
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 884938828857d7148f04245c1d0aa36cb98d9fdb
|
4
|
+
data.tar.gz: 2f33f84994e1e492db710394e0cd7b77b189cd2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec5bf16855b3db4198d53a92628f13a4bf5cf0655dd49093f2f9698152e01ee84c7d599f97228fbc059b20a2e40393ee50ec305cb57b43ffc51d28efbb31f8a
|
7
|
+
data.tar.gz: 0036e9e4d089b197ee71d483b1ef89fd6fb89cc5293e72e28c6a6e68c091ae6d078fc337b144549e5cb6288e1fff1bce9f49cf1ed8071b4a13d84d5788a37cb6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.36
|
@@ -141,17 +141,18 @@ module BEL::Translator::Plugins
|
|
141
141
|
return bel unless annotation_references
|
142
142
|
|
143
143
|
annotation_references.reduce(bel) { |bel, ref|
|
144
|
-
|
145
|
-
bel << "DEFINE ANNOTATION #{keyword} AS "
|
144
|
+
bel << "DEFINE ANNOTATION #{ref.keyword} AS "
|
146
145
|
|
147
|
-
case type.to_sym
|
146
|
+
case ref.type.to_sym
|
147
|
+
when :url
|
148
|
+
bel << %Q{URL "#{ref.domain}"\n}
|
148
149
|
when :uri
|
149
|
-
bel << %Q{
|
150
|
+
bel << %Q{URI "#{ref.domain}"\n}
|
150
151
|
when :pattern
|
151
|
-
regex = domain.respond_to?(:source) ? domain.source : domain
|
152
|
+
regex = ref.domain.respond_to?(:source) ? ref.domain.source : ref.domain
|
152
153
|
bel << %Q{PATTERN "#{regex}"\n}
|
153
154
|
when :list
|
154
|
-
bel << %Q|LIST {#{domain.inspect[1...-1]}}\n|
|
155
|
+
bel << %Q|LIST {#{ref.domain.inspect[1...-1]}}\n|
|
155
156
|
end
|
156
157
|
bel
|
157
158
|
}
|
@@ -168,8 +169,7 @@ module BEL::Translator::Plugins
|
|
168
169
|
return bel unless namespace_references
|
169
170
|
|
170
171
|
namespace_references.reduce(bel) { |bel, ref|
|
171
|
-
|
172
|
-
bel << %Q{DEFINE NAMESPACE #{keyword} AS URL "#{url}"\n}
|
172
|
+
bel << %Q{DEFINE NAMESPACE #{ref.keyword} AS URL "#{ref.uri}"\n}
|
173
173
|
bel
|
174
174
|
}
|
175
175
|
bel << "\n"
|
@@ -5,9 +5,11 @@ module BELParser
|
|
5
5
|
class Annotation
|
6
6
|
include Enumerable
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
attr_accessor :keyword
|
9
|
+
attr_accessor :type
|
10
|
+
attr_accessor :domain
|
11
|
+
attr_reader :uri_reader
|
12
|
+
attr_reader :url_reader
|
11
13
|
|
12
14
|
def initialize(keyword, type, domain, options = {})
|
13
15
|
raise(ArgumentError, 'keyword is nil') unless keyword
|
@@ -18,13 +20,26 @@ module BELParser
|
|
18
20
|
@type = type.to_sym
|
19
21
|
@domain = domain
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
uri_reader = options.fetch(:uri_reader, nil)
|
24
|
+
url_reader = options.fetch(:url_reader, nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize_copy(original)
|
28
|
+
@keyword = original.keyword
|
29
|
+
@type = original.type
|
30
|
+
@domain = original.domain
|
31
|
+
@uri_reader = original.uri_reader
|
32
|
+
@url_reader = original.url_reader
|
33
|
+
end
|
34
|
+
|
35
|
+
def uri_reader=(uri_reader)
|
23
36
|
BELParser::Resource::Reader.assert_reader(@uri_reader, 'uri_reader')
|
37
|
+
@uri_reader = uri_reader
|
38
|
+
end
|
24
39
|
|
25
|
-
|
26
|
-
@url_reader = options.fetch(:url_reader, nil)
|
40
|
+
def url_reader=(url_reader)
|
27
41
|
BELParser::Resource::Reader.assert_reader(@url_reader, 'url_reader')
|
42
|
+
@url_reader = url_reader
|
28
43
|
end
|
29
44
|
|
30
45
|
def uri?
|
@@ -37,9 +52,9 @@ module BELParser
|
|
37
52
|
|
38
53
|
def [](value)
|
39
54
|
if uri?
|
40
|
-
@uri_reader.retrieve_value_from_resource(@
|
55
|
+
@uri_reader.retrieve_value_from_resource(@domain, value)
|
41
56
|
elsif url?
|
42
|
-
@url_reader.retrieve_value_from_resource(@
|
57
|
+
@url_reader.retrieve_value_from_resource(@domain, value)
|
43
58
|
else
|
44
59
|
nil
|
45
60
|
end
|
@@ -49,9 +64,9 @@ module BELParser
|
|
49
64
|
if block_given?
|
50
65
|
values =
|
51
66
|
if uri?
|
52
|
-
@uri_reader.retrieve_values_from_resource(@
|
67
|
+
@uri_reader.retrieve_values_from_resource(@domain)
|
53
68
|
elsif url?
|
54
|
-
@url_reader.retrieve_values_from_resource(@
|
69
|
+
@url_reader.retrieve_values_from_resource(@domain)
|
55
70
|
else
|
56
71
|
[]
|
57
72
|
end
|
@@ -64,15 +79,22 @@ module BELParser
|
|
64
79
|
end
|
65
80
|
|
66
81
|
def hash
|
67
|
-
[@keyword, @
|
82
|
+
[@keyword, @type, @domain].hash
|
68
83
|
end
|
69
84
|
|
70
85
|
def ==(other)
|
71
86
|
return false if other.nil?
|
72
|
-
@keyword == other.keyword &&
|
87
|
+
@keyword == other.keyword &&
|
88
|
+
@type == other.type &&
|
89
|
+
@domain == other.domain
|
73
90
|
end
|
74
91
|
alias :eql? :'=='
|
75
92
|
|
93
|
+
def domain_equal?(other)
|
94
|
+
return false if other.nil?
|
95
|
+
@type == other.type && @domain == other.domain
|
96
|
+
end
|
97
|
+
|
76
98
|
def to_s
|
77
99
|
@keyword.to_s
|
78
100
|
end
|
@@ -13,6 +13,8 @@ module BELParser
|
|
13
13
|
attr_accessor :keyword
|
14
14
|
attr_accessor :uri
|
15
15
|
attr_accessor :url
|
16
|
+
attr_reader :uri_reader
|
17
|
+
attr_reader :url_reader
|
16
18
|
|
17
19
|
def initialize(keyword, uri = nil, url = nil, options = {})
|
18
20
|
raise(ArgumentError, 'keyword is nil') unless keyword
|
@@ -29,6 +31,14 @@ module BELParser
|
|
29
31
|
BELParser::Resource::Reader.assert_reader(@url_reader, 'url_reader')
|
30
32
|
end
|
31
33
|
|
34
|
+
def initialize_copy(original)
|
35
|
+
@keyword = original.keyword
|
36
|
+
@uri = original.uri
|
37
|
+
@uri_reader = original.uri_reader
|
38
|
+
@url = original.url
|
39
|
+
@url_reader = original.url_reader
|
40
|
+
end
|
41
|
+
|
32
42
|
def uri?
|
33
43
|
!@uri.nil?
|
34
44
|
end
|
@@ -75,6 +85,11 @@ module BELParser
|
|
75
85
|
end
|
76
86
|
alias :eql? :'=='
|
77
87
|
|
88
|
+
def domain_equal?(other)
|
89
|
+
return false if other.nil?
|
90
|
+
@uri == other.uri && @url == other.url
|
91
|
+
end
|
92
|
+
|
78
93
|
def to_s
|
79
94
|
@keyword.to_s
|
80
95
|
end
|