code-ruby 3.0.0 → 3.0.1
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/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/node/square_bracket.rb +6 -1
- data/spec/code_spec.rb +1 -0
- metadata +1 -2
- data/spec/code/object/identifier_list_spec.rb +0 -60
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6764dfae8187cff0c8c1a5cb3877fa76359791c2a5c3dbecc074cf01a1764f38
|
|
4
|
+
data.tar.gz: 8b1aef62dec7e892e71047c8c1704de6396096a437e9a5e35dc37b53d2c8d09d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06eb3f841f44f59cd55a6ce4518df768be00db976daf3119383f80ff93f21f948935fad9e16d2eb13becf8004e5b0568510c2012502d51be22a4dd2d4f8f1428
|
|
7
|
+
data.tar.gz: 5389937455b8120b48c26772255e287b156a4ed9cb37e36013e8443cb67de69948845ca5d77087f1c76c834a06554d2a6ff00a9a9c00718b8da5ef847b9f2d6e
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.0.
|
|
1
|
+
3.0.1
|
|
@@ -22,7 +22,12 @@ class Code
|
|
|
22
22
|
def resolve(**args)
|
|
23
23
|
left = @left&.resolve(**args) || Object::Nothing.new
|
|
24
24
|
|
|
25
|
-
list =
|
|
25
|
+
list =
|
|
26
|
+
if left.is_an?(Object::IdentifierList)
|
|
27
|
+
Object::IdentifierList.new(left.raw.dup)
|
|
28
|
+
else
|
|
29
|
+
Object::IdentifierList.new([left])
|
|
30
|
+
end
|
|
26
31
|
|
|
27
32
|
(@statements || []).each do |statement|
|
|
28
33
|
list.code_append(statement.evaluate(**args))
|
data/spec/code_spec.rb
CHANGED
|
@@ -412,6 +412,7 @@ RSpec.describe Code do
|
|
|
412
412
|
['"Hello {1}"', '"Hello 1"'],
|
|
413
413
|
['user = {} user.name = "Dorian" user.name', ":Dorian"],
|
|
414
414
|
['user = {} user[:name] = "Dorian" user[:name]', ":Dorian"],
|
|
415
|
+
['value = {} email = "a" calendar_id = "c" value[email] ||= {} value[email][calendar_id] ||= {} value[email][calendar_id]', "{}"],
|
|
415
416
|
['{ "first_name": "Dorian" }', '{"first_name" => "Dorian"}'],
|
|
416
417
|
['{ "first_name": "Dorian" }.as_json', '{"first_name" => "Dorian"}'],
|
|
417
418
|
%w[nothing.to_json :null],
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: code-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dorian Marié
|
|
@@ -306,7 +306,6 @@ files:
|
|
|
306
306
|
- spec/code/object/decimal_spec.rb
|
|
307
307
|
- spec/code/object/dictionary_spec.rb
|
|
308
308
|
- spec/code/object/function_spec.rb
|
|
309
|
-
- spec/code/object/identifier_list_spec.rb
|
|
310
309
|
- spec/code/object/integer_spec.rb
|
|
311
310
|
- spec/code/object/list_spec.rb
|
|
312
311
|
- spec/code/object/nothing_spec.rb
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Code::Object::IdentifierList do
|
|
6
|
-
it "assigns square bracket keys in parent context from nested scopes" do
|
|
7
|
-
parent_context = Code::Object::Context.new
|
|
8
|
-
child_context = Code::Object::Context.new({}, parent_context)
|
|
9
|
-
code_identifier = Code::Object::String.new("github")
|
|
10
|
-
code_index = Code::Object::Integer.new(1)
|
|
11
|
-
|
|
12
|
-
parent_context.code_set(code_identifier, Code::Object::Dictionary.new(a: 1))
|
|
13
|
-
|
|
14
|
-
identifier_list = described_class.new([code_identifier, code_index])
|
|
15
|
-
|
|
16
|
-
identifier_list.call(
|
|
17
|
-
operator: "=",
|
|
18
|
-
arguments: Code::Object::List.new([Code::Object::Integer.new(2)]),
|
|
19
|
-
context: child_context,
|
|
20
|
-
error: StringIO.new,
|
|
21
|
-
input: StringIO.new,
|
|
22
|
-
object: Code::Object::Global.new,
|
|
23
|
-
output: StringIO.new,
|
|
24
|
-
source: ""
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
expect(parent_context.code_fetch(code_identifier).code_fetch(code_index)).to eq(
|
|
28
|
-
Code::Object::Integer.new(2)
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "keeps context for ||= assignments in nested context receivers" do
|
|
33
|
-
code_context = Code::Object::Context.new
|
|
34
|
-
code_identifier = Code::Object::String.new("value")
|
|
35
|
-
code_key = Code::Object::String.new("key")
|
|
36
|
-
|
|
37
|
-
code_context.code_set(
|
|
38
|
-
code_identifier,
|
|
39
|
-
Code::Object::Dictionary.new(code_key => Code::Object::Dictionary.new(a: 1))
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
identifier_list = described_class.new([code_identifier, code_key])
|
|
43
|
-
|
|
44
|
-
expect do
|
|
45
|
-
identifier_list.send(
|
|
46
|
-
:assign_in_context,
|
|
47
|
-
context: code_context,
|
|
48
|
-
assignment_operator: "||=",
|
|
49
|
-
code_value: Code::Object::Dictionary.new(b: 2),
|
|
50
|
-
arguments: Code::Object::List.new([Code::Object::Dictionary.new(b: 2)]),
|
|
51
|
-
operator: "||=",
|
|
52
|
-
error: StringIO.new,
|
|
53
|
-
input: StringIO.new,
|
|
54
|
-
object: Code::Object::Global.new,
|
|
55
|
-
output: StringIO.new,
|
|
56
|
-
source: ""
|
|
57
|
-
)
|
|
58
|
-
end.not_to raise_error
|
|
59
|
-
end
|
|
60
|
-
end
|