code-ruby 0.6.1 → 0.6.2

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: 1d1e6240535fbaa53a8402bb09fca25f382435c77b631953da7650279c1779c4
4
- data.tar.gz: 31ca274073a554129651ad5f6f398ec421bdf34ce20d0953f360b801bb4ba1f4
3
+ metadata.gz: b63a5dc762c3ac1d5e2f37910c24806b092a78f0bc8ed5ad4409f2e6283f7880
4
+ data.tar.gz: 5cd2966db552e1b06a7946767af43005a670dbe76378e8680524af6abf3a2479
5
5
  SHA512:
6
- metadata.gz: a81a91547923b0bcdca0b971fc0a18a684c439a4bf4821fd4b981afa06d4dbcb7baaf00b4e0e04513a2bc4abbd965b538ab92a7f4cf5739a42d1ffd306c72108
7
- data.tar.gz: b4135cc2b58e02bde82fe6fb41de533f5c37e0c8ca13bd2507e8c559fb2ebd71b796ab36059c5db0f0a51ca73091c75581136c38a5558e89e0f3ef8341f7a436
6
+ metadata.gz: 7d364133a93859542602ac10730d4b539e2e090e7b91fa9ffacfec1602edc5701da4ab8c6d1208e6e9a1967983ea2c62d80fbf7aab6df62141da332199ed7796
7
+ data.tar.gz: ad10fe135a0391fa37d769282b13a1fa7b1423a9226daa147553d91ee0d61f03f8b49d6e7b1c0514709bbf0cb03fe6c64db9ea7a71b10b9761cdcc1cdc95f2a1
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (0.6.0)
4
+ code-ruby (0.6.1)
5
+ bigdecimal (~> 3)
5
6
  language-ruby (~> 0)
6
7
  zeitwerk (~> 2)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
12
+ bigdecimal (3.1.6)
11
13
  diff-lcs (1.5.0)
12
14
  language-ruby (0.6.0)
13
15
  zeitwerk (~> 2)
@@ -24,11 +26,12 @@ GEM
24
26
  diff-lcs (>= 1.2.0, < 2.0)
25
27
  rspec-support (~> 3.12.0)
26
28
  rspec-support (3.12.1)
27
- ruby-prof (1.6.3)
29
+ ruby-prof (1.7.0)
28
30
  zeitwerk (2.6.12)
29
31
 
30
32
  PLATFORMS
31
- arm64-darwin-22
33
+ arm64-darwin-23
34
+ ruby
32
35
 
33
36
  DEPENDENCIES
34
37
  code-ruby!
@@ -36,4 +39,4 @@ DEPENDENCIES
36
39
  ruby-prof
37
40
 
38
41
  BUNDLED WITH
39
- 2.4.22
42
+ 2.5.5
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # code-ruby
2
2
 
3
3
  A programming language, like `Code.evaluate("1 + 1") # => 2`
4
+
5
+ TODO
6
+
7
+ - [ ] `code` command
data/code-ruby.gemspec CHANGED
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "zeitwerk", "~> 2"
18
18
  s.add_dependency "language-ruby", "~> 0"
19
+ s.add_dependency "bigdecimal", "~> 3"
19
20
  end
@@ -71,6 +71,9 @@ class Code
71
71
  when "size"
72
72
  sig(args)
73
73
  code_size
74
+ when "sum"
75
+ sig(args)
76
+ code_sum
74
77
  when "uniq"
75
78
  sig(args)
76
79
  code_uniq
@@ -197,6 +200,10 @@ class Code
197
200
  List.new(raw.uniq)
198
201
  end
199
202
 
203
+ def code_sum
204
+ raw.inject(&:code_plus) || Nothing.new
205
+ end
206
+
200
207
  def inspect
201
208
  to_s
202
209
  end
data/lib/code/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require_relative "../code"
2
2
 
3
- Code::Version = Gem::Version.new("0.6.1")
3
+ Code::Version = Gem::Version.new("0.6.2")
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Code::Object::List do
6
+ [
7
+ ["[] == []", "true"],
8
+ ["[1, 2, 3].sum", "6"],
9
+ ].each do |input, expected|
10
+ it "#{input} == #{expected}" do
11
+ expect(Code.evaluate(input)).to eq(Code.evaluate(expected))
12
+ end
13
+ end
14
+ end
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2024-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bigdecimal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
41
55
  description: 'A programming language, like Code.evaluate("1 + 1") # => 2'
42
56
  email: dorian@dorianmarie.fr
43
57
  executables:
@@ -154,6 +168,7 @@ files:
154
168
  - spec/code/object/dictionary_spec.rb
155
169
  - spec/code/object/function_spec.rb
156
170
  - spec/code/object/integer_spec.rb
171
+ - spec/code/object/list_spec.rb
157
172
  - spec/code/object/nothing_spec.rb
158
173
  - spec/code/object/range_spec.rb
159
174
  - spec/code/parser/boolean_spec.rb
@@ -188,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
203
  - !ruby/object:Gem::Version
189
204
  version: '0'
190
205
  requirements: []
191
- rubygems_version: 3.4.22
206
+ rubygems_version: 3.5.5
192
207
  signing_key:
193
208
  specification_version: 4
194
209
  summary: A programming language
@@ -199,6 +214,7 @@ test_files:
199
214
  - spec/code/object/dictionary_spec.rb
200
215
  - spec/code/object/function_spec.rb
201
216
  - spec/code/object/integer_spec.rb
217
+ - spec/code/object/list_spec.rb
202
218
  - spec/code/object/nothing_spec.rb
203
219
  - spec/code/object/range_spec.rb
204
220
  - spec/code/parser/boolean_spec.rb