code-ruby 0.7.1 → 0.7.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: f013740cc5bbbf2e3d0d364dc987ed62d34d85d38b4af848d4c74a7110e6ad16
4
- data.tar.gz: adf22e7e5b35c2cda0e112797768af9f2840edd9425a2a4ea87d510698d27754
3
+ metadata.gz: a4443807269930ca7780ac7dea378b206922ceb64efd2c67268faf6dc4019ec3
4
+ data.tar.gz: f02f48a5adf807a5d02e95906946161b005b0899ebf94be4707add11fccbdfb0
5
5
  SHA512:
6
- metadata.gz: fc543960e9c707f39753e9931c85f35508cc97196ddee418165bf632ceea29a2f48c076e080ad3dba0ea4080a92ce17c262f24e5686083b6051d57da157b7f96
7
- data.tar.gz: 965a1ecebb0486ab5bca33b9c35d0303b2a9204d079675516d10a52ccd10c6104003336dedd0f5d82f8e35ef805dd749ea805a5b4890c43b76f99903e3aa9d1f
6
+ metadata.gz: f940cbc1443f45503c5200eec011b9e75057ef6cafd8519884432de7600d2137afc6559e1e5e96f616a6476910b1ace98558e2eba2260cbfac16f1819fde198b
7
+ data.tar.gz: 8ca5252fdf014aecf582d52f0bf95a23ff74f34d96ac763c438d88cffd9f02add548303a5502462294f6d823328e4e0e3132313b57d014e358b6de5601ec351e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (0.6.7)
4
+ code-ruby (0.7.1)
5
5
  bigdecimal (~> 3)
6
6
  language-ruby (~> 0)
7
7
  zeitwerk (~> 2)
@@ -10,24 +10,24 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  bigdecimal (3.1.6)
13
- diff-lcs (1.5.0)
14
- language-ruby (0.6.1)
13
+ diff-lcs (1.5.1)
14
+ language-ruby (0.6.2)
15
15
  zeitwerk (~> 2)
16
- rspec (3.12.0)
17
- rspec-core (~> 3.12.0)
18
- rspec-expectations (~> 3.12.0)
19
- rspec-mocks (~> 3.12.0)
20
- rspec-core (3.12.2)
21
- rspec-support (~> 3.12.0)
22
- rspec-expectations (3.12.3)
16
+ rspec (3.13.0)
17
+ rspec-core (~> 3.13.0)
18
+ rspec-expectations (~> 3.13.0)
19
+ rspec-mocks (~> 3.13.0)
20
+ rspec-core (3.13.0)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-expectations (3.13.0)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.12.0)
25
- rspec-mocks (3.12.6)
24
+ rspec-support (~> 3.13.0)
25
+ rspec-mocks (3.13.0)
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.12.0)
28
- rspec-support (3.12.1)
27
+ rspec-support (~> 3.13.0)
28
+ rspec-support (3.13.0)
29
29
  ruby-prof (1.7.0)
30
- zeitwerk (2.6.12)
30
+ zeitwerk (2.6.13)
31
31
 
32
32
  PLATFORMS
33
33
  arm64-darwin-23
data/bin/code CHANGED
@@ -4,11 +4,18 @@
4
4
  require 'optparse'
5
5
  require_relative '../lib/code-ruby'
6
6
 
7
- options = { timeout: 0, profile: false, profiler: 'text' }
7
+ options = {
8
+ timeout: 0,
9
+ profile: false,
10
+ profiler: 'text',
11
+ input: "",
12
+ context: "",
13
+ parse: false
14
+ }
8
15
 
9
16
  OptionParser
10
17
  .new do |opts|
11
- opts.banner = 'Usage: template [options]'
18
+ opts.banner = 'Usage: code [options]'
12
19
 
13
20
  opts.on('-v', '--version', 'Version of template') do |_input|
14
21
  puts Code::Version
@@ -17,7 +24,7 @@ OptionParser
17
24
 
18
25
  opts.on(
19
26
  '-i INPUT',
20
- '--input=INPUT',
27
+ '--input INPUT',
21
28
  'Input in the code language (String or File)'
22
29
  ) do |input|
23
30
  input = File.read(input) if File.exist?(input)
@@ -27,7 +34,7 @@ OptionParser
27
34
 
28
35
  opts.on(
29
36
  '-c CONTEXT',
30
- '--context=CONTEXT',
37
+ '--context CONTEXT',
31
38
  'Context in the code language (String or File)'
32
39
  ) do |context|
33
40
  context = File.read(context) if File.exist?(context)
@@ -41,7 +48,7 @@ OptionParser
41
48
 
42
49
  opts.on(
43
50
  '-t TIMEOUT',
44
- '--timeout=TIMEOUT',
51
+ '--timeout TIMEOUT',
45
52
  'Set timeout in seconds'
46
53
  ) { |timeout| options[:timeout] = timeout.to_f }
47
54
 
@@ -61,19 +68,23 @@ OptionParser
61
68
  end
62
69
  .parse!
63
70
 
64
- input = options.fetch(:input, '')
65
- context = options.fetch(:context, '')
66
-
67
71
  RubyProf.start if options[:profile]
68
72
 
69
73
  if options[:parse]
70
- pp Code::Parser.parse(input).to_raw
74
+ pp Code::Parser.parse(options[:input]).to_raw
71
75
  else
72
- print Code.evaluate(input, context, io: $stdout, timeout: options[:timeout])
76
+ print Code.evaluate(
77
+ options[:input],
78
+ options[:context],
79
+ output: $stdout,
80
+ error: $stderr,
81
+ timeout: options[:timeout]
82
+ )
73
83
  end
74
84
 
75
85
  if options[:profile]
76
86
  result = RubyProf.stop
87
+
77
88
  if options[:profiler] == 'text'
78
89
  printer = RubyProf::FlatPrinter.new(result)
79
90
  printer.print($stdout)
@@ -8,7 +8,7 @@ class Code
8
8
  end
9
9
 
10
10
  def newline
11
- str("\n")
11
+ str("\n") | str("\r")
12
12
  end
13
13
 
14
14
  def hashtag
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.1")
5
+ Code::Version = Gem::Version.new("0.7.2")
data/spec/code_spec.rb CHANGED
@@ -4,6 +4,7 @@ require "spec_helper"
4
4
 
5
5
  RSpec.describe Code do
6
6
  [
7
+ ["\r\n", "nothing"],
7
8
  ["1 + 1", "2"],
8
9
  ["a = 1", "1"],
9
10
  ["a = 1 b = 2 c = a + b c", "3"],
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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié