language-ruby 0.5.4 → 0.5.6

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: 2efe0c5926ad16a67ec4373bfe2276827c5295778b5a78c27697087dd8f32a58
4
- data.tar.gz: 2d81c4e457a8a5459fa07680bcfaa3bf7b1684b017420e4824107cdeddf8a55a
3
+ metadata.gz: 1ffefd2b6b98738fdb6cca491d3e66d49954089665ee0c549c9fbaa72c44c6de
4
+ data.tar.gz: 3bebdecdd1017fb28756407d7c759739a92c7367d2da1c0184b2c992412b065f
5
5
  SHA512:
6
- metadata.gz: cbc41426ffeccd6a83ea79a69a30b1a32d55c989e27cc523667a6453fbd4674f1cb89b152d1fb925141f828d02a0ef61578bebfe705ee42621a9ae25809041b5
7
- data.tar.gz: 50c889240055297df35cf515c1298e79d297dadef212c00121fe3c663d488d3679ec388a25869ec661982110220c188b8f3a3e172bdc1ebba1780a8852b8f396
6
+ metadata.gz: 838a0152426d4e052b4a2349dbafded5dbb38f003a1854920a99180a8b215234e2b460d40623d9c02a929ffc3b61b8d42363fa4db81eb418cc073ac26ddfb83e
7
+ data.tar.gz: 28ed842cf8c9cbfbe624b2f4bfadaa256cbf3472210949d023a7e915a73e1ace1447d67d1c117ef403b94f5c0d76b24569105dc27753ac4777c79ed40d7a863a
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.3
data/Gemfile.lock CHANGED
@@ -8,9 +8,9 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- code-ruby (0.4.0)
11
+ code-ruby (0.5.6)
12
12
  zeitwerk (~> 2)
13
- template-ruby (0.4.0)
13
+ template-ruby (0.5.6)
14
14
  zeitwerk (~> 2)
15
15
 
16
16
  GEM
@@ -36,6 +36,7 @@ GEM
36
36
 
37
37
  PLATFORMS
38
38
  arm64-darwin-21
39
+ arm64-darwin-22
39
40
 
40
41
  DEPENDENCIES
41
42
  code-ruby!
@@ -25,6 +25,9 @@ class Code
25
25
  elsif operator == "reverse"
26
26
  sig(arguments)
27
27
  reverse
28
+ elsif operator == "downcase"
29
+ sig(arguments)
30
+ downcase
28
31
  elsif operator == "include?"
29
32
  sig(arguments) { ::Code::Object::String }
30
33
  include?(value)
@@ -87,6 +90,10 @@ class Code
87
90
  ::Code::Object::String.new(raw.reverse)
88
91
  end
89
92
 
93
+ def downcase
94
+ ::Code::Object::String.new(raw.downcase)
95
+ end
96
+
90
97
  def include?(value)
91
98
  ::Code::Object::Boolean.new(raw.include?(value.raw))
92
99
  end
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(o) }
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(o) })
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
@@ -92,9 +92,15 @@ class Code
92
92
  special_character.absent << any
93
93
  end
94
94
 
95
+ def separator
96
+ special_character
97
+ end
98
+
95
99
  def root
96
- do_keyword.absent << end_keyword.absent << elsif_keyword.absent <<
97
- else_keyword.absent << character.repeat(1)
100
+ (do_keyword << separator).absent <<
101
+ (else_keyword << separator).absent <<
102
+ (elsif_keyword << separator).absent <<
103
+ (end_keyword << separator).absent << character.repeat(1)
98
104
  end
99
105
  end
100
106
  end
@@ -1,3 +1,3 @@
1
1
  require_relative "../template"
2
2
 
3
- Template::Version = Gem::Version.new("0.5.4")
3
+ Template::Version = Gem::Version.new("0.5.6")
@@ -4,4 +4,26 @@ RSpec.describe "function" do
4
4
  it "converts nil" do
5
5
  expect(Code::Ruby.from_code(Code.evaluate("a", ruby: { a: nil }))).to eq(nil)
6
6
  end
7
+
8
+ it "works with downcase" do
9
+ expect(Code.evaluate("downcase", "{ downcase: 1 }")).to eq(1)
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
7
29
  end
@@ -16,7 +16,8 @@ RSpec.describe "string" do
16
16
  ['"Hello \\{name}"', "Hello {name}"],
17
17
  ["'Hello {1}'", "Hello 1"],
18
18
  ['"Hello {1}"', "Hello 1"],
19
- ['"Hello".include?("H")', "true"]
19
+ ['"Hello".include?("H")', "true"],
20
+ ['"Hello".downcase', "hello"]
20
21
  ].each do |input, output|
21
22
  context input do
22
23
  let(:input) { input }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
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-09 00:00:00.000000000 Z
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -36,6 +36,7 @@ files:
36
36
  - ".gitignore"
37
37
  - ".prettierrc"
38
38
  - ".rspec"
39
+ - ".tool-versions"
39
40
  - CHANGELOG.md
40
41
  - Gemfile
41
42
  - Gemfile.lock