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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c3b7bafdeffced99541f8cbefc206ad65b70f9
4
- data.tar.gz: 2dc63bb3d6b163500ae5e06f2acbc5db546ca54b
3
+ metadata.gz: 1b8255ab8d0f64149d63bba68dfc581972af8ff5
4
+ data.tar.gz: 71e13753d0f09de8f3a09d5b1a069400859e3ca4
5
5
  SHA512:
6
- metadata.gz: 75ce820f1e0ea4085f6c022f7540e9f98eb04e2b4a8ca74c4c8b5a2494119e968e12b32e6516e4c5c3120980549221ee98467064ced29354d23a5a73951bf287
7
- data.tar.gz: f45f37895b128b2df0c43748268d34e477c40e1b0fcdc9eb7814b312fd6c2dd12ab19fa3b8bd19d7d60ad56ffe5773e7f966d489a07c99f29bd3c2a85f9a1453
6
+ metadata.gz: 9c516ed72a14dcb7f4f7f30d880a938e5c2712cdb651eb71c85c2f70e1f2927e62541c19c564ae22a96e639d95a4e9adb01b45a6b8f55d2604c87251d5260ed3
7
+ data.tar.gz: 459e40f9843c66830eae53bc499534221a0bcd4785cf85211bed21a836e5ba722f3ba1fe8b7d27754f852b44bf68d17c776971f15a0f43127472e1242c9aac25
@@ -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
@@ -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
- # If +search+ is +nil+ then namespace values will not be provided as
16
- # completion. +search+ is expected to provide +#search+ and
17
- # +#search_namespace+ methods.
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 = nil, position = nil)
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(tokens, active_index, active_token, options)
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
@@ -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 = options.delete(:search)
186
- return EMPTY_MATCH if not search or token_list.empty?
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 = BEL::Namespace::NAMESPACE_LATEST[prefix_token.value.to_sym]
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
- URI(scheme_uri),
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
- map_namespace_value(search_result.pref_label)
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
@@ -15,6 +15,8 @@ module BEL
15
15
  property :inScheme
16
16
  property :orthologousMatch
17
17
  end
18
+
19
+ FULL_URI_REGEX = /\A#{URI::regexp}\z/
18
20
  end
19
21
  end
20
22
 
@@ -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(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(uri, RDF::SKOS.inScheme, @uri)
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(uri, RDF.type, BELV.NamespaceConcept)
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, uri)
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
- # RDF::URI input handled as a special case
44
- return find_namespace_uri(namespace) if namespace.is_a?(RDF::URI)
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(uri)
68
- type_check = RDF::Statement(uri, RDF.type, BELV.NamespaceConceptScheme)
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, uri)
71
+ return Namespace.new(@rdf_repository, subject)
71
72
  end
72
73
  end
73
74
 
@@ -1,3 +1,3 @@
1
1
  module BEL
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
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.0
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 00:00:00.000000000 Z
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
- type: :runtime
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.5.1
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: