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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3 -3
  3. data/.prettierignore +2 -0
  4. data/.rubocop.yml +123 -5
  5. data/.ruby-version +1 -1
  6. data/.tool-versions +1 -1
  7. data/Gemfile +10 -2
  8. data/Gemfile.lock +32 -29
  9. data/VERSION +1 -1
  10. data/bin/bundle +123 -0
  11. data/bin/code +9 -11
  12. data/code-ruby.gemspec +3 -1
  13. data/lib/code/node/dictionary.rb +1 -3
  14. data/lib/code/node/if.rb +20 -15
  15. data/lib/code/node/left_operation.rb +1 -3
  16. data/lib/code/node/right_operation.rb +6 -6
  17. data/lib/code/node/while.rb +6 -6
  18. data/lib/code/object/boolean.rb +1 -1
  19. data/lib/code/object/class.rb +1 -1
  20. data/lib/code/object/code.rb +1 -1
  21. data/lib/code/object/context.rb +1 -1
  22. data/lib/code/object/date.rb +1 -1
  23. data/lib/code/object/decimal.rb +2 -2
  24. data/lib/code/object/dictionary.rb +12 -34
  25. data/lib/code/object/duration.rb +1 -1
  26. data/lib/code/object/function.rb +1 -1
  27. data/lib/code/object/global.rb +1 -1
  28. data/lib/code/object/html.rb +1 -1
  29. data/lib/code/object/integer.rb +2 -2
  30. data/lib/code/object/json.rb +2 -4
  31. data/lib/code/object/list.rb +3 -5
  32. data/lib/code/object/nothing.rb +1 -1
  33. data/lib/code/object/parameter.rb +1 -5
  34. data/lib/code/object/range.rb +1 -1
  35. data/lib/code/object/string.rb +1 -1
  36. data/lib/code/object/time.rb +1 -1
  37. data/lib/code/object.rb +7 -13
  38. data/lib/code/parser/string.rb +7 -7
  39. data/lib/code/type/repeat.rb +1 -1
  40. data/lib/code/version.rb +1 -1
  41. data/lib/code-ruby.rb +1 -1
  42. data/package-lock.json +14 -0
  43. data/package.json +0 -1
  44. data/spec/code/node/call_spec.rb +0 -34
  45. data/spec/code/parser_spec.rb +2 -2
  46. data/spec/code/type_spec.rb +1 -1
  47. data/spec/code_spec.rb +78 -79
  48. metadata +14 -12
  49. data/bin/console +0 -6
  50. data/yarn.lock +0 -4
  51. /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
- %w[
7
- 1.day.ago
8
- 1.day.from_now
9
- 1.hour.ago
10
- 1.hour.from_now
11
- 2.days.ago
12
- 2.days.from_now
13
- 2.hours.ago
14
- 2.hours.ago.hour
15
- 2.hours.from_now
16
- 2.hours.from_now.hour
17
- Time.hour
18
- Date.hour
19
- Boolean.new
20
- Boolean.new(true)
21
- Boolean.new(false)
22
- Class.new
23
- Class.new(Boolean)
24
- Class.new(Class)
25
- Context.new
26
- Context.new(a:1)
27
- Date.new
28
- Date.new.hour
29
- Date.new("2024-03-05")
30
- Date.new("2024-03-05").hour
31
- Date.today
32
- Date.yesterday
33
- Date.tomorrow
34
- Date.tomorrow.hour
35
- Decimal.new
36
- Decimal.new(0)
37
- Decimal.new(1.2)
38
- Dictionary.new
39
- Dictionary.new(a:1)
40
- Duration.new
41
- Duration.new(1.day)
42
- Duration.new("P1D")
43
- Function.new
44
- Integer.new
45
- Integer.new(0)
46
- Integer.new(1)
47
- Integer.new(1.2)
48
- List.new
49
- List.new([])
50
- List.new([1,2])
51
- Nothing.new
52
- Nothing.new(1)
53
- Object.new
54
- Object.new(1)
55
- Range.new
56
- Range.new(1,2)
57
- Range.new(-1)
58
- Range.new(1,2,exclude_end:false)
59
- Range.new(1,2,exclude_end:true)
60
- String.new
61
- String.new(:hello)
62
- Time.new
63
- Time.new("2024-03-05.06:10:59.UTC")
64
- Time.now
65
- Time.tomorrow
66
- Time.yesterday
67
- Time.tomorrow
68
- Code.new
69
- Parameter.new
70
- IdentifierList.new
71
- IdentifierList.new([])
72
- Time.new(nothing).before?
73
- Html.link_to
74
- Html.link_to('/')
75
- Html.link_to('Home','/')
76
- ].each { |input| it(input) { Code.evaluate(input) } }
77
-
78
- ["Time.hour >= 6 and Time.hour <= 23"].each do |input|
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 = Code.evaluate(input, output:)
321
- expected = Code.evaluate(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
- Code.evaluate(input, output:)
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
- Code.evaluate(<<~INPUT)
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.0.0
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-08-24 00:00:00.000000000 Z
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: json
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: language-ruby
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: zeitwerk
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: dorian-arguments
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/chained_call.rb
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: '0'
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.11
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
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/code-ruby"
5
-
6
- binding.irb
data/yarn.lock DELETED
@@ -1,4 +0,0 @@
1
- # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
- # yarn lockfile v1
3
-
4
-