template-ruby 0.5.3 → 0.5.5
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/.tool-versions +1 -0
- data/Gemfile.lock +3 -2
- data/lib/code/object/string.rb +7 -0
- data/lib/code/parser/name.rb +8 -2
- data/lib/code/ruby.rb +13 -1
- data/lib/template/version.rb +1 -1
- data/spec/code/code_spec.rb +11 -0
- data/spec/code/string_spec.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b950102aa3704abeb5a08e1cb6168fb7b5dcd3ec6abdcaba8583bde498f4fd7
|
|
4
|
+
data.tar.gz: d95cdb157fb3da9c59b18fc4f84808fe2368390a132e2be8b9e2bc6a20758503
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e6e656e902c31050f1bcc8070c3ca064100cfe2445f8904bba7aeb90f986c8ba29d533204e7d943160c59457aa299da3db9f5589b13f84dad43b54776feb848
|
|
7
|
+
data.tar.gz: 63bce33e3bbe8db8baf4ea842467f98aafc0470277d15665253cca727d29fcfc1e00b79f4f00b35c734937b15dbb17dbc0144b80ae526dbc5075d1b019249047
|
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
|
|
11
|
+
code-ruby (0.5.4)
|
|
12
12
|
zeitwerk (~> 2)
|
|
13
|
-
template-ruby (0.4
|
|
13
|
+
template-ruby (0.5.4)
|
|
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!
|
data/lib/code/object/string.rb
CHANGED
|
@@ -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/parser/name.rb
CHANGED
|
@@ -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
|
|
97
|
-
else_keyword.absent <<
|
|
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
|
data/lib/code/ruby.rb
CHANGED
|
@@ -15,6 +15,8 @@ class Code
|
|
|
15
15
|
def to_code
|
|
16
16
|
if code?
|
|
17
17
|
raw
|
|
18
|
+
elsif nil?
|
|
19
|
+
::Code::Object::Nothing.new
|
|
18
20
|
elsif true?
|
|
19
21
|
::Code::Object::Boolean.new(raw)
|
|
20
22
|
elsif false?
|
|
@@ -50,7 +52,9 @@ class Code
|
|
|
50
52
|
|
|
51
53
|
def from_code
|
|
52
54
|
if code?
|
|
53
|
-
if
|
|
55
|
+
if code_nothing?
|
|
56
|
+
raw.raw
|
|
57
|
+
elsif code_boolean?
|
|
54
58
|
raw.raw
|
|
55
59
|
elsif code_decimal?
|
|
56
60
|
raw.raw
|
|
@@ -87,6 +91,10 @@ class Code
|
|
|
87
91
|
raw.is_a?(::Code::Object)
|
|
88
92
|
end
|
|
89
93
|
|
|
94
|
+
def nil?
|
|
95
|
+
raw.is_a?(::NilClass)
|
|
96
|
+
end
|
|
97
|
+
|
|
90
98
|
def true?
|
|
91
99
|
raw.is_a?(::TrueClass)
|
|
92
100
|
end
|
|
@@ -127,6 +135,10 @@ class Code
|
|
|
127
135
|
raw.is_a?(::Proc)
|
|
128
136
|
end
|
|
129
137
|
|
|
138
|
+
def code_nothing?
|
|
139
|
+
raw.is_a?(::Code::Object::Nothing)
|
|
140
|
+
end
|
|
141
|
+
|
|
130
142
|
def code_boolean?
|
|
131
143
|
raw.is_a?(::Code::Object::Boolean)
|
|
132
144
|
end
|
data/lib/template/version.rb
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe "function" do
|
|
4
|
+
it "converts nil" do
|
|
5
|
+
expect(Code::Ruby.from_code(Code.evaluate("a", ruby: { a: nil }))).to eq(nil)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "works with downcase" do
|
|
9
|
+
expect(Code.evaluate("downcase", "{ downcase: 1 }")).to eq(1)
|
|
10
|
+
end
|
|
11
|
+
end
|
data/spec/code/string_spec.rb
CHANGED
|
@@ -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: template-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.5
|
|
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-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: zeitwerk
|
|
@@ -38,6 +38,7 @@ files:
|
|
|
38
38
|
- ".gitignore"
|
|
39
39
|
- ".prettierrc"
|
|
40
40
|
- ".rspec"
|
|
41
|
+
- ".tool-versions"
|
|
41
42
|
- CHANGELOG.md
|
|
42
43
|
- Gemfile
|
|
43
44
|
- Gemfile.lock
|
|
@@ -182,6 +183,7 @@ files:
|
|
|
182
183
|
- spec/code/boolean_spec.rb
|
|
183
184
|
- spec/code/call_spec.rb
|
|
184
185
|
- spec/code/chained_call_spec.rb
|
|
186
|
+
- spec/code/code_spec.rb
|
|
185
187
|
- spec/code/dictionnary_spec.rb
|
|
186
188
|
- spec/code/equal_spec.rb
|
|
187
189
|
- spec/code/equality_spec.rb
|
|
@@ -250,6 +252,7 @@ test_files:
|
|
|
250
252
|
- spec/code/boolean_spec.rb
|
|
251
253
|
- spec/code/call_spec.rb
|
|
252
254
|
- spec/code/chained_call_spec.rb
|
|
255
|
+
- spec/code/code_spec.rb
|
|
253
256
|
- spec/code/dictionnary_spec.rb
|
|
254
257
|
- spec/code/equal_spec.rb
|
|
255
258
|
- spec/code/equality_spec.rb
|