bel_parser 1.0.0.alpha.14 → 1.0.0.alpha.15

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: a93a3b8baa29469eeee1329e06bbc82a886d7d59
4
- data.tar.gz: 07332e2aff2a9b3ba75e7570c13dd4b5be14d340
3
+ metadata.gz: 5a99bbde75e5c199ecf2dd8be815f1405e9eb5e4
4
+ data.tar.gz: c356ebe805e01532cfce41ac8106468cb4f5c385
5
5
  SHA512:
6
- metadata.gz: 810411e5492af6670af3ba4a1674d1bf72f1543e4bd432befecd528f466b9f35e03e321861faba4d25a9efe000c0d8b3b0ed9cd809b4df2e4d56256d742a6200
7
- data.tar.gz: 29cfd9031739f4108975fb8dd618c8051c2ad95cd46ccbdee6840d1768bb7f90d9776e687dc8f816825b7c7aa7a83bf47f9b98f8cf15907c9ac180f6ec0b99f3
6
+ metadata.gz: b2106d5573f751b638a5386111ecd43a5278bdb8dcfc2c346f2a7a92b14cee760d53e848ad1f251f7b4430722219309b1c67190e63e6ed05854ee65a6fcbbd57
7
+ data.tar.gz: 6876b054cf3ddb09c21471dd787608754fcc09aa31842228d25204464e24f7816464f67f2d02ef9b50a9f2b5d6432aaac44668c6af072e765d229213183a0d15
data/.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  'Anthony Bargnesi',
12
12
  'Nick Bargnesi',
13
13
  ]
14
- spec.date = %q{2016-04-27}
14
+ spec.date = %q{2016-04-28}
15
15
  spec.email = %q{abargnesi@selventa.com}
16
16
  spec.files = [
17
17
  Dir.glob('lib/**/*.{rb,rl}'),
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.14
1
+ 1.0.0.alpha.15
data/bin/bel2_validator CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(
4
4
 
5
5
  unless ARGV.first
6
6
  program = File.basename($PROGRAM_NAME)
7
- $stderr.puts <<-USAGE.gsub(/ {6}/, '')
7
+ $stderr.puts <<-USAGE.gsub(/ {4}/, '')
8
8
  usage: #{program} [BEL specification version] [PREFIX=URI]...
9
9
  USAGE
10
10
  exit 1
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(
3
+ File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
4
+
5
+ bel_specification_version, file = ARGV
6
+
7
+ unless bel_specification_version
8
+ program = File.basename($PROGRAM_NAME)
9
+ $stderr.puts <<-USAGE.gsub(/ {4}/, '')
10
+ usage: #{program} [BEL specification version]
11
+ USAGE
12
+ exit 1
13
+ end
14
+
15
+ io =
16
+ if file
17
+ File.open(ARGV.first, external_encoding: 'UTF-8')
18
+ else
19
+ $stdin
20
+ end
21
+
22
+ require 'bel_parser/language'
23
+ require 'bel_parser/script/validator'
24
+ require 'bel_parser/resource/resource_file_reader'
25
+
26
+ def select(list, cls)
27
+ list.select { |item| item.is_a?(cls) }
28
+ end
29
+
30
+ def report(line_number, ast, errors, warnings)
31
+ log = !errors.empty? || !warnings.empty?
32
+ if log
33
+ puts "On line #{line_number} for #{ast.type}"
34
+ puts " Errors:"
35
+ errors.each do |err|
36
+ puts " #{err}"
37
+ end
38
+ puts " Warnings:"
39
+ warnings.each do |warn|
40
+ puts " #{warn}"
41
+ end
42
+ end
43
+ end
44
+
45
+ SYN_ERR = BELParser::Language::Syntax::SyntaxError
46
+ SYN_WARN = BELParser::Language::Syntax::SyntaxWarning
47
+ SEM_WARN = BELParser::Language::Semantics::SemanticsWarning
48
+
49
+ initial_state = {
50
+ resource_reader: BELParser::Resource::ResourceFileReader.new,
51
+ specification: BELParser::Language.specification(
52
+ bel_specification_version
53
+ )
54
+ }
55
+
56
+ BELParser::Script::Validator
57
+ .new(initial_state)
58
+ .each(io) do |(line_number, line, ast, syntax_results, state)|
59
+ errors = select(syntax_results, SYN_ERR)
60
+ warnings =
61
+ select(syntax_results, SYN_WARN) +
62
+ select(syntax_results, SEM_WARN)
63
+
64
+ report(line_number, ast, errors, warnings)
65
+
66
+ unless errors.empty?
67
+ puts "Exiting due to error on line #{line_number}: #{line}"
68
+ exit 1
69
+ end
70
+ end
@@ -48,14 +48,25 @@ if __FILE__ == $PROGRAM_NAME
48
48
  USAGE
49
49
  exit 1
50
50
  end
51
- namespaces = Hash[ARGV[1..-1].map { |ns| ns.split('=') }]
51
+
52
+ require 'bel_parser/resource/resource_file_reader'
53
+
54
+ resource_reader = BELParser::Resource::ResourceFileReader.new
55
+ namespaces =
56
+ Hash[
57
+ ARGV[1..-1]
58
+ .map do |ns|
59
+ prefix, identifier = ns.split('=')
60
+ [prefix, resource_reader.retrieve_resource(identifier)]
61
+ end
62
+ ]
52
63
  BELParser::Expression::Validator
53
- .new(ARGV.first, namespaces)
54
- .each($stdin) do |(line_number, line, ast, messages)|
64
+ .new(ARGV.first, namespaces, resource_reader)
65
+ .each($stdin) do |(line_number, line, ast, results)|
55
66
  results.select { |res| res.is_a? BELParser::Language::Syntax::SyntaxError }
56
67
  puts "#{line_number}: #{line}"
57
68
  puts " AST Type: #{ast.type}"
58
- puts messages
69
+ puts results
59
70
  .map { |r| "#{r}\n" }
60
71
  .join
61
72
  .each_line
@@ -8,9 +8,9 @@ module BELParser
8
8
  include AST::Processor::Mixin
9
9
  include BELParser::Quoting
10
10
 
11
- def initialize(language_spec, identifier_hash, resource_reader)
11
+ def initialize(language_spec, namespace_hash, resource_reader)
12
12
  @language_spec = language_spec
13
- @identifier_hash = identifier_hash
13
+ @namespace_hash = namespace_hash
14
14
  @resource_reader = resource_reader
15
15
  end
16
16
 
@@ -61,10 +61,9 @@ module BELParser
61
61
  return prefix_node unless prefix_node.identifier
62
62
 
63
63
  @prefix = prefix_node.identifier.string_literal
64
- identifier = @identifier_hash[@prefix].identifier
65
- return prefix_node unless identifier
64
+ dataset = @namespace_hash[@prefix]
65
+ return prefix_node unless dataset
66
66
 
67
- dataset = @resource_reader.retrieve_resource(identifier)
68
67
  @resolved_dataset = dataset
69
68
  prefix_node.namespace = dataset
70
69
 
@@ -22,8 +22,9 @@ module BELParser
22
22
 
23
23
  function_name = term_node.function.identifier.string_literal
24
24
  function = spec.function(function_name.to_sym)
25
- mapsig = method(:map_signature).to_proc.curry[term_node][spec]
25
+ return nil unless function
26
26
 
27
+ mapsig = method(:map_signature).to_proc.curry[term_node][spec]
27
28
  function.signatures.map(&mapsig)
28
29
  end
29
30
 
@@ -717,7 +717,7 @@ module BELParser
717
717
  end
718
718
 
719
719
  def match(value_node, spec)
720
- string_literal_sym = value_node.children[0].to_sym
720
+ string_literal_sym = value_node.children[0].string_literal.to_sym
721
721
  return success(value_node, spec) if @hashed[:*]
722
722
 
723
723
  if @hashed.key?(string_literal_sym)
@@ -760,7 +760,7 @@ module BELParser
760
760
  end
761
761
 
762
762
  def match(value_node, spec)
763
- string_literal = unquote(value_node.string_literal)
763
+ string_literal = unquote(value_node.children[0].string_literal)
764
764
  integer_position =
765
765
  begin
766
766
  Integer(string_literal)
@@ -14,7 +14,7 @@ module BELParser
14
14
  SHORT = :r
15
15
  LONG = :rnaAbundance
16
16
  RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::GeneAbundance
17
- R_ENC = Version1_0::ReturnTypes::GeneAbundance
17
+ R_ENC = Version1_0::ValueEncodings::RNAAbundance
18
18
  DESCRIPTION = 'Denotes the abundance of a gene'.freeze
19
19
 
20
20
  def self.short
@@ -24,10 +24,7 @@ module BELParser
24
24
  end
25
25
 
26
26
  concepts = resources[resource_identifier]
27
- concepts.getset(value) {
28
- puts "retrieving from RDF..."
29
- super
30
- }
27
+ concepts.getset(value) { super }
31
28
  end
32
29
 
33
30
  def retrieve_values_from_resource(resource_identifier)
@@ -21,7 +21,6 @@ module BELParser
21
21
  keyword, domain = ast_node.children
22
22
  if domain.url?
23
23
  url = unquote(domain.child.string.string_literal)
24
- puts resource_reader.retrieve_resource(url)
25
24
  unless resource_reader.retrieve_resource(url)
26
25
  prefix = keyword.identifier.string_literal
27
26
  return UnresolvableNamespaceError.new(ast_node, prefix, url)
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.14
4
+ version: 1.0.0.alpha.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -9,12 +9,13 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-27 00:00:00.000000000 Z
12
+ date: 2016-04-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Implements language versions 1.0 and 2.0.
15
15
  email: abargnesi@selventa.com
16
16
  executables:
17
17
  - bel2_validator
18
+ - bel_script_reader
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
@@ -24,6 +25,7 @@ files:
24
25
  - README.md
25
26
  - VERSION
26
27
  - bin/bel2_validator
28
+ - bin/bel_script_reader
27
29
  - lib/bel_parser.rb
28
30
  - lib/bel_parser/ast_filter.rb
29
31
  - lib/bel_parser/ast_generator.rb