livetext 0.9.62 → 0.9.64
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/livetext/expansion.rb +2 -0
- data/lib/livetext/functions.rb +5 -0
- data/lib/livetext/version.rb +1 -1
- data/test/snapshots/simple_func_api/match-output.txt +1 -1
- data/test/snapshots/system_info/match-output.txt +1 -1
- data/test/unit/function_api_access.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 668ebd888cc8329fa00934cb05b47ed599c2f22910e4c2691350c9d5e05e20f0
|
4
|
+
data.tar.gz: 39c26ca4ac7eea09f1fecc984a1f4c14575c49cc265a7ebb07d9842cc951be7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d15b35fe3fe416bfa699349ec4e998c951e58db1e4ecf98ad9046e44e80fa8cec7c403543de8aaf578e881e48827d1934769d085b8adc706fed6f6fcc46cbd17
|
7
|
+
data.tar.gz: 47912d143d7f83e63a36a2a087b82840b2b5742ea2ef747dd325e993a89d6eeab136c085f88f047c7854d4b7b407ccabee24e80afc290d417747d5360da180c4
|
data/lib/livetext/expansion.rb
CHANGED
@@ -59,6 +59,8 @@ class Livetext::Expansion
|
|
59
59
|
if result.start_with?("[Error evaluating $$#{name}(")
|
60
60
|
# Try old Livetext::Functions system
|
61
61
|
fobj = ::Livetext::Functions.new
|
62
|
+
# Set api on Livetext::Functions so functions can access it
|
63
|
+
Livetext::Functions.api = @live.api
|
62
64
|
old_result = fobj.send(name, param) rescue nil
|
63
65
|
return old_result.to_s if old_result
|
64
66
|
|
data/lib/livetext/functions.rb
CHANGED
@@ -20,6 +20,11 @@ class Livetext::Functions
|
|
20
20
|
@vars = nil
|
21
21
|
end
|
22
22
|
|
23
|
+
# Simple method to access the class variable
|
24
|
+
def api
|
25
|
+
self.class.api
|
26
|
+
end
|
27
|
+
|
23
28
|
# Helper method to access variables with fallback to global Livetext::Vars
|
24
29
|
def get_var(name)
|
25
30
|
return @vars.get(name) if @vars
|
data/lib/livetext/version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
4 /<p>Directory: .*livetext.*</p>/
|
5
5
|
5 <p>Platform: universal.x86_64-darwin22</p>
|
6
6
|
6 <p>Ruby version: 2.6.10</p>
|
7
|
-
7
|
7
|
+
7 /<p>Livetext version: \d+\.\d+\.\d+<\/p>/
|
8
8
|
8 <p>Reverse of 'hello': olleh</p>
|
9
9
|
9 <p>Square root of 16: 4</p>
|
10
10
|
10 /<p>Random \(1-10\): \d+</p>/
|
@@ -31,8 +31,8 @@ class TestFunctionAPIAccess < Minitest::Test
|
|
31
31
|
Livetext::Functions.class_eval do
|
32
32
|
def test_asset_function(param)
|
33
33
|
# This mimics the asset function from Scriptorium that needs api.vars
|
34
|
-
vname =
|
35
|
-
postid =
|
34
|
+
vname = api.vars.to_h[:View]
|
35
|
+
postid = api.vars.to_h[:"post.id"]
|
36
36
|
"view=#{vname}, post=#{postid}, file=#{param}"
|
37
37
|
end
|
38
38
|
end
|
@@ -47,8 +47,8 @@ class TestFunctionAPIAccess < Minitest::Test
|
|
47
47
|
# Define a function that needs access to api.vars but takes no parameters
|
48
48
|
Livetext::Functions.class_eval do
|
49
49
|
def test_view_info
|
50
|
-
vname =
|
51
|
-
postid =
|
50
|
+
vname = api.vars.to_h[:View]
|
51
|
+
postid = api.vars.to_h[:"post.id"]
|
52
52
|
"view=#{vname}, post=#{postid}"
|
53
53
|
end
|
54
54
|
end
|