code-ruby 0.9.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/code +20 -17
- data/lib/code/object/boolean.rb +5 -1
- data/lib/code/object/class.rb +1 -0
- data/lib/code/object/context.rb +2 -1
- data/lib/code/object/date.rb +2 -1
- data/lib/code/object/decimal.rb +1 -0
- data/lib/code/object/dictionary.rb +2 -1
- data/lib/code/object/duration.rb +1 -0
- data/lib/code/object/list.rb +1 -0
- data/lib/code/object/range.rb +1 -1
- data/lib/code/object/string.rb +1 -0
- data/lib/code/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbab52af883b6728dd2be14b84df672b911f542bc1b46e5f905be43acf1c0aed
|
4
|
+
data.tar.gz: 266bfadcff8f8deffc940f1a802d97a2dc5b89a189233eda6418f0e6939798b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2503a5d2bfe52eb270c81156dfa40fa535427ff2222748344669f27cd069da453eb5d2ea506f01af8f5e210e51f89eaa80de5d0558539d38a14d714393d5b7b5
|
7
|
+
data.tar.gz: 455729dce33fe36792986541c6c78d3e53fad319728f141568f51d13b989d0da648422c69cb623c9ab327679610150c0bf06eefc9caf0a740b86c3d5de79700a
|
data/bin/code
CHANGED
@@ -9,15 +9,14 @@ options = {
|
|
9
9
|
profile: false,
|
10
10
|
profiler: "text",
|
11
11
|
input: "",
|
12
|
-
context: "",
|
13
12
|
parse: false
|
14
13
|
}
|
15
14
|
|
16
|
-
OptionParser
|
15
|
+
argv = OptionParser
|
17
16
|
.new do |opts|
|
18
|
-
opts.banner = "Usage: code
|
17
|
+
opts.banner = "Usage: code INPUT\n\n"
|
19
18
|
|
20
|
-
opts.on("-v", "--version", "Version of
|
19
|
+
opts.on("-v", "--version", "Version of Code") do |_input|
|
21
20
|
puts Code::Version
|
22
21
|
exit
|
23
22
|
end
|
@@ -25,24 +24,14 @@ OptionParser
|
|
25
24
|
opts.on(
|
26
25
|
"-i INPUT",
|
27
26
|
"--input INPUT",
|
28
|
-
"Input in the
|
27
|
+
"Input in the Code language (String or File)"
|
29
28
|
) do |input|
|
30
29
|
input = File.read(input) if File.exist?(input)
|
31
30
|
|
32
31
|
options[:input] = input
|
33
32
|
end
|
34
33
|
|
35
|
-
opts.on(
|
36
|
-
"-c CONTEXT",
|
37
|
-
"--context CONTEXT",
|
38
|
-
"Context in the code language (String or File)"
|
39
|
-
) do |context|
|
40
|
-
context = File.read(context) if File.exist?(context)
|
41
|
-
|
42
|
-
options[:context] = context
|
43
|
-
end
|
44
|
-
|
45
|
-
opts.on("-p", "--parse", "Get parser results for input") do |parse|
|
34
|
+
opts.on("-p", "--parse", "Parser tree for input") do |parse|
|
46
35
|
options[:parse] = parse
|
47
36
|
end
|
48
37
|
|
@@ -68,6 +57,21 @@ OptionParser
|
|
68
57
|
end
|
69
58
|
.parse!
|
70
59
|
|
60
|
+
options[:input] = argv.join(" ") if options[:input].empty?
|
61
|
+
|
62
|
+
if options[:input].empty?
|
63
|
+
abort <<~HELP
|
64
|
+
Usage: code INPUT
|
65
|
+
|
66
|
+
-v, --version Version of Code
|
67
|
+
-i, --input INPUT Input in the Code language (String or File)
|
68
|
+
-p, --parse Parser tree for input
|
69
|
+
-t, --timeout TIMEOUT Set timeout in seconds
|
70
|
+
--profile Profile Ruby code
|
71
|
+
--profiler TYPE Profiler output type (text (default) or html)
|
72
|
+
HELP
|
73
|
+
end
|
74
|
+
|
71
75
|
RubyProf.start if options[:profile]
|
72
76
|
|
73
77
|
if options[:parse]
|
@@ -75,7 +79,6 @@ if options[:parse]
|
|
75
79
|
else
|
76
80
|
print Code.evaluate(
|
77
81
|
options[:input],
|
78
|
-
options[:context],
|
79
82
|
output: $stdout,
|
80
83
|
error: $stderr,
|
81
84
|
timeout: options[:timeout]
|
data/lib/code/object/boolean.rb
CHANGED
data/lib/code/object/class.rb
CHANGED
data/lib/code/object/context.rb
CHANGED
data/lib/code/object/date.rb
CHANGED
data/lib/code/object/decimal.rb
CHANGED
data/lib/code/object/duration.rb
CHANGED
data/lib/code/object/list.rb
CHANGED
data/lib/code/object/range.rb
CHANGED
data/lib/code/object/string.rb
CHANGED
data/lib/code/version.rb
CHANGED