bel 0.4.0 → 0.4.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 +13 -0
- data/lib/bel/completion.rb +18 -5
- data/lib/bel/completion_rule.rb +29 -9
- data/lib/bel/resource.rb +2 -0
- data/lib/bel/resource/namespace.rb +8 -7
- data/lib/bel/resource/namespaces.rb +10 -9
- data/lib/bel/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b8255ab8d0f64149d63bba68dfc581972af8ff5
|
4
|
+
data.tar.gz: 71e13753d0f09de8f3a09d5b1a069400859e3ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c516ed72a14dcb7f4f7f30d880a938e5c2712cdb651eb71c85c2f70e1f2927e62541c19c564ae22a96e639d95a4e9adb01b45a6b8f55d2604c87251d5260ed3
|
7
|
+
data.tar.gz: 459e40f9843c66830eae53bc499534221a0bcd4785cf85211bed21a836e5ba722f3ba1fe8b7d27754f852b44bf68d17c776971f15a0f43127472e1242c9aac25
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@ All notable changes to bel.rb will be documented in this file. The curated log b
|
|
3
3
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [0.4.1][0.4.1] - 2015-12-17
|
7
|
+
### Added
|
8
|
+
- Updated `find` API of `BEL::Resource::Namespaces` and `BEL::Resource::Namespace` to find by string representing a URI.
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- [Development] Install `pry-byebug` only for `ruby` platforms. This allows development on JRuby.
|
12
|
+
- [Development] No-op `rake compile` when running on JRuby. Report informative message when compiling on JRuby.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Complete BEL namespaces and namespace values using the Namespaces API backed by RDF data.
|
16
|
+
- Enable :exclude_identifier_schemes option for BEL completion to disallow namespace value results that report an identifier as their preferred name. This is allowed if the namespace prefix is first provided (e.g. "EG:AKT" will find "EG:207").
|
17
|
+
|
6
18
|
## [0.4.0][0.4.0] - 2015-12-14
|
7
19
|
### Fixed
|
8
20
|
- Improved conversion of evidence to JSON Evidence format.
|
@@ -45,6 +57,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
45
57
|
### Added
|
46
58
|
- Development gem dependencies (i.e. byebug, pry, pry-byebug) for debugging.
|
47
59
|
|
60
|
+
[0.4.1]: https://github.com/OpenBEL/bel.rb/compare/0.4.0...0.4.1
|
48
61
|
[0.4.0]: https://github.com/OpenBEL/bel.rb/compare/0.3.3...0.4.0
|
49
62
|
[0.3.2]: https://github.com/OpenBEL/bel.rb/compare/0.3.1...0.3.2
|
50
63
|
[0.3.3]: https://github.com/OpenBEL/bel.rb/compare/0.3.2...0.3.3
|
data/lib/bel/completion.rb
CHANGED
@@ -12,9 +12,11 @@ module BEL
|
|
12
12
|
# otherwise the +to_s+ method is called. An empty +bel_expression+ will
|
13
13
|
# return all BEL functions as possible completions.
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
15
|
+
# A {BEL::Resource::Search} plugin must be provided that provides
|
16
|
+
# completions for namespaces and namespace values.
|
17
|
+
#
|
18
|
+
# A {BEL::Resource::Namespaces} API must be provided to resolve namespace
|
19
|
+
# properties given a URI.
|
18
20
|
#
|
19
21
|
# If +position+ is +nil+ then its assumed to be the last index of
|
20
22
|
# +bel_expression+ otherwise the +to_i+ method is called.
|
@@ -28,7 +30,14 @@ module BEL
|
|
28
30
|
# provide namespace value completions
|
29
31
|
# @param position [responds to #to_i] the position to complete from
|
30
32
|
# @return [Array<Completion>]
|
31
|
-
def self.complete(bel_expression, search
|
33
|
+
def self.complete(bel_expression, search, namespaces, position = nil)
|
34
|
+
raise ArgumentError.new(
|
35
|
+
"search should be a BEL::Resource::Search plugin implementation"
|
36
|
+
) unless search
|
37
|
+
raise ArgumentError.new(
|
38
|
+
"namespaces should be a BEL::Resource::Namespaces object"
|
39
|
+
) unless namespaces
|
40
|
+
|
32
41
|
bel_expression = (bel_expression || '').to_s
|
33
42
|
position = (position || bel_expression.length).to_i
|
34
43
|
if position < 0 or position > bel_expression.length
|
@@ -47,7 +56,11 @@ module BEL
|
|
47
56
|
options = {
|
48
57
|
:search => search
|
49
58
|
}
|
50
|
-
BEL::Completion::run_rules(
|
59
|
+
BEL::Completion::run_rules(
|
60
|
+
tokens, active_index, active_token,
|
61
|
+
:search => search,
|
62
|
+
:namespaces => namespaces
|
63
|
+
)
|
51
64
|
end
|
52
65
|
end
|
53
66
|
end
|
data/lib/bel/completion_rule.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative 'language'
|
2
2
|
require_relative 'namespace'
|
3
3
|
require_relative 'quoting'
|
4
|
-
require 'uri'
|
5
4
|
|
6
5
|
module BEL
|
7
6
|
module Completion
|
@@ -182,8 +181,9 @@ module BEL
|
|
182
181
|
include BEL::Quoting
|
183
182
|
|
184
183
|
def _apply(token_list, active_token, active_token_index, options = {})
|
185
|
-
search
|
186
|
-
|
184
|
+
search = options.delete(:search)
|
185
|
+
namespaces = options.delete(:namespaces)
|
186
|
+
return EMPTY_MATCH if !search || !namespaces || token_list.empty?
|
187
187
|
|
188
188
|
if active_token.type == :IDENT && active_token.value.length > 1
|
189
189
|
previous_token = token_list[active_token_index - 1]
|
@@ -191,16 +191,16 @@ module BEL
|
|
191
191
|
# search within a namespace
|
192
192
|
prefix_token = token_list[active_token_index - 2]
|
193
193
|
if prefix_token and prefix_token.type == :IDENT
|
194
|
-
namespace =
|
194
|
+
namespace = namespaces.find(prefix_token.value.downcase).first
|
195
195
|
if namespace
|
196
|
-
scheme_uri = namespace[1]
|
197
196
|
return search.search(
|
198
197
|
"#{active_token.value}*",
|
199
198
|
:namespace_concept,
|
200
|
-
|
199
|
+
namespace.uri.to_s,
|
201
200
|
nil,
|
202
201
|
:start => 0,
|
203
|
-
:size => 10
|
202
|
+
:size => 10,
|
203
|
+
:exclude_identifier_schemes => false
|
204
204
|
).
|
205
205
|
map { |search_result|
|
206
206
|
map_namespace_value(search_result.pref_label)
|
@@ -214,10 +214,12 @@ module BEL
|
|
214
214
|
nil,
|
215
215
|
nil,
|
216
216
|
:start => 0,
|
217
|
-
:size => 10
|
217
|
+
:size => 10,
|
218
|
+
:exclude_identifier_schemes => true
|
218
219
|
).
|
219
220
|
map { |search_result|
|
220
|
-
|
221
|
+
ns = namespaces.find(search_result.scheme_uri).first
|
222
|
+
map_namespace_value_with_prefix(ns, search_result.pref_label)
|
221
223
|
}.to_a
|
222
224
|
end
|
223
225
|
end
|
@@ -236,6 +238,24 @@ module BEL
|
|
236
238
|
:offset => 0
|
237
239
|
}
|
238
240
|
end
|
241
|
+
|
242
|
+
def map_namespace_value_with_prefix(ns, ns_value)
|
243
|
+
quoted_value = ensure_quotes(ns_value)
|
244
|
+
|
245
|
+
if ns
|
246
|
+
ns_prefix = ns.prefix.to_s.upcase
|
247
|
+
ns_value = "#{ns_prefix}:#{ns_value}"
|
248
|
+
quoted_value = "#{ns_prefix}:#{quoted_value}"
|
249
|
+
end
|
250
|
+
|
251
|
+
{
|
252
|
+
:id => ns_value,
|
253
|
+
:type => :namespace_value,
|
254
|
+
:label => ns_value,
|
255
|
+
:value => quoted_value,
|
256
|
+
:offset => 0
|
257
|
+
}
|
258
|
+
end
|
239
259
|
end
|
240
260
|
end
|
241
261
|
end
|
data/lib/bel/resource.rb
CHANGED
@@ -55,14 +55,14 @@ module BEL
|
|
55
55
|
# nil input always yield nil
|
56
56
|
return nil if value == nil
|
57
57
|
|
58
|
-
# RDF::URI input handled as a special case
|
59
|
-
return find_namespace_value_uri(value) if value.is_a?(RDF::URI)
|
60
|
-
|
61
58
|
# input handled as literal identifier; empty literals match in a
|
62
59
|
# pattern as if it was nil so return nil if empty string
|
63
60
|
vstr = value.to_s
|
64
61
|
return nil if vstr.empty?
|
65
62
|
|
63
|
+
# URI handled by regex match on string
|
64
|
+
return find_namespace_value_uri(vstr) if vstr =~ FULL_URI_REGEX
|
65
|
+
|
66
66
|
# match input as namespace value prefLabel
|
67
67
|
vlit = RDF::Literal(vstr)
|
68
68
|
label = value_query(
|
@@ -86,15 +86,16 @@ module BEL
|
|
86
86
|
return NamespaceValue.new(@rdf_repository, title.subject) if title
|
87
87
|
end
|
88
88
|
|
89
|
-
def find_namespace_value_uri(
|
89
|
+
def find_namespace_value_uri(uri_s)
|
90
|
+
subject = RDF::URI(uri_s)
|
90
91
|
in_namespace_check = @rdf_repository.has_statement?(
|
91
|
-
RDF::Statement(
|
92
|
+
RDF::Statement(subject, RDF::SKOS.inScheme, @uri)
|
92
93
|
)
|
93
94
|
return nil if !in_namespace_check
|
94
95
|
|
95
|
-
type_check = RDF::Statement(
|
96
|
+
type_check = RDF::Statement(subject, RDF.type, BELV.NamespaceConcept)
|
96
97
|
if @rdf_repository.has_statement?(type_check)
|
97
|
-
return NamespaceValue.new(@rdf_repository,
|
98
|
+
return NamespaceValue.new(@rdf_repository, subject)
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
@@ -40,14 +40,14 @@ module BEL
|
|
40
40
|
# nil input always yield nil
|
41
41
|
return nil if namespace == nil
|
42
42
|
|
43
|
-
#
|
44
|
-
return
|
45
|
-
|
46
|
-
# input handled as literal identifier; empty literals will match
|
47
|
-
# in a pattern as if it was nil so return nil if empty string
|
48
|
-
nstr = namespace.to_s
|
43
|
+
# empty literals will match in a pattern as if it was nil
|
44
|
+
# so return nil if empty string
|
45
|
+
nstr = namespace.to_s
|
49
46
|
return nil if nstr.empty?
|
50
47
|
|
48
|
+
# URI handled by regex match on string
|
49
|
+
return find_namespace_uri(nstr) if nstr =~ FULL_URI_REGEX
|
50
|
+
|
51
51
|
# match input as namespace prefix
|
52
52
|
nlit = RDF::Literal(nstr)
|
53
53
|
prefix = namespace_query(
|
@@ -64,10 +64,11 @@ module BEL
|
|
64
64
|
return Namespace.new(@rdf_repository, label.subject) if label
|
65
65
|
end
|
66
66
|
|
67
|
-
def find_namespace_uri(
|
68
|
-
|
67
|
+
def find_namespace_uri(uri_s)
|
68
|
+
subject = RDF::URI(uri_s)
|
69
|
+
type_check = RDF::Statement(subject, RDF.type, BELV.NamespaceConceptScheme)
|
69
70
|
if @rdf_repository.has_statement?(type_check)
|
70
|
-
return Namespace.new(@rdf_repository,
|
71
|
+
return Namespace.new(@rdf_repository, subject)
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
data/lib/bel/version.rb
CHANGED
metadata
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Bargnesi
|
8
8
|
- Natalie Catlett
|
9
9
|
- Nick Bargnesi
|
10
10
|
- William Hayes
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-12-
|
14
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name: ffi
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
18
|
requirements:
|
20
19
|
- - '='
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: 1.9.8
|
23
|
-
|
22
|
+
name: ffi
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.9.8
|
30
|
-
description: " The BEL gem allows the reading, writing, and processing of BEL (Biological
|
31
|
-
Expression Language) with a natural DSL. "
|
30
|
+
description: " The BEL gem allows the reading, writing, and processing of BEL (Biological\
|
31
|
+
\ Expression Language) with a natural DSL. "
|
32
32
|
email:
|
33
33
|
- abargnesi@selventa.com
|
34
34
|
- ncatlett@selventa.com
|
@@ -167,7 +167,7 @@ homepage: https://github.com/OpenBEL/bel.rb
|
|
167
167
|
licenses:
|
168
168
|
- Apache-2.0
|
169
169
|
metadata: {}
|
170
|
-
post_install_message:
|
170
|
+
post_install_message:
|
171
171
|
rdoc_options:
|
172
172
|
- "--title"
|
173
173
|
- BEL Ruby Documentation
|
@@ -201,10 +201,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
|
-
rubyforge_project:
|
205
|
-
rubygems_version: 2.4.
|
206
|
-
signing_key:
|
204
|
+
rubyforge_project:
|
205
|
+
rubygems_version: 2.4.8
|
206
|
+
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Process BEL with ruby.
|
209
209
|
test_files: []
|
210
|
-
has_rdoc:
|
210
|
+
has_rdoc:
|