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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/eval +1 -1
  4. data/lib/dorian/eval.rb +18 -7
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd6d10903e8c43ae9f0fbd906a87d2e8d689f404efe3490af4444d00427a35a2
4
- data.tar.gz: 12ad8928f6052e1761174f6b8aeb242ce2b2e682dd8ff07f79896612d66c1524
3
+ metadata.gz: b21f0fd649da60ad757aee35c4cd37882238256ad3cce477d4ef091251958ce0
4
+ data.tar.gz: '08c67d23fabfcb66678e1527ec0743ce3e920162f1b947126384e2623bb3e928'
5
5
  SHA512:
6
- metadata.gz: afa0fb9a8bf3631d7ad589ae71917c276080be3224e8c7bcdca3bc64e2c5cc9f83c79a69537bfb672746e2163a0fc00625a4164f05513a6ca48edf284c71dcc2
7
- data.tar.gz: 13b97ad458f8ddc4577e733f930a2dc947d7f023455d5ac81b60e28805d369914ee40800d7be4ce816b91d292908e33789e17b0f9174729e02d09b42b526381e
6
+ metadata.gz: 28a5aa59bcb7da623d70f44094ab1c85fd49bee49aebaf84bed690227b044a040f20a30fbcfaea4a03a31ae2a5b460268a4834a21b52fd4889f5b80d98874ae4
7
+ data.tar.gz: 2cbb210c32dc52ef8dd9f46002f1e0b1d21f25293322174b0b634b71d27a076af9686d030e7d35088e2f8daf64be645998114f20ec2ed3ac7ef282beaf53a2ab
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/bin/eval CHANGED
@@ -39,7 +39,7 @@ parsed =
39
39
  abort parsed.help if parsed.options.help
40
40
 
41
41
  if parsed.options.version
42
- abort File.read(File.expand_path("../../VERSION", __FILE__))
42
+ abort File.read(File.expand_path("../VERSION", __dir__))
43
43
  end
44
44
 
45
45
  Dorian::Eval.eval(
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 << gets(read_out, color: :green, print: stdout?).to_s
44
- err << gets(read_err, color: :red, print: stderr?).to_s
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 = colorize? ? colorize_string(string, color) : string
103
- puts([prefix, string].join) if print
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
- [COLORS.fetch(color), string, COLORS.fetch(:reset)]
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.1.0
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-25 00:00:00.000000000 Z
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: '0'
37
+ version: 3.3.4
38
38
  required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="