dorian-eval 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/eval +1 -1
- data/lib/dorian/eval.rb +18 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21f0fd649da60ad757aee35c4cd37882238256ad3cce477d4ef091251958ce0
|
4
|
+
data.tar.gz: '08c67d23fabfcb66678e1527ec0743ce3e920162f1b947126384e2623bb3e928'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a5aa59bcb7da623d70f44094ab1c85fd49bee49aebaf84bed690227b044a040f20a30fbcfaea4a03a31ae2a5b460268a4834a21b52fd4889f5b80d98874ae4
|
7
|
+
data.tar.gz: 2cbb210c32dc52ef8dd9f46002f1e0b1d21f25293322174b0b634b71d27a076af9686d030e7d35088e2f8daf64be645998114f20ec2ed3ac7ef282beaf53a2ab
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/bin/eval
CHANGED
data/lib/dorian/eval.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Dorian
|
2
4
|
class Eval
|
3
5
|
attr_reader :ruby, :it, :debug, :stdout, :stderr, :colorize, :rails
|
4
6
|
|
5
|
-
COLORS = { red: "\e[31m", green: "\e[32m", reset: "\e[0m" }
|
7
|
+
COLORS = { red: "\e[31m", green: "\e[32m", reset: "\e[0m" }.freeze
|
6
8
|
|
7
9
|
def initialize(
|
8
10
|
*args,
|
@@ -40,8 +42,8 @@ class Dorian
|
|
40
42
|
err = ""
|
41
43
|
|
42
44
|
while !read_out.eof? || !read_err.eof?
|
43
|
-
out
|
44
|
-
err
|
45
|
+
out += gets(read_out, print: stdout?, method: :puts).to_s
|
46
|
+
err += gets(read_err, color: :red, print: stderr?, method: :warn).to_s
|
45
47
|
end
|
46
48
|
|
47
49
|
[out, err]
|
@@ -95,17 +97,26 @@ class Dorian
|
|
95
97
|
)
|
96
98
|
end
|
97
99
|
|
98
|
-
def gets(read, color: nil, print: true)
|
100
|
+
def gets(read, color: nil, print: true, method: :puts)
|
99
101
|
original_string = read.gets
|
100
102
|
return unless original_string
|
103
|
+
|
101
104
|
string = original_string.rstrip
|
102
|
-
string =
|
103
|
-
|
105
|
+
string = colorize_string(string, color) if colorize? && color
|
106
|
+
|
107
|
+
if method == :puts && print
|
108
|
+
puts [prefix, string].join
|
109
|
+
elsif method == :warn && print
|
110
|
+
warn [prefix, string].join
|
111
|
+
end
|
112
|
+
|
104
113
|
original_string
|
105
114
|
end
|
106
115
|
|
107
116
|
def colorize_string(string, color)
|
108
|
-
|
117
|
+
return string unless color
|
118
|
+
|
119
|
+
[COLORS.fetch(color), string, COLORS.fetch(:reset)].join
|
109
120
|
end
|
110
121
|
end
|
111
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-eval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: evaluates ruby
|
14
14
|
email: dorian@dorianmarie.com
|
@@ -32,9 +32,9 @@ require_paths:
|
|
32
32
|
- lib
|
33
33
|
required_ruby_version: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 3.3.4
|
38
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|