code-ruby 0.15.15 → 1.0.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: 381b6da2c705fe3f7f21f03ed74bb43029e0a93348b16372c7313c8f9998d90d
4
- data.tar.gz: 3c37e2ce62f94eadb7575a53b6bb60ac61e1b1804eafba3bd90f792d7271523e
3
+ metadata.gz: c8fd1137d78771da7054494333cedcdf9ebb4d45402112d2694d227e4d44739b
4
+ data.tar.gz: f494bfe408b64cd08e39f300b499d1634c8ec59534519306658d44ef908c2f72
5
5
  SHA512:
6
- metadata.gz: b23a3ac309cbab033d5212d9f79fdd7a8afc654ee586915459641db7b13b8bd6bd5dfc3b3f373379718b5c6185612d920ccd322572dfb8edbce30606473a7d66
7
- data.tar.gz: 29cee7ad7781d50a3682611385a4fa8236d935fc6f26474019834e70f9e8f8518b065213a5fca1af8eb2cd41c4a766e7566d3621de7129f03bd69e92a99a93af
6
+ metadata.gz: 641adcd7f50838888057e7f2c84464d89641a5648136a00f18955ae2128d35b59ac7d2a780544c0a3cf2f917110e7417cbe9dfc4d1f9c494eac80cf313abe2b4
7
+ data.tar.gz: d42e4ab20e52db2ab7cbde25b12c43810ef8441076954cbe3fbf7fba6abb1ae861af48ea0b85b85d037e26c77aeb96cc4c6b26a96f42e651ea3e33ee4845ca89
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (0.15.15)
4
+ code-ruby (1.0.0)
5
5
  activesupport
6
6
  bigdecimal
7
7
  did-you-mean
8
+ dorian-arguments
8
9
  json
9
10
  language-ruby
10
11
  zeitwerk
@@ -12,7 +13,7 @@ PATH
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- activesupport (7.2.0)
16
+ activesupport (7.2.1)
16
17
  base64
17
18
  bigdecimal
18
19
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -26,7 +27,7 @@ GEM
26
27
  ast (2.4.2)
27
28
  base64 (0.2.0)
28
29
  bigdecimal (3.1.8)
29
- bundler-audit (0.9.1)
30
+ bundler-audit (0.9.2)
30
31
  bundler (>= 1.2.0, < 3)
31
32
  thor (~> 1.0)
32
33
  concurrent-ruby (1.3.4)
@@ -34,11 +35,17 @@ GEM
34
35
  did-you-mean (0.1.1)
35
36
  levenshtein (>= 0.2.0)
36
37
  diff-lcs (1.5.1)
38
+ dorian-arguments (0.4.1)
39
+ activesupport
40
+ bigdecimal
41
+ dorian-to_struct
42
+ dorian-to_struct (0.6.0)
37
43
  drb (2.2.1)
38
44
  i18n (1.14.5)
39
45
  concurrent-ruby (~> 1.0)
40
46
  json (2.7.2)
41
- language-ruby (0.9.0)
47
+ language-ruby (0.9.3)
48
+ dorian-arguments
42
49
  zeitwerk
43
50
  language_server-protocol (3.17.0.3)
44
51
  levenshtein (0.2.2)
@@ -53,7 +60,7 @@ GEM
53
60
  rainbow (3.1.1)
54
61
  rake (13.2.1)
55
62
  regexp_parser (2.9.2)
56
- rexml (3.3.5)
63
+ rexml (3.3.6)
57
64
  strscan
58
65
  rspec (3.13.0)
59
66
  rspec-core (~> 3.13.0)
@@ -61,7 +68,7 @@ GEM
61
68
  rspec-mocks (~> 3.13.0)
62
69
  rspec-core (3.13.0)
63
70
  rspec-support (~> 3.13.0)
64
- rspec-expectations (3.13.1)
71
+ rspec-expectations (3.13.2)
65
72
  diff-lcs (>= 1.2.0, < 2.0)
66
73
  rspec-support (~> 3.13.0)
67
74
  rspec-mocks (3.13.1)
@@ -87,10 +94,10 @@ GEM
87
94
  rubocop-performance (1.21.1)
88
95
  rubocop (>= 1.48.1, < 2.0)
89
96
  rubocop-ast (>= 1.31.1, < 2.0)
90
- rubocop-rails (2.25.1)
97
+ rubocop-rails (2.26.0)
91
98
  activesupport (>= 4.2.0)
92
99
  rack (>= 1.1)
93
- rubocop (>= 1.33.0, < 2.0)
100
+ rubocop (>= 1.52.0, < 2.0)
94
101
  rubocop-ast (>= 1.31.1, < 2.0)
95
102
  rubocop-rails-omakase (1.0.0)
96
103
  rubocop
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/code CHANGED
@@ -1,108 +1,71 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "optparse"
5
4
  require_relative "../lib/code-ruby"
6
-
7
- options = {
8
- timeout: 0,
9
- profile: false,
10
- profiler: "text",
11
- input: "",
12
- parse: false
13
- }
14
-
15
- argv =
16
- OptionParser
17
- .new do |opts|
18
- opts.banner = "Usage: code INPUT\n\n"
19
-
20
- opts.on("-v", "--version", "Version of Code") do |_input|
21
- puts Code::Version
22
- exit
23
- end
24
-
25
- opts.on(
26
- "-i INPUT",
27
- "--input INPUT",
28
- "Input in the Code language (String or File)"
29
- ) do |input|
30
- input = File.read(input) if File.exist?(input)
31
-
32
- options[:input] = input
33
- end
34
-
35
- opts.on("-p", "--parse", "Parser tree for input") do |parse|
36
- options[:parse] = parse
37
- end
38
-
39
- opts.on(
40
- "-t TIMEOUT",
41
- "--timeout TIMEOUT",
42
- "Set timeout in seconds"
43
- ) { |timeout| options[:timeout] = timeout.to_f }
44
-
45
- opts.on(
46
- "-z TIME_ZONE",
47
- "--time-zone TIME_ZONE",
48
- "Set time zone"
49
- ) { |time_zone| Time.zone = time_zone }
50
-
51
- opts.on("--profile", "Profile Ruby code") do |_timeout|
52
- require "ruby-prof"
53
- options[:profile] = true
54
- end
55
-
56
- opts.on(
57
- "--profiler TYPE",
58
- "Profiler output type (text (default) or html)"
59
- ) do |profiler|
60
- require "ruby-prof"
61
- options[:profile] = true
62
- options[:profiler] = profiler
63
- end
64
- end
65
- .parse!
66
-
67
- if options[:input].empty?
68
- options[:input] = argv.join(" ")
69
- options[:input] = File.read(options[:input]) if File.exist?(options[:input])
70
- end
71
-
72
- abort <<~HELP if options[:input].empty?
73
- Usage: code INPUT
74
-
75
- -v, --version Version of Code
76
- -i, --input INPUT Input in the Code language (String or File)
77
- -p, --parse Parser tree for input
78
- -t, --timeout TIMEOUT Set timeout in seconds
79
- --profile Profile Ruby code
80
- --profiler TYPE Profiler output type (text (default) or html)
81
- HELP
82
-
83
- RubyProf.start if options[:profile]
84
-
85
- if options[:parse]
86
- pp Code::Parser.parse(options[:input]).to_raw
5
+ require "dorian/arguments"
6
+
7
+ parsed =
8
+ Dorian::Arguments.parse(
9
+ input: {
10
+ type: :string,
11
+ alias: :i
12
+ },
13
+ parse: {
14
+ type: :boolean,
15
+ alias: :p
16
+ },
17
+ profile: :boolean,
18
+ profiler: :string,
19
+ timeout: {
20
+ type: :integer,
21
+ alias: :t
22
+ },
23
+ version: {
24
+ type: :boolean,
25
+ alias: :v
26
+ },
27
+ help: {
28
+ type: :boolean,
29
+ alias: :h
30
+ }
31
+ )
32
+
33
+ abort Code::Version.to_s if parsed.options.version
34
+ abort parsed.help if parsed.options.help
35
+
36
+ input = parsed.options.input.to_s
37
+ input = File.read(input) if File.exist?(input)
38
+ input += parsed.arguments.join(" ")
39
+ input += parsed.files.map { |file| File.read(file) }.join
40
+
41
+ abort parsed.help if input.empty?
42
+
43
+ profile = parsed.options.profile || !parsed.options.profiler.empty?
44
+ require "ruby-prof" if profile
45
+
46
+ RubyProf.start if profile
47
+
48
+ if parsed.options.parse
49
+ pp Code::Parser.parse(input).to_raw
87
50
  else
88
- print Code.evaluate(
89
- options[:input],
90
- output: $stdout,
91
- error: $stderr,
92
- timeout: options[:timeout]
93
- )
51
+ print(
52
+ Code.evaluate(
53
+ input,
54
+ output: $stdout,
55
+ error: $stderr,
56
+ timeout: parsed.options.timeout
57
+ )
58
+ )
94
59
  end
95
60
 
96
- if options[:profile]
61
+ if profile
97
62
  result = RubyProf.stop
98
63
 
99
- if options[:profiler] == "text"
100
- printer = RubyProf::FlatPrinter.new(result)
101
- printer.print($stdout)
102
- elsif options[:profiler] == "html"
64
+ if parsed.options.profiler == "html"
103
65
  printer = RubyProf::GraphHtmlPrinter.new(result)
104
66
  printer.print($stdout)
105
67
  else
106
- abort "#{options[:profiler]} not recognized"
68
+ printer = RubyProf::FlatPrinter.new(result)
69
+ printer.print($stdout)
107
70
  end
108
71
  end
data/code-ruby.gemspec CHANGED
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "English"
4
- require_relative "lib/code/version"
5
-
6
3
  Gem::Specification.new do |s|
7
4
  s.name = "code-ruby"
8
- s.version = ::Code::Version
5
+ s.version = File.read("VERSION").strip
9
6
  s.summary = "a programming language for the internet"
10
7
  s.description = s.summary
11
8
  s.authors = ["Dorian Marié"]
@@ -22,4 +19,5 @@ Gem::Specification.new do |s|
22
19
  s.add_dependency "json"
23
20
  s.add_dependency "language-ruby"
24
21
  s.add_dependency "zeitwerk"
22
+ s.add_dependency "dorian-arguments"
25
23
  end
data/lib/code/version.rb CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require_relative "../code"
4
4
 
5
- Code::Version = Gem::Version.new("0.15.15")
5
+ Code::Version =
6
+ Gem::Version.new(File.read(File.expand_path("../../../VERSION", __FILE__)))
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.15.15
4
+ version: 1.0.0
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-08-18 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dorian-arguments
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: a programming language for the internet
98
112
  email: dorian@dorianmarie.fr
99
113
  executables:
@@ -114,6 +128,7 @@ files:
114
128
  - LICENSE
115
129
  - README.md
116
130
  - Rakefile
131
+ - VERSION
117
132
  - bin/bundle-audit
118
133
  - bin/bundler-audit
119
134
  - bin/code