code-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: abf1a1657a2333a0ebacfaef8714b4704dc19927d3c8a66ef94a23b8ab526c1e
4
- data.tar.gz: 2b5f1a517e49e30f4f3a9c8d52faba2ddedad5a567473863fd3006e790b8018c
3
+ metadata.gz: 2b29f8f45f88a9c9ccd84fc3bcf830ea548742e8587e03476a8edd3d3e315b1d
4
+ data.tar.gz: 23cc48f2a4e786a14a51fab7fb4930da343f96a29de7b1992ff0ce07718ef204
5
5
  SHA512:
6
- metadata.gz: fc1e6ec8ad7829a3ff9681fe0549cbcef10551fd3ab449bcf0187586a0d523004d3191288227b7009b4ed2279f057e4179394c1e2c2e9e41923669e544192191
7
- data.tar.gz: 2db666b26767609eaa6793341d8f87ce426a5ec0ea42daa8fc59bf2d2c05ba8316d8c79ca31260c59bf021e22f8101493a3fbd9dfd21bcdb290b28e34b27db2e
6
+ metadata.gz: 99819e4bae8c1bc53b9cc8e162ba2b9ff34e2434039e9fc700f1bf28686ae26e2c9ba92fd9359d545d542c9c7456709b95bd7454ef596e5799a65f93ff03abb3
7
+ data.tar.gz: bd7bed0d5decbaa3af28c789fe9fc35085d39e24a1b9d047733afb35d362343fb3f9508e7682b5cb4fb9d8e098aa2a321f2db93e8918ac2cb6444dca5bddd1ec
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: code-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