dorian-eval 1.1.0 → 1.1.1

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.
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: bcfc5e74c01f95c84c211b93c2d0a581ed989a5985d4e8432350073a6811777f
4
+ data.tar.gz: b6e28dff4e13d842b53997cb3b00931ebbe2272b2f0bab9ebd7fd91fcb43a18a
5
5
  SHA512:
6
- metadata.gz: afa0fb9a8bf3631d7ad589ae71917c276080be3224e8c7bcdca3bc64e2c5cc9f83c79a69537bfb672746e2163a0fc00625a4164f05513a6ca48edf284c71dcc2
7
- data.tar.gz: 13b97ad458f8ddc4577e733f930a2dc947d7f023455d5ac81b60e28805d369914ee40800d7be4ce816b91d292908e33789e17b0f9174729e02d09b42b526381e
6
+ metadata.gz: 41b97220af4b806ba42f40b54262d947d075367737392cc49b685748080fe12d7d0030307466a122adf2eafc1375bdd4b631672d181c6344858c99a00ed6961c
7
+ data.tar.gz: 8b9728add481168d18ad811780560def8c2b26cc8001b65a6472d46acfa69d6edaed8b5985d117632fee71ad4581786427a89a95bf52c0c4bb2ab29abde45b1a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
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.1.1
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
  - - ">="