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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a866affca8019509c1e7836990f7a3488990e5bf64f8c8e3b6a976ed7e1bab6
4
- data.tar.gz: 23ad1030abf7de9981adcf65267c195b85d1026995aa74fa566427c4c74660c5
3
+ metadata.gz: c056c67f03842581b5c4a106cb6147d2cfb4eefea75c2bb187112e04adc44851
4
+ data.tar.gz: 1c61bb7ccb9b0a1b29a76cf9405c70ba94d740f77db9c9003662b4401e4d4293
5
5
  SHA512:
6
- metadata.gz: 9b9b495235c6b7e32d00ae42b372c5b42e6a12123d8adda974044d7eceee36a5d802a68c72c52b9926b295b00ea803bb696697bf6377dcad370f539d23f3cc4c
7
- data.tar.gz: be2c356e043c80850ac786da56ec5a380fc624d75f953eedc18817728e70d31f75d4c3e2be5782808da8e50c4c0d445ae6ac9ee150166262d7809f2ea72d1423
6
+ metadata.gz: 7d45064357034d4232410e47bf5edb5bbfda2ea51be5596aabea466ecd796a011abfc7d850761319deb37e7d2f391852ca0cd8699c82c8a4e9b0f38e2dc6904b
7
+ data.tar.gz: 65580e08bae19b1e190a49b44e7d67c2ad05ceb18cda8b4e90efa9a02333fa1bc6216beeefd62d777178a88632562cb737076be7273c4cb500ef3783f7bb9b72
data/.rubocop.yml CHANGED
@@ -120,6 +120,8 @@ Style/StringLiterals:
120
120
  Enabled: false
121
121
  Style/StringLiteralsInInterpolation:
122
122
  Enabled: false
123
+ Lint/SafeNavigationChain:
124
+ Enabled: false
123
125
  plugins:
124
126
  - rubocop-factory_bot
125
127
  - rubocop-performance
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.5.6)
4
+ code-ruby (1.6.0)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.6
1
+ 1.6.0
@@ -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
@@ -16,7 +16,7 @@ class Code
16
16
  code_new(*code_arguments.raw)
17
17
  when "!", "not"
18
18
  sig(args)
19
- code_exclamation_point
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
- code_equal_equal(code_value)
37
+ code_equal(code_value)
38
38
  when "===", "strict_equal"
39
39
  sig(args) { Object }
40
- code_equal_equal_equal(code_value)
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 code_equal_equal(other)
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 code_exclamation_point
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 code_equal_equal_equal(other)
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?