template-ruby 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/code/object.rb +2 -2
- data/lib/template/version.rb +1 -1
- data/spec/code/code_spec.rb +18 -0
- 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: 85a62b57a542b3efd227470d49473db796da2b091f9c827a637d1b877196dfc0
|
4
|
+
data.tar.gz: 3bebdecdd1017fb28756407d7c759739a92c7367d2da1c0184b2c992412b065f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6accd36def6ee891d77c5bc70e61aba6d945250fe26ecd004992a9eb9d8ddcb5eade880417436e8d088203366aa92757d1a2f6d76cffa6f39c9b906ac6da276
|
7
|
+
data.tar.gz: 28ed842cf8c9cbfbe624b2f4bfadaa256cbf3472210949d023a7e915a73e1ace1447d67d1c117ef403b94f5c0d76b24569105dc27753ac4777c79ed40d7a863a
|
data/Gemfile.lock
CHANGED
data/lib/code/object.rb
CHANGED
@@ -92,11 +92,11 @@ class Code
|
|
92
92
|
|
93
93
|
def deep_dup(object)
|
94
94
|
if object.is_a?(Array)
|
95
|
-
object.map { |element| deep_dup(
|
95
|
+
object.map { |element| deep_dup(element) }
|
96
96
|
elsif object.is_a?(Hash)
|
97
97
|
object.map { |key, value| [deep_dup(key), deep_dup(value)] }.to_h
|
98
98
|
elsif object.is_a?(::Code::Object::List)
|
99
|
-
::Code::Object::List.new(object.raw.map { |element| deep_dup(
|
99
|
+
::Code::Object::List.new(object.raw.map { |element| deep_dup(element) })
|
100
100
|
elsif object.is_a?(::Code::Object::Dictionnary)
|
101
101
|
::Code::Object::Dictionnary.new(
|
102
102
|
object.raw.map { |key, value| [deep_dup(key), deep_dup(value)] }.to_h
|
data/lib/template/version.rb
CHANGED
data/spec/code/code_spec.rb
CHANGED
@@ -8,4 +8,22 @@ RSpec.describe "function" do
|
|
8
8
|
it "works with downcase" do
|
9
9
|
expect(Code.evaluate("downcase", "{ downcase: 1 }")).to eq(1)
|
10
10
|
end
|
11
|
+
|
12
|
+
it "works with nested objects" do
|
13
|
+
expect(
|
14
|
+
Code.evaluate(
|
15
|
+
"items.first.title",
|
16
|
+
ruby: { items: [{ title: "Hello" }] }
|
17
|
+
)
|
18
|
+
).to eq("Hello")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "works with arrays" do
|
22
|
+
expect(
|
23
|
+
Code.evaluate(
|
24
|
+
"items.map { |item| item.title }",
|
25
|
+
ruby: { items: [{ title: "Hello" }] }
|
26
|
+
)
|
27
|
+
).to eq(["Hello"])
|
28
|
+
end
|
11
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: template-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|