language-ruby 0.5.3 → 0.5.4

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: '05749a98bba8a50630c8780cfc867dc9896c49dc02dde0b2866504a3e6d5470a'
4
- data.tar.gz: 2b5f1a517e49e30f4f3a9c8d52faba2ddedad5a567473863fd3006e790b8018c
3
+ metadata.gz: 2efe0c5926ad16a67ec4373bfe2276827c5295778b5a78c27697087dd8f32a58
4
+ data.tar.gz: 2d81c4e457a8a5459fa07680bcfaa3bf7b1684b017420e4824107cdeddf8a55a
5
5
  SHA512:
6
- metadata.gz: 8be20c47524964786c35f409329fbdb23d6335d3b471247c4d08e747920129e1bc2980c830bdb8b3be24d0d16c9cf30311c95172e5e377dcaa0c1973fee75c05
7
- data.tar.gz: 2db666b26767609eaa6793341d8f87ce426a5ec0ea42daa8fc59bf2d2c05ba8316d8c79ca31260c59bf021e22f8101493a3fbd9dfd21bcdb290b28e34b27db2e
6
+ metadata.gz: cbc41426ffeccd6a83ea79a69a30b1a32d55c989e27cc523667a6453fbd4674f1cb89b152d1fb925141f828d02a0ef61578bebfe705ee42621a9ae25809041b5
7
+ data.tar.gz: 50c889240055297df35cf515c1298e79d297dadef212c00121fe3c663d488d3679ec388a25869ec661982110220c188b8f3a3e172bdc1ebba1780a8852b8f396
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 code_boolean?
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
@@ -1,3 +1,3 @@
1
1
  require_relative "../template"
2
2
 
3
- Template::Version = Gem::Version.new("0.5.3")
3
+ Template::Version = Gem::Version.new("0.5.4")
@@ -0,0 +1,7 @@
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
+ end
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.3
4
+ version: 0.5.4
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-08 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -180,6 +180,7 @@ files:
180
180
  - spec/code/boolean_spec.rb
181
181
  - spec/code/call_spec.rb
182
182
  - spec/code/chained_call_spec.rb
183
+ - spec/code/code_spec.rb
183
184
  - spec/code/dictionnary_spec.rb
184
185
  - spec/code/equal_spec.rb
185
186
  - spec/code/equality_spec.rb
@@ -248,6 +249,7 @@ test_files:
248
249
  - spec/code/boolean_spec.rb
249
250
  - spec/code/call_spec.rb
250
251
  - spec/code/chained_call_spec.rb
252
+ - spec/code/code_spec.rb
251
253
  - spec/code/dictionnary_spec.rb
252
254
  - spec/code/equal_spec.rb
253
255
  - spec/code/equality_spec.rb