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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/modl/parser/evaluator.rb +1 -1
- data/lib/modl/parser/modl_method.rb +18 -14
- data/lib/modl/parser/ref_processor.rb +32 -4
- data/lib/modl/parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ac4822ef0d304cf504228f0c13b138d40550eb66e93559586fc3995ba46eacc
|
4
|
+
data.tar.gz: b8116a683a54fede8adfe0b649974ec743ad817a600f4443f9c4376e9eac46d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 684d94505d18c20d4f76f148319b575137a2c43b00ba7e4fe1195a41507c027384d91218a24483301259d5fff9b14b528fbf06bcc6c18b837463f8f6926185bf
|
7
|
+
data.tar.gz: 5ab166816510f1d359471f34a538b9078874040a4f8e9d2fba2299294add9bfff4e2de64e3a813d0510df5750d32ee7f3976ababce5938822a8d37d7c39fd94d
|
data/CHANGELOG.md
CHANGED
@@ -109,31 +109,35 @@ module MODL
|
|
109
109
|
end
|
110
110
|
|
111
111
|
class StandardMethods
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
130
|
+
when 'r', 'replace'
|
131
|
+
s1, s2 = get_subst_parts(mthd)
|
128
132
|
str.sub(s1, s2)
|
129
|
-
when 't'
|
130
|
-
s1 = extract_params
|
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 + '.' +
|
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
|
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
|
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.
|
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
|
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?
|
data/lib/modl/parser/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: antlr4-runtime
|