tina4ruby 3.10.30 → 3.10.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tina4/frond.rb +23 -16
- data/lib/tina4/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f58284436d1c4f21bf16c723f02d174c6b4090395eb59a8357387b776cdb3c07
|
|
4
|
+
data.tar.gz: e19f24eac4a4010d9377a74f7e5da9ab437c062b3c4773f1a0932995b661e298
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9191ea613953492469a000a221cc0c18f819eb48493c6a3128b04f5ef1e85d99ab08c29fe38ebbdb3b1fdfc85db1eaa648c6d327888d0f57ad19af7a14f4155d
|
|
7
|
+
data.tar.gz: 7d431e996a22db4a25879f148e891ceaeb6a7b8e186e2e5c9ccecb631234122c8a463b35f4bf4c963435973dc1b6c58dd819053ae2966917742c2baa0860a45d
|
data/lib/tina4/frond.rb
CHANGED
|
@@ -45,7 +45,7 @@ module Tina4
|
|
|
45
45
|
HASH_LIT_RE = /\A\{(.+)\}\z/m
|
|
46
46
|
HASH_PAIR_RE = /\A\s*["']?(\w+)["']?\s*:\s*(.+)\z/
|
|
47
47
|
RANGE_LIT_RE = /\A(\d+)\.\.(\d+)\z/
|
|
48
|
-
|
|
48
|
+
ARITHMETIC_OPS = [" + ", " - ", " * ", " // ", " / ", " % ", " ** "].freeze
|
|
49
49
|
FUNC_CALL_RE = /\A(\w+)\s*\((.*)\)\z/m
|
|
50
50
|
FILTER_WITH_ARGS_RE = /\A(\w+)\s*\((.*)\)\z/m
|
|
51
51
|
FILTER_CMP_RE = /\A(\w+)\s*(!=|==|>=|<=|>|<)\s*(.+)\z/
|
|
@@ -933,12 +933,15 @@ module Tina4
|
|
|
933
933
|
return eval_comparison(expr, context)
|
|
934
934
|
end
|
|
935
935
|
|
|
936
|
-
# Arithmetic: +, -, *, /,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
936
|
+
# Arithmetic: +, -, *, //, /, %, ** (lowest to highest precedence)
|
|
937
|
+
ARITHMETIC_OPS.each do |op|
|
|
938
|
+
pos = find_outside_quotes(expr, op)
|
|
939
|
+
next unless pos && pos >= 0
|
|
940
|
+
left_s = expr[0...pos].strip
|
|
941
|
+
right_s = expr[(pos + op.length)..].strip
|
|
942
|
+
l_val = eval_expr(left_s, context)
|
|
943
|
+
r_val = eval_expr(right_s, context)
|
|
944
|
+
return apply_math(l_val, op.strip, r_val)
|
|
942
945
|
end
|
|
943
946
|
|
|
944
947
|
# Function call: name(arg1, arg2)
|
|
@@ -1144,17 +1147,21 @@ module Tina4
|
|
|
1144
1147
|
# -----------------------------------------------------------------------
|
|
1145
1148
|
|
|
1146
1149
|
def apply_math(left, op, right)
|
|
1147
|
-
l = left.to_f
|
|
1148
|
-
r = right.to_f
|
|
1150
|
+
l = (left || 0).to_f
|
|
1151
|
+
r = (right || 0).to_f
|
|
1152
|
+
# Preserve int type when both operands are int-like (except for / which returns float)
|
|
1153
|
+
both_int = l == l.to_i && r == r.to_i && op != "/"
|
|
1149
1154
|
result = case op
|
|
1150
|
-
when "+"
|
|
1151
|
-
when "-"
|
|
1152
|
-
when "*"
|
|
1153
|
-
when "/"
|
|
1154
|
-
when "
|
|
1155
|
+
when "+" then l + r
|
|
1156
|
+
when "-" then l - r
|
|
1157
|
+
when "*" then l * r
|
|
1158
|
+
when "/" then r != 0 ? l / r : 0
|
|
1159
|
+
when "//" then r != 0 ? (l / r).floor : 0
|
|
1160
|
+
when "%" then r != 0 ? l % r : 0
|
|
1161
|
+
when "**" then l ** r
|
|
1155
1162
|
else 0
|
|
1156
1163
|
end
|
|
1157
|
-
result == result.to_i ? result.to_i : result
|
|
1164
|
+
both_int && result == result.to_i ? result.to_i : result.to_f == result.to_i ? result.to_i : result
|
|
1158
1165
|
end
|
|
1159
1166
|
|
|
1160
1167
|
# -----------------------------------------------------------------------
|
|
@@ -1354,7 +1361,7 @@ module Tina4
|
|
|
1354
1361
|
if content =~ SET_RE
|
|
1355
1362
|
name = Regexp.last_match(1)
|
|
1356
1363
|
expr = Regexp.last_match(2).strip
|
|
1357
|
-
context[name] =
|
|
1364
|
+
context[name] = eval_var_raw(expr, context)
|
|
1358
1365
|
end
|
|
1359
1366
|
end
|
|
1360
1367
|
|
data/lib/tina4/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tina4ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.10.
|
|
4
|
+
version: 3.10.31
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tina4 Team
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rack
|
|
@@ -400,7 +399,6 @@ licenses:
|
|
|
400
399
|
- MIT
|
|
401
400
|
metadata:
|
|
402
401
|
homepage_uri: https://tina4.com
|
|
403
|
-
post_install_message:
|
|
404
402
|
rdoc_options: []
|
|
405
403
|
require_paths:
|
|
406
404
|
- lib
|
|
@@ -415,8 +413,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
415
413
|
- !ruby/object:Gem::Version
|
|
416
414
|
version: '0'
|
|
417
415
|
requirements: []
|
|
418
|
-
rubygems_version:
|
|
419
|
-
signing_key:
|
|
416
|
+
rubygems_version: 4.0.3
|
|
420
417
|
specification_version: 4
|
|
421
418
|
summary: Simple. Fast. Human. This is not a framework.
|
|
422
419
|
test_files: []
|