code-ruby 0.9.0 → 0.9.1

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: 53b06f45f6875d9e78c0554c660567fcfc7837b2e3fc3bfa8f3773bbdf133831
4
- data.tar.gz: 894638c2797c729099e577a8c7f10d21990d291a0cc2376760f5e61d58f0c6e4
3
+ metadata.gz: 1f92c4c4db84ee34d5e5d58325ab4de49d9346a738239aba44682db9e2530e7e
4
+ data.tar.gz: 6d056953ec6852d7824343f45198e0b35f13db881420fdce645753e091249ac7
5
5
  SHA512:
6
- metadata.gz: 387dde40ad9948f938cdaea2a94dfcaabe4e94cef99f8941340184287a8b79efcd378f1012d3a0b4215b394090efc51368b9770429a5b60e63804721487c3546
7
- data.tar.gz: a5939cfca0ff262ac86075c141cb133b39126f0f99f61b4715a018e3f746a45513dce30b4a45520a5f95117cbd67716a6984236199ef45b6d527853a31dae3f0
6
+ metadata.gz: 98ddcc59fe93cf2625cbc521a08b2119bcb8fc1bd8cd6fd3da6fb40039a73aa8835e35234c3e77842fbbcc6fa57fe51377e96f457bfd6e391a5bd96d37229296
7
+ data.tar.gz: 7b2723a4c912be64c3c7588fb905b40c6cd8fc510a61ca56a7af21037bd8d27d29a667659ea07a97d096d9a44d01dc6a5064f7a45ee58e39770d016a479353af
@@ -10,14 +10,6 @@ class Code
10
10
  @name = name
11
11
  end
12
12
 
13
- def self.name
14
- "Argument"
15
- end
16
-
17
- def inspect
18
- to_s
19
- end
20
-
21
13
  def keyword?
22
14
  !regular?
23
15
  end
@@ -29,10 +21,6 @@ class Code
29
21
  def regular?
30
22
  !name
31
23
  end
32
-
33
- def to_s
34
- "<Argument #{value.inspect}>"
35
- end
36
24
  end
37
25
  end
38
26
  end
@@ -60,6 +60,10 @@ class Code
60
60
  def truthy?
61
61
  raw
62
62
  end
63
+
64
+ def as_json(...)
65
+ raw.as_json(...)
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -24,6 +24,10 @@ class Code
24
24
  def self.name
25
25
  "Class"
26
26
  end
27
+
28
+ def as_json(...)
29
+ raw.name.as_json(...)
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -37,6 +37,10 @@ class Code
37
37
  def to_s
38
38
  raw.to_s
39
39
  end
40
+
41
+ def as_json(...)
42
+ raw.as_json(...)
43
+ end
40
44
  end
41
45
  end
42
46
  end
@@ -309,6 +309,10 @@ class Code
309
309
  def to_s
310
310
  raw.to_s("F")
311
311
  end
312
+
313
+ def as_json(...)
314
+ raw.as_json(...)
315
+ end
312
316
  end
313
317
  end
314
318
  end
@@ -648,6 +648,10 @@ class Code
648
648
  def to_s
649
649
  "{#{raw.map { |key, value| "#{key.inspect} => #{value.inspect}" }.join(", ")}}"
650
650
  end
651
+
652
+ def as_json(...)
653
+ raw.as_json(...)
654
+ end
651
655
  end
652
656
  end
653
657
  end
@@ -43,6 +43,10 @@ class Code
43
43
  def to_s
44
44
  raw.to_s
45
45
  end
46
+
47
+ def as_json(...)
48
+ raw.as_json(...)
49
+ end
46
50
  end
47
51
  end
48
52
  end
@@ -87,6 +87,10 @@ class Code
87
87
  def to_s
88
88
  ""
89
89
  end
90
+
91
+ def as_json(...)
92
+ raw.as_json(...)
93
+ end
90
94
  end
91
95
  end
92
96
  end
@@ -91,10 +91,6 @@ class Code
91
91
  end
92
92
  end
93
93
  end
94
-
95
- def to_s
96
- "global"
97
- end
98
94
  end
99
95
  end
100
96
  end
@@ -403,6 +403,10 @@ class Code
403
403
  def to_s
404
404
  raw.to_s
405
405
  end
406
+
407
+ def as_json(...)
408
+ raw.as_json(...)
409
+ end
406
410
  end
407
411
  end
408
412
  end
@@ -211,6 +211,10 @@ class Code
211
211
  def to_s
212
212
  "[#{raw.map(&:inspect).join(", ")}]"
213
213
  end
214
+
215
+ def as_json(...)
216
+ raw.as_json(...)
217
+ end
214
218
  end
215
219
  end
216
220
  end
@@ -24,6 +24,10 @@ class Code
24
24
  def truthy?
25
25
  false
26
26
  end
27
+
28
+ def as_json(...)
29
+ raw.as_json(...)
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -138,6 +138,10 @@ class Code
138
138
  def to_s
139
139
  raw.to_s
140
140
  end
141
+
142
+ def as_json(...)
143
+ raw.as_json(...)
144
+ end
141
145
  end
142
146
  end
143
147
  end
@@ -100,6 +100,10 @@ class Code
100
100
  def to_s
101
101
  raw
102
102
  end
103
+
104
+ def as_json(...)
105
+ raw.as_json(...)
106
+ end
103
107
  end
104
108
  end
105
109
  end
@@ -77,6 +77,10 @@ class Code
77
77
  def to_s
78
78
  raw.to_s
79
79
  end
80
+
81
+ def as_json(...)
82
+ raw.as_json(...)
83
+ end
80
84
  end
81
85
  end
82
86
  end
data/lib/code/object.rb CHANGED
@@ -319,5 +319,13 @@ class Code
319
319
  def truthy?
320
320
  true
321
321
  end
322
+
323
+ def to_json(...)
324
+ as_json(...).to_json
325
+ end
326
+
327
+ def as_json(...)
328
+ raise NotImplementedError, "#{self.class}#as_json"
329
+ end
322
330
  end
323
331
  end
data/lib/code/version.rb CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../code"
4
4
 
5
- Code::Version = Gem::Version.new("0.9.0")
5
+ Code::Version = Gem::Version.new("0.9.1")
data/lib/code-ruby.rb CHANGED
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support"
4
+ require "active_support/core_ext/date/conversions"
5
+ require "active_support/core_ext/numeric/time"
6
+ require "active_support/core_ext/object/json"
3
7
  require "bigdecimal"
8
+ require "json"
9
+ require "language-ruby"
4
10
  require "stringio"
5
11
  require "timeout"
6
12
  require "zeitwerk"
7
- require "language-ruby"
8
- require "active_support"
9
- require "active_support/core_ext/numeric/time"
10
- require "active_support/core_ext/date/conversions"
11
13
 
12
14
  loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
13
15
  loader.ignore("#{__dir__}/code-ruby.rb")
data/spec/code_spec.rb CHANGED
@@ -146,6 +146,10 @@ RSpec.describe Code do
146
146
  it "#{input} == #{expected}" do
147
147
  expect(Code.evaluate(input)).to eq(Code.evaluate(expected))
148
148
  end
149
+
150
+ it "#{input} converts to json like #{expected}" do
151
+ expect(Code.evaluate(input).to_json).to eq(Code.evaluate(expected).to_json)
152
+ end
149
153
  end
150
154
 
151
155
  %w[
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: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié