bel_parser 1.0.0.alpha.35 → 1.0.0.alpha.36

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: 2146335395f5a41bb0344d6c9318fa282a992717
4
- data.tar.gz: c9d8cb3623c5bee85f8a82a70c3f5db762229a03
3
+ metadata.gz: 6187ff526a33b8ad9d816257a5142034426900a1
4
+ data.tar.gz: 2a6c8271ef21cc76b3e3813c547e57000e249c7f
5
5
  SHA512:
6
- metadata.gz: 44d14c01868f3c034077f1c6d33b58dc2f5b9a145a6cd79223e353c014045cd088c6a69bbba5ad2983296b896ca303d8d1a573dc48129dd8b3e92fe766fcf618
7
- data.tar.gz: 01440f40494138c891264c19c41ebe0c31074fe1657fde659a9f7259165fee2f66620e7b42e9eb5691b215491da51995d633ae97f6f60df121b4ff095f219af0
6
+ metadata.gz: 5e4adde29aa3c3d3474cb2ffa78bc6899b0bbde1d53d8fcbddb929a02f74109308a73d8ce400dfd723bb0c1f559d4d033b253147af009c8914fa6927106adfb3
7
+ data.tar.gz: bb72ee5e809d3018c8ed8ea2c3e7b8fddc4ae7162fe0c0899592f5de1140707d1c20f7e9b795786a7eed917e483e60f8ed1d26a0009567c487cb4ce2447c3389
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.35
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
- keyword, type, domain = ref.values_at(:keyword, :type, :domain)
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{URL "#{domain}"\n}
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
- keyword, url = ref.values_at(:keyword, :uri)
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
- attr_reader :keyword
9
- attr_reader :type
10
- attr_reader :domain
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
- # configure reader for URIs (RDF).
22
- @uri_reader = options.fetch(:uri_reader, nil)
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
- # configure reader for URLs (Resource files).
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(@uri, value)
55
+ @uri_reader.retrieve_value_from_resource(@domain, value)
41
56
  elsif url?
42
- @url_reader.retrieve_value_from_resource(@url, value)
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(@uri)
67
+ @uri_reader.retrieve_values_from_resource(@domain)
53
68
  elsif url?
54
- @url_reader.retrieve_values_from_resource(@url)
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, @uri, @url].hash
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 && @uri == other.uri && @url == other.url
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bel_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.35
4
+ version: 1.0.0.alpha.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi