posxml_parser 2.0.0 → 2.1.0

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: 922b6e903234fcc2824fb73f7b65fa4ae164de55
4
- data.tar.gz: 624b36e3a15e7eefe2e356a950bfbdf9d0ac3756
3
+ metadata.gz: 1832f100013a8327eb5bc2af3938f37df654e8da
4
+ data.tar.gz: f88056150a5fbd972ded5068594da963f2ae7531
5
5
  SHA512:
6
- metadata.gz: 4d10e1046ccdb6a4140a58b062be03d2aba4a1f07297ebb18c2e09f9d309dfce797ce53415ba559ea51910ec4654a15aa226b3c40907b8164e6509024746e87b
7
- data.tar.gz: 8c6d97c2022face12080345117e4af0a18bd636fcfd1c5465f0bd1ba68fc050cf975a9b16d162c9b33d9e31319523f23a60a4bf53632773901db0491f87a7e3a
6
+ metadata.gz: b22ad44960174d80ca1c7e9bd22ccf578bd69770540c7ecd738971b34e85cf9b61e61711e44b7058cd6e1f5fd5ee3a9a5cc1336ddefb21676303fb8a8c419ac5
7
+ data.tar.gz: 1667e63da3a8144d14e72665536bc8c24b7a2800573f789a6cc77dd7276afdedc9dbf40adbf39583e17701c2da2d61e38334b94e8f4e441a89cb38224090a2bf
@@ -1,5 +1,10 @@
1
1
  # Posxml Parser
2
2
 
3
+ ### 2.1.0 - 2018-02-22
4
+
5
+ - PosxmlCompiler refactoring VariableTypeError message.
6
+ - PosxmlCompiler supports parameter validation.
7
+
3
8
  ### 2.0.0 - 2018-02-21
4
9
 
5
10
  - Bug fix interface_menu function to expect “1.” And “1 “ entry numbers.
data/Rakefile CHANGED
@@ -35,6 +35,7 @@ files = [
35
35
  "lib/posxml_compiler/variable_undefined_error.rb",
36
36
  "lib/posxml_compiler/instruction_not_found_error.rb",
37
37
  "lib/posxml_compiler/variable_type_error.rb",
38
+ "lib/posxml_compiler/parameter_not_found_error.rb",
38
39
  "lib/posxml_translate/parser.rb",
39
40
  "lib/posxml_translate/pattern.rb",
40
41
  "lib/posxml_translate/base.rb",
@@ -0,0 +1,5 @@
1
+ module PosxmlCompiler
2
+ class ParameterNotFoundError < PosxmlCompilerError
3
+ end
4
+ end
5
+
@@ -33,11 +33,11 @@ module PosxmlCompiler
33
33
  when :string_or_integer # match everything is ok
34
34
  when nil # not defined yet, it's ok for now
35
35
  when :string
36
- raise PosxmlCompiler::VariableTypeError.new("Variable type #{variable_struct[:type]} mismatch, instruction #{instruction}, parameter #{parameter_name}, xsd type #{type}.")
36
+ raise PosxmlCompiler::VariableTypeError.new("Wrong argument type #{variable_struct[:type]} for instruction #{instruction}, parameter #{parameter_name} (expected #{type})")
37
37
  when :integer
38
- raise PosxmlCompiler::VariableTypeError.new("Variable type #{variable_struct[:type]} mismatch, instruction #{instruction}, parameter #{parameter_name}, xsd type #{type}.")
38
+ raise PosxmlCompiler::VariableTypeError.new("Wrong argument type #{variable_struct[:type]} for instruction #{instruction}, parameter #{parameter_name} (expected #{type})")
39
39
  else
40
- raise PosxmlCompiler::VariableTypeError.new("Variable type #{variable_struct[:type]} not recognized, instruction #{instruction}, parameter #{parameter_name}, xsd type #{type}.")
40
+ raise PosxmlCompiler::VariableTypeError.new("Wrong argument type #{variable_struct[:type]} for instruction #{instruction}, parameter #{parameter_name} (expected #{type})")
41
41
  end
42
42
 
43
43
  return true
@@ -34,7 +34,8 @@ module PosxmlCompiler
34
34
  instruction = self.find(name) # => {:bytecode => "I", :order => ["variable", "operator", "value"], :parameters => {"variable" => :string_or_integer, "operator" => :string, "value" => :string_or_integer}
35
35
  raise InstructionNotFoundError.new("Instruction #{name.inspect} not found") unless instruction
36
36
 
37
- line = instruction[:order].collect { |param| parameters[param][:value] || parameters[param][:value]}
37
+ parameters_validate(name, instruction, parameters)
38
+ line = instruction[:order].collect { |param| parameters[param][:value] }
38
39
 
39
40
  if line.empty?
40
41
  instruction[:bytecode].chr + DELIMITER_END_INSTRUCTION
@@ -47,6 +48,15 @@ module PosxmlCompiler
47
48
  self.instructions[name] # => {:bytecode => "I", :order => ["variable", "operator", "value"], :parameters => {"variable" => :string_or_integer, "operator" => :string, "value" => :string_or_integer}
48
49
  end
49
50
 
51
+ def parameters_validate(instruction_name, instruction, parameters)
52
+ parameters_valid = instruction[:parameters].keys
53
+ parameters.each do |name, data|
54
+ unless parameters_valid.include? name
55
+ raise ParameterNotFoundError.new("invalid parameter '#{name}' for instruction '#{instruction_name}'")
56
+ end
57
+ end
58
+ end
59
+
50
60
  private
51
61
  def string2byte(str)
52
62
  value = str.gsub(";", "").gsub("true", "").gsub("false", "")
@@ -1,5 +1,5 @@
1
1
 
2
2
  module PosxmlParser
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudWalk Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,6 +64,7 @@ files:
64
64
  - "./lib/posxml_compiler/instruction_not_found_error.rb"
65
65
  - "./lib/posxml_compiler/jump.rb"
66
66
  - "./lib/posxml_compiler/jump_point.rb"
67
+ - "./lib/posxml_compiler/parameter_not_found_error.rb"
67
68
  - "./lib/posxml_compiler/parser.rb"
68
69
  - "./lib/posxml_compiler/posxml_compiler_error.rb"
69
70
  - "./lib/posxml_compiler/string_size_error.rb"