code-ruby 0.7.2 → 0.7.4

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: a4443807269930ca7780ac7dea378b206922ceb64efd2c67268faf6dc4019ec3
4
- data.tar.gz: f02f48a5adf807a5d02e95906946161b005b0899ebf94be4707add11fccbdfb0
3
+ metadata.gz: c1de692db935f0bf2da829334bd120b8fa972a686b700c529379f4ac4631d34b
4
+ data.tar.gz: 1fc45c35736818f606f17ccb0876be91d6b40c71415dab4e5b66693f3ace40d5
5
5
  SHA512:
6
- metadata.gz: f940cbc1443f45503c5200eec011b9e75057ef6cafd8519884432de7600d2137afc6559e1e5e96f616a6476910b1ace98558e2eba2260cbfac16f1819fde198b
7
- data.tar.gz: 8ca5252fdf014aecf582d52f0bf95a23ff74f34d96ac763c438d88cffd9f02add548303a5502462294f6d823328e4e0e3132313b57d014e358b6de5601ec351e
6
+ metadata.gz: e4f23cc4451bc13bed8b98068707c026bbf3e603849872e6c3593d0fd18d81b62afdc27105437138156bd7edc88716b2864a4653b2af49efe915ad0d097d3b1a
7
+ data.tar.gz: 533109d631965b229c82a46ed04f5158a956f38eaa1154cdaed66f0a6f50943e2e7fb47ec8f81f229b14bb24b611fe1b32ffa3420ecf44eb5a61eb902cee78b7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (0.7.1)
4
+ code-ruby (0.7.3)
5
5
  bigdecimal (~> 3)
6
6
  language-ruby (~> 0)
7
7
  zeitwerk (~> 2)
@@ -32,7 +32,7 @@ class Code
32
32
  when "&", "bitwise_and"
33
33
  sig(args) { Number }
34
34
  code_bitwise_and(value)
35
- when "*", "multiplication"
35
+ when "*", "multiplication", "×"
36
36
  sig(args) { Number | String }
37
37
  code_multiplication(value)
38
38
  when "**", "power"
@@ -44,7 +44,7 @@ class Code
44
44
  when "-", "minus", "unary_minus"
45
45
  sig(args) { Number.maybe }
46
46
  value ? code_minus(value) : code_unary_minus
47
- when "/", "division"
47
+ when "/", "division", "÷"
48
48
  sig(args) { Number }
49
49
  code_division(value)
50
50
  when "<", "inferior"
@@ -4,6 +4,10 @@ class Code
4
4
  class Parser
5
5
  class List < Language
6
6
  def code
7
+ Code
8
+ end
9
+
10
+ def code_present
7
11
  Code.new.present
8
12
  end
9
13
 
@@ -28,13 +32,14 @@ class Code
28
32
  end
29
33
 
30
34
  def element
31
- code
35
+ (whitespace? << code_present << (whitespace? << comma).maybe) |
36
+ (whitespace? << code << whitespace? << comma)
32
37
  end
33
38
 
34
39
  def root
35
40
  (
36
41
  opening_square_bracket.ignore << whitespace? <<
37
- (whitespace? << element << (whitespace? << comma).maybe).repeat <<
42
+ element.repeat <<
38
43
  (whitespace? << closing_square_bracket.ignore).maybe
39
44
  ).aka(:list) | String
40
45
  end
@@ -11,6 +11,10 @@ class Code
11
11
  str("*")
12
12
  end
13
13
 
14
+ def multiplication_sign
15
+ str("×")
16
+ end
17
+
14
18
  def slash
15
19
  str("/")
16
20
  end
@@ -19,8 +23,12 @@ class Code
19
23
  str("%")
20
24
  end
21
25
 
26
+ def division_sign
27
+ str("÷")
28
+ end
29
+
22
30
  def operator
23
- asterisk | slash | percent
31
+ asterisk | slash | percent | multiplication_sign | division_sign
24
32
  end
25
33
  end
26
34
  end
@@ -108,7 +108,7 @@ class Code
108
108
  end
109
109
 
110
110
  def separator
111
- special_character
111
+ special_character | any.absent
112
112
  end
113
113
 
114
114
  def root
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.7.2")
5
+ Code::Version = Gem::Version.new("0.7.4")
data/spec/code_spec.rb CHANGED
@@ -4,6 +4,7 @@ require "spec_helper"
4
4
 
5
5
  RSpec.describe Code do
6
6
  [
7
+ ["9975×14÷8", "17456.25"],
7
8
  ["\r\n", "nothing"],
8
9
  ["1 + 1", "2"],
9
10
  ["a = 1", "1"],
@@ -68,6 +69,11 @@ RSpec.describe Code do
68
69
  ["[1, 2, 3]", "[1, 2, 3]"],
69
70
  ["[1, 2, 3].include?(2)", "true"],
70
71
  ["[1, 2, 3].include?(4)", "false"],
72
+ ["[1, 2, 3,].include?(4)", "false"],
73
+ ["[1, 2, 3, \n ].include?(4)", "false"],
74
+ ["[1].each do end", "[1]"],
75
+ ["[,].include?(4)", "false"],
76
+ ["[,,].include?(4)", "false"],
71
77
  ["[[true]]", "[[true]]"],
72
78
  ["2 * 3", "6"],
73
79
  ["2 * 3 + 2", "8"],
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: 0.7.2
4
+ version: 0.7.4
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-02-11 00:00:00.000000000 Z
11
+ date: 2024-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal