modl 0.3.8 → 0.3.9

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
  SHA256:
3
- metadata.gz: e50e0895120efc15886ab14e88925610d92c41a683f98faa56cbb95ab90bd77d
4
- data.tar.gz: da66a46c8837e2dc27ce6218df30ffdf9f47a5778d4a14a451ebfc286dc75fc1
3
+ metadata.gz: 4ac4822ef0d304cf504228f0c13b138d40550eb66e93559586fc3995ba46eacc
4
+ data.tar.gz: b8116a683a54fede8adfe0b649974ec743ad817a600f4443f9c4376e9eac46d5
5
5
  SHA512:
6
- metadata.gz: fdafe65158efb8cda5280997ca0ba6be9142c24b3249d596a5b12c59d298d78b7e3424101112e11720cbad2d65b4a2138042f47e9a907e4f8126bbc760e4ff02
7
- data.tar.gz: 33170d670ca8aa92d1dd828323eec2484a7f42e13513d700d7b2b7143f45a78c5c1d32cafed2476cd315126909bfc0c97c2075aad4d328d304f216c2aad41b72
6
+ metadata.gz: 684d94505d18c20d4f76f148319b575137a2c43b00ba7e4fe1195a41507c027384d91218a24483301259d5fff9b14b528fbf06bcc6c18b837463f8f6926185bf
7
+ data.tar.gz: 5ab166816510f1d359471f34a538b9078874040a4f8e9d2fba2299294add9bfff4e2de64e3a813d0510df5750d32ee7f3976ababce5938822a8d37d7c39fd94d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.9
2
+ ===
3
+ - Fix GitHub Issue #18 - Quoted strings not handled correctly in references
4
+
1
5
  0.3.8
2
6
  ===
3
7
  - Add MIT license to all non-auto-generated Ruby files.
@@ -63,7 +63,7 @@ module MODL
63
63
  when '='
64
64
  wild = value2.is_a?(String) && value2.include?('*') ? true : false
65
65
  if wild
66
- regex = '^'
66
+ regex = '^'.dup
67
67
  value2.each_char do |c|
68
68
  regex << (c == '*' ? '.*' : c)
69
69
  end
@@ -109,31 +109,35 @@ module MODL
109
109
  end
110
110
 
111
111
  class StandardMethods
112
- def self.run_method(m, str)
113
- case m[0]
114
- when 'u'
112
+
113
+ @@mthd_names = %w(u d i s e r t p upcase downcase initcap sentence urlencode replace trim punydecode)
114
+
115
+ def self.run_method(mthd, str)
116
+ m = mthd.match(/\w*/)[0]
117
+ case m
118
+ when 'u', 'upcase'
115
119
  str.upcase
116
- when 'd'
120
+ when 'd', 'downcase'
117
121
  str.downcase
118
- when 'i'
122
+ when 'i', 'initcap'
119
123
  str.split.map(&:capitalize) * ' '
120
- when 's'
124
+ when 's', 'sentence'
121
125
  split = str.split
122
126
  split[0].capitalize!
123
127
  split.join(' ')
124
- when 'e'
128
+ when 'e', 'urlencode'
125
129
  CGI.escape(str)
126
- when 'r'
127
- s1, s2 = get_subst_parts m
130
+ when 'r', 'replace'
131
+ s1, s2 = get_subst_parts(mthd)
128
132
  str.sub(s1, s2)
129
- when 't'
130
- s1 = extract_params m
133
+ when 't', 'trim'
134
+ s1 = extract_params mthd
131
135
  i = str.index(s1)
132
136
  Sutil.head(str, i)
133
- when 'p'
137
+ when 'p', 'punydecode'
134
138
  Punycode.decode(str)
135
139
  else
136
- str + '.' + m
140
+ str.nil? ? '.' + mthd : str.to_s + '.' + mthd
137
141
  end
138
142
  end
139
143
 
@@ -153,7 +157,7 @@ module MODL
153
157
  end
154
158
 
155
159
  def self.valid_method?(mthd)
156
- return 'udisertp'.include?(mthd)
160
+ return @@mthd_names.include?(mthd)
157
161
  end
158
162
  end
159
163
  end
@@ -137,20 +137,48 @@ module MODL
137
137
  result = if n.to_s == p
138
138
  # Numeric ref
139
139
  if !result.nil? && !result.respond_to?(:find_property)
140
- raise InterpreterError, 'Interpreter Error: Invalid obejct reference: ' + degraved
140
+ raise InterpreterError, 'Interpreter Error: Invalid object reference: ' + degraved
141
141
  end
142
142
  result.nil? ? global.index_value(n, degraved) : result.find_property(n)
143
143
  else
144
144
  # String ref
145
145
  if result.is_a? String
146
- StandardMethods.run_method(p, result)
146
+ if StandardMethods.valid_method?(p)
147
+ StandardMethods.run_method(p, result)
148
+ else
149
+ mthd = global.user_method(p)
150
+ if !mthd.nil?
151
+ mthd.run(result)
152
+ else
153
+ mthd
154
+ end
155
+ end
156
+ elsif result.is_a? Parsed::ParsedPair
157
+ if result.text
158
+ if StandardMethods.valid_method?(p)
159
+ StandardMethods.run_method(p, result.text)
160
+ else
161
+ mthd = global.user_method(p)
162
+ if !mthd.nil?
163
+ mthd.run(result.text)
164
+ else
165
+ mthd
166
+ end
167
+ end
168
+ else
169
+ result.find_property(p)
170
+ end
147
171
  elsif result.is_a? Array
148
172
  nil
149
173
  else
150
174
  if !result.nil? && !result.respond_to?(:find_property)
151
- raise InterpreterError, 'Interpreter Error: Invalid obejct reference: ' + degraved
175
+ raise InterpreterError, 'Interpreter Error: Invalid object reference: ' + degraved
176
+ end
177
+ if result.nil?
178
+ global.pair(p)
179
+ else
180
+ result.find_property(p)
152
181
  end
153
- result.nil? ? global.pair(p) : result.find_property(p)
154
182
  end
155
183
  end
156
184
  break if result.nil?
@@ -24,6 +24,6 @@
24
24
 
25
25
  module MODL
26
26
  module Parser
27
- VERSION = "0.3.8"
27
+ VERSION = "0.3.9"
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Walmsley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-25 00:00:00.000000000 Z
11
+ date: 2019-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: antlr4-runtime