code-ruby 1.0.0 → 1.1.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/.github/workflows/ci.yml +3 -3
- data/.prettierignore +2 -0
- data/.rubocop.yml +123 -5
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/Gemfile +10 -2
- data/Gemfile.lock +32 -29
- data/VERSION +1 -1
- data/bin/bundle +123 -0
- data/bin/code +9 -11
- data/code-ruby.gemspec +3 -1
- data/lib/code/node/dictionary.rb +1 -3
- data/lib/code/node/if.rb +20 -15
- data/lib/code/node/left_operation.rb +1 -3
- data/lib/code/node/right_operation.rb +6 -6
- data/lib/code/node/while.rb +6 -6
- data/lib/code/object/boolean.rb +1 -1
- data/lib/code/object/class.rb +1 -1
- data/lib/code/object/code.rb +1 -1
- data/lib/code/object/context.rb +1 -1
- data/lib/code/object/date.rb +1 -1
- data/lib/code/object/decimal.rb +2 -2
- data/lib/code/object/dictionary.rb +12 -34
- data/lib/code/object/duration.rb +1 -1
- data/lib/code/object/function.rb +1 -1
- data/lib/code/object/global.rb +1 -1
- data/lib/code/object/html.rb +1 -1
- data/lib/code/object/integer.rb +2 -2
- data/lib/code/object/json.rb +2 -4
- data/lib/code/object/list.rb +3 -5
- data/lib/code/object/nothing.rb +1 -1
- data/lib/code/object/parameter.rb +1 -5
- data/lib/code/object/range.rb +1 -1
- data/lib/code/object/string.rb +1 -1
- data/lib/code/object/time.rb +1 -1
- data/lib/code/object.rb +7 -13
- data/lib/code/parser/string.rb +7 -7
- data/lib/code/type/repeat.rb +1 -1
- data/lib/code/version.rb +1 -1
- data/lib/code-ruby.rb +1 -1
- data/package-lock.json +14 -0
- data/package.json +0 -1
- data/spec/code/node/call_spec.rb +0 -34
- data/spec/code/parser_spec.rb +2 -2
- data/spec/code/type_spec.rb +1 -1
- data/spec/code_spec.rb +78 -79
- metadata +14 -12
- data/bin/console +0 -6
- data/yarn.lock +0 -4
- /data/spec/code/parser/{chained_call.rb → chained_call_spec.rb} +0 -0
data/spec/code_spec.rb
CHANGED
@@ -3,81 +3,79 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
RSpec.describe Code do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
it(input) { Code.evaluate(input) }
|
80
|
-
end
|
6
|
+
(
|
7
|
+
%w[
|
8
|
+
1.day.ago
|
9
|
+
1.day.from_now
|
10
|
+
1.hour.ago
|
11
|
+
1.hour.from_now
|
12
|
+
2.days.ago
|
13
|
+
2.days.from_now
|
14
|
+
2.hours.ago
|
15
|
+
2.hours.ago.hour
|
16
|
+
2.hours.from_now
|
17
|
+
2.hours.from_now.hour
|
18
|
+
Time.hour
|
19
|
+
Date.hour
|
20
|
+
Boolean.new
|
21
|
+
Boolean.new(true)
|
22
|
+
Boolean.new(false)
|
23
|
+
Class.new
|
24
|
+
Class.new(Boolean)
|
25
|
+
Class.new(Class)
|
26
|
+
Context.new
|
27
|
+
Context.new(a:1)
|
28
|
+
Date.new
|
29
|
+
Date.new.hour
|
30
|
+
Date.new("2024-03-05")
|
31
|
+
Date.new("2024-03-05").hour
|
32
|
+
Date.today
|
33
|
+
Date.yesterday
|
34
|
+
Date.tomorrow
|
35
|
+
Date.tomorrow.hour
|
36
|
+
Decimal.new
|
37
|
+
Decimal.new(0)
|
38
|
+
Decimal.new(1.2)
|
39
|
+
Dictionary.new
|
40
|
+
Dictionary.new(a:1)
|
41
|
+
Duration.new
|
42
|
+
Duration.new(1.day)
|
43
|
+
Duration.new("P1D")
|
44
|
+
Function.new
|
45
|
+
Integer.new
|
46
|
+
Integer.new(0)
|
47
|
+
Integer.new(1)
|
48
|
+
Integer.new(1.2)
|
49
|
+
List.new
|
50
|
+
List.new([])
|
51
|
+
List.new([1,2])
|
52
|
+
Nothing.new
|
53
|
+
Nothing.new(1)
|
54
|
+
Object.new
|
55
|
+
Object.new(1)
|
56
|
+
Range.new
|
57
|
+
Range.new(1,2)
|
58
|
+
Range.new(-1)
|
59
|
+
Range.new(1,2,exclude_end:false)
|
60
|
+
Range.new(1,2,exclude_end:true)
|
61
|
+
String.new
|
62
|
+
String.new(:hello)
|
63
|
+
Time.new
|
64
|
+
Time.new("2024-03-05.06:10:59.UTC")
|
65
|
+
Time.now
|
66
|
+
Time.tomorrow
|
67
|
+
Time.yesterday
|
68
|
+
Time.tomorrow
|
69
|
+
Code.new
|
70
|
+
Parameter.new
|
71
|
+
IdentifierList.new
|
72
|
+
IdentifierList.new([])
|
73
|
+
Time.new(nothing).before?
|
74
|
+
Html.link_to
|
75
|
+
Html.link_to('/')
|
76
|
+
Html.link_to('Home','/')
|
77
|
+
] + ["Time.hour >= 6 and Time.hour <= 23"]
|
78
|
+
).each { |input| it(input) { described_class.evaluate(input) } }
|
81
79
|
|
82
80
|
[
|
83
81
|
[
|
@@ -317,11 +315,12 @@ RSpec.describe Code do
|
|
317
315
|
].each do |input, expected|
|
318
316
|
it "#{input} == #{expected}" do
|
319
317
|
output = StringIO.new
|
320
|
-
input =
|
321
|
-
expected =
|
318
|
+
input = described_class.evaluate(input, output:)
|
319
|
+
expected = described_class.evaluate(expected)
|
322
320
|
expect(input).to eq(expected)
|
323
321
|
expect(output.string).to eq("")
|
324
322
|
next if input.is_a?(Code::Object::Decimal)
|
323
|
+
|
325
324
|
expect(input.to_json).to eq(expected.to_json)
|
326
325
|
end
|
327
326
|
end
|
@@ -329,13 +328,13 @@ RSpec.describe Code do
|
|
329
328
|
[["puts(true)", "true\n"], %w[print(false) false]].each do |input, expected|
|
330
329
|
it "#{input} prints #{expected}" do
|
331
330
|
output = StringIO.new
|
332
|
-
|
331
|
+
described_class.evaluate(input, output:)
|
333
332
|
expect(output.string).to eq(expected)
|
334
333
|
end
|
335
334
|
end
|
336
335
|
|
337
336
|
it "doesn't crash with dictionnary as parameter" do
|
338
|
-
|
337
|
+
described_class.evaluate(<<~INPUT)
|
339
338
|
[
|
340
339
|
{
|
341
340
|
videos: [{}]
|
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: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: dorian-arguments
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: language-ruby
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: zeitwerk
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".github/workflows/ci.yml"
|
120
120
|
- ".gitignore"
|
121
121
|
- ".node-version"
|
122
|
+
- ".prettierignore"
|
122
123
|
- ".rspec"
|
123
124
|
- ".rubocop.yml"
|
124
125
|
- ".ruby-version"
|
@@ -129,10 +130,10 @@ files:
|
|
129
130
|
- README.md
|
130
131
|
- Rakefile
|
131
132
|
- VERSION
|
133
|
+
- bin/bundle
|
132
134
|
- bin/bundle-audit
|
133
135
|
- bin/bundler-audit
|
134
136
|
- bin/code
|
135
|
-
- bin/console
|
136
137
|
- bin/rspec
|
137
138
|
- bin/rubocop
|
138
139
|
- bin/test
|
@@ -237,6 +238,7 @@ files:
|
|
237
238
|
- lib/code/type/repeat.rb
|
238
239
|
- lib/code/type/sig.rb
|
239
240
|
- lib/code/version.rb
|
241
|
+
- package-lock.json
|
240
242
|
- package.json
|
241
243
|
- spec/code/node/call_spec.rb
|
242
244
|
- spec/code/object/boolean_spec.rb
|
@@ -249,7 +251,7 @@ files:
|
|
249
251
|
- spec/code/object/range_spec.rb
|
250
252
|
- spec/code/object/string_spec.rb
|
251
253
|
- spec/code/parser/boolean_spec.rb
|
252
|
-
- spec/code/parser/
|
254
|
+
- spec/code/parser/chained_call_spec.rb
|
253
255
|
- spec/code/parser/dictionary_spec.rb
|
254
256
|
- spec/code/parser/function_spec.rb
|
255
257
|
- spec/code/parser/group_spec.rb
|
@@ -261,11 +263,11 @@ files:
|
|
261
263
|
- spec/code/type_spec.rb
|
262
264
|
- spec/code_spec.rb
|
263
265
|
- spec/spec_helper.rb
|
264
|
-
- yarn.lock
|
265
266
|
homepage: https://github.com/dorianmariecom/code-ruby
|
266
267
|
licenses:
|
267
268
|
- MIT
|
268
|
-
metadata:
|
269
|
+
metadata:
|
270
|
+
rubygems_mfa_required: 'true'
|
269
271
|
post_install_message:
|
270
272
|
rdoc_options: []
|
271
273
|
require_paths:
|
@@ -274,14 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
274
276
|
requirements:
|
275
277
|
- - ">="
|
276
278
|
- !ruby/object:Gem::Version
|
277
|
-
version: '
|
279
|
+
version: '3'
|
278
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
279
281
|
requirements:
|
280
282
|
- - ">="
|
281
283
|
- !ruby/object:Gem::Version
|
282
284
|
version: '0'
|
283
285
|
requirements: []
|
284
|
-
rubygems_version: 3.5.
|
286
|
+
rubygems_version: 3.5.16
|
285
287
|
signing_key:
|
286
288
|
specification_version: 4
|
287
289
|
summary: a programming language for the internet
|
data/bin/console
DELETED
data/yarn.lock
DELETED
File without changes
|