code-ruby 1.5.6 → 1.6.0
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/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/docs/precedence.txt +36 -0
- data/lib/code/concerns/shared.rb +33 -6
- data/lib/code/node/if.rb +5 -0
- data/lib/code/object/date.rb +651 -45
- data/lib/code/object/decimal.rb +722 -78
- data/lib/code/object/dictionary.rb +435 -60
- data/lib/code/object/function.rb +4 -3
- data/lib/code/object/global.rb +8 -1
- data/lib/code/object/integer.rb +724 -87
- data/lib/code/object/list.rb +546 -102
- data/lib/code/object/number.rb +8 -0
- data/lib/code/object/parameter.rb +7 -11
- data/lib/code/object/range.rb +5 -0
- data/lib/code/object/string.rb +14 -0
- data/lib/code/object/time.rb +644 -114
- data/lib/code/parser/equal.rb +1 -1
- data/lib/code/parser/equality.rb +5 -4
- data/lib/code/parser/if.rb +7 -2
- data/lib/code/parser/name.rb +56 -8
- data/lib/code/parser/negation.rb +2 -2
- data/lib/code.rb +1 -1
- data/spec/code/object/decimal_spec.rb +0 -1
- data/spec/code/object/http_spec.rb +72 -68
- data/spec/code/object/integer_spec.rb +0 -1
- data/spec/code/parser/if_modifier_spec.rb +2 -2
- data/spec/code_spec.rb +142 -132
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c056c67f03842581b5c4a106cb6147d2cfb4eefea75c2bb187112e04adc44851
|
4
|
+
data.tar.gz: 1c61bb7ccb9b0a1b29a76cf9405c70ba94d740f77db9c9003662b4401e4d4293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d45064357034d4232410e47bf5edb5bbfda2ea51be5596aabea466ecd796a011abfc7d850761319deb37e7d2f391852ca0cd8699c82c8a4e9b0f38e2dc6904b
|
7
|
+
data.tar.gz: 65580e08bae19b1e190a49b44e7d67c2ad05ceb18cda8b4e90efa9a02333fa1bc6216beeefd62d777178a88632562cb737076be7273c4cb500ef3783f7bb9b72
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.6.0
|
data/docs/precedence.txt
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Code
|
2
|
+
Statement
|
3
|
+
Splat
|
4
|
+
Class
|
5
|
+
While
|
6
|
+
If
|
7
|
+
IfModifier
|
8
|
+
OrKeyword
|
9
|
+
NotKeyword
|
10
|
+
Equal
|
11
|
+
Rescue
|
12
|
+
Ternary
|
13
|
+
Range
|
14
|
+
OrOperator
|
15
|
+
AndOperator
|
16
|
+
Equality
|
17
|
+
Greater
|
18
|
+
BitwiseOr
|
19
|
+
BitwiseAnd
|
20
|
+
Shift
|
21
|
+
Addition
|
22
|
+
Multiplication
|
23
|
+
Negation
|
24
|
+
ChainedCall
|
25
|
+
SquareBracket
|
26
|
+
UnaryMinus
|
27
|
+
Power
|
28
|
+
Function
|
29
|
+
Dictionary
|
30
|
+
List
|
31
|
+
String
|
32
|
+
Number
|
33
|
+
Boolean
|
34
|
+
Nothing
|
35
|
+
Group
|
36
|
+
Call
|
data/lib/code/concerns/shared.rb
CHANGED
@@ -16,7 +16,7 @@ class Code
|
|
16
16
|
code_new(*code_arguments.raw)
|
17
17
|
when "!", "not"
|
18
18
|
sig(args)
|
19
|
-
|
19
|
+
code_exclamation_mark
|
20
20
|
when "!=", "different"
|
21
21
|
sig(args) { Object }
|
22
22
|
code_different(code_value)
|
@@ -34,10 +34,13 @@ class Code
|
|
34
34
|
code_exclusive_range(code_value)
|
35
35
|
when "==", "equal"
|
36
36
|
sig(args) { Object }
|
37
|
-
|
37
|
+
code_equal(code_value)
|
38
38
|
when "===", "strict_equal"
|
39
39
|
sig(args) { Object }
|
40
|
-
|
40
|
+
code_strict_equal(code_value)
|
41
|
+
when "!==", "strict_different"
|
42
|
+
sig(args) { Object }
|
43
|
+
code_strict_different(code_value)
|
41
44
|
when "falsy?"
|
42
45
|
sig(args)
|
43
46
|
code_falsy?
|
@@ -109,6 +112,12 @@ class Code
|
|
109
112
|
when "name"
|
110
113
|
sig(args)
|
111
114
|
code_name
|
115
|
+
when "nothing?"
|
116
|
+
sig(args)
|
117
|
+
code_nothing?
|
118
|
+
when "something?"
|
119
|
+
sig(args)
|
120
|
+
code_something?
|
112
121
|
when /=$/
|
113
122
|
sig(args) { Object }
|
114
123
|
|
@@ -166,13 +175,13 @@ class Code
|
|
166
175
|
Object::Boolean.new(self != code_other)
|
167
176
|
end
|
168
177
|
|
169
|
-
def
|
178
|
+
def code_equal(other)
|
170
179
|
code_other = other.to_code
|
171
180
|
|
172
181
|
Object::Boolean.new(self == code_other)
|
173
182
|
end
|
174
183
|
|
175
|
-
def
|
184
|
+
def code_exclamation_mark
|
176
185
|
Object::Boolean.new(falsy?)
|
177
186
|
end
|
178
187
|
|
@@ -198,12 +207,18 @@ class Code
|
|
198
207
|
self
|
199
208
|
end
|
200
209
|
|
201
|
-
def
|
210
|
+
def code_strict_equal(other)
|
202
211
|
code_other = other.to_code
|
203
212
|
|
204
213
|
Object::Boolean.new(self === code_other)
|
205
214
|
end
|
206
215
|
|
216
|
+
def code_strict_different(other)
|
217
|
+
code_other = other.to_code
|
218
|
+
|
219
|
+
Object::Boolean.new(!(self === code_other))
|
220
|
+
end
|
221
|
+
|
207
222
|
def falsy?
|
208
223
|
!truthy?
|
209
224
|
end
|
@@ -302,10 +317,22 @@ class Code
|
|
302
317
|
code_inspect.raw
|
303
318
|
end
|
304
319
|
|
320
|
+
def code_nothing?
|
321
|
+
Boolean.new(nothing?)
|
322
|
+
end
|
323
|
+
|
324
|
+
def code_something?
|
325
|
+
Boolean.new(something?)
|
326
|
+
end
|
327
|
+
|
305
328
|
def nothing?
|
306
329
|
false
|
307
330
|
end
|
308
331
|
|
332
|
+
def something?
|
333
|
+
!nothing?
|
334
|
+
end
|
335
|
+
|
309
336
|
def code_falsy?
|
310
337
|
Object::Boolean.new(falsy?)
|
311
338
|
end
|
data/lib/code/node/if.rb
CHANGED
@@ -6,6 +6,7 @@ class Code
|
|
6
6
|
IF_KEYWORD = "if"
|
7
7
|
UNLESS_KEYWORD = "unless"
|
8
8
|
ELSIF_KEYWORD = "elsif"
|
9
|
+
ELSUNLESS_KEYWORD = "elsunless"
|
9
10
|
ELSE_KEYWORD = "else"
|
10
11
|
|
11
12
|
class Else < Node
|
@@ -50,6 +51,10 @@ class Code
|
|
50
51
|
elses.operator == ELSIF_KEYWORD &&
|
51
52
|
elses.statement.evaluate(**args).truthy?
|
52
53
|
) ||
|
54
|
+
(
|
55
|
+
elses.operator == ELSUNLESS_KEYWORD &&
|
56
|
+
elses.statement.evaluate(**args).falsy?
|
57
|
+
) ||
|
53
58
|
(
|
54
59
|
elses.operator == IF_KEYWORD &&
|
55
60
|
elses.statement.evaluate(**args).truthy?
|