eac_ruby_utils 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc288c5822f1c0981eb007a0ac8398e0d06e8355b39a1f2aa7a5dbf12fb9e2b
|
4
|
+
data.tar.gz: 7aa562293120d2e8da628bf6d471f7ec23416c9b49f03b8a2205881c6fd166c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30eed73757ef9d54ee35f35f1b9753c43b543959760c2fe1320dd8fb81b0f30a912b991b0066d8b6cfc9d062a0d65a7bc31325d46067c066ac876a6cf8863b5
|
7
|
+
data.tar.gz: 48d825385999066c7b1b366e5f47d934069e5b8f7fb272e4a5805645bbf4a2c88c4506be462666e204a993b276423c1867f8e9e30b23f710d80c9c5d7d6fe3f8
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/speaker/node'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
module Speaker
|
8
|
+
class << self
|
9
|
+
def current_node
|
10
|
+
nodes_stack.last
|
11
|
+
end
|
12
|
+
|
13
|
+
def push
|
14
|
+
nodes_stack << ::EacRubyUtils::Console::Speaker::Node.new
|
15
|
+
current_node
|
16
|
+
end
|
17
|
+
|
18
|
+
def pop
|
19
|
+
return nodes_stack.pop if nodes_stack.count > 1
|
20
|
+
raise "Cannot remove first node (nodes_stack.count: #{nodes_stack.count})"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def nodes_stack
|
26
|
+
@nodes_stack ||= [::EacRubyUtils::Console::Speaker::Node.new]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
module Speaker
|
8
|
+
class Node
|
9
|
+
attr_accessor :stdin, :stdout, :stderr
|
10
|
+
|
11
|
+
def initialize(parent = nil)
|
12
|
+
self.stdin = parent.if_present(STDIN, &:stdin)
|
13
|
+
self.stdout = parent.if_present(STDOUT, &:stdout)
|
14
|
+
self.stderr = parent.if_present(STDERR, &:stderr)
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield(self)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,18 +3,20 @@
|
|
3
3
|
require 'colorize'
|
4
4
|
require 'io/console'
|
5
5
|
require 'eac_ruby_utils/options_consumer'
|
6
|
+
require 'eac_ruby_utils/console/speaker/_class_methods'
|
6
7
|
require 'eac_ruby_utils/console/speaker/list'
|
8
|
+
require 'eac_ruby_utils/console/speaker/node'
|
7
9
|
|
8
10
|
module EacRubyUtils
|
9
11
|
module Console
|
10
12
|
# https://github.com/fazibear/colorize
|
11
13
|
module Speaker
|
12
14
|
def puts(string = '')
|
13
|
-
|
15
|
+
current_node.stderr.puts(string.to_s)
|
14
16
|
end
|
15
17
|
|
16
18
|
def out(string = '')
|
17
|
-
|
19
|
+
current_node.stdout.write(string.to_s)
|
18
20
|
end
|
19
21
|
|
20
22
|
def fatal_error(string)
|
@@ -102,15 +104,19 @@ module EacRubyUtils
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def request_string(question, noecho)
|
105
|
-
|
107
|
+
current_node.stderr.write "#{question}: ".to_s.yellow
|
106
108
|
if noecho
|
107
|
-
r =
|
108
|
-
|
109
|
+
r = current_node.stdin.noecho(&:gets).chomp.strip
|
110
|
+
current_node.stderr.write("\n")
|
109
111
|
r
|
110
112
|
else
|
111
|
-
|
113
|
+
current_node.stdin.gets.chomp.strip
|
112
114
|
end
|
113
115
|
end
|
116
|
+
|
117
|
+
def current_node
|
118
|
+
::EacRubyUtils::Console::Speaker.current_node
|
119
|
+
end
|
114
120
|
end
|
115
121
|
end
|
116
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -126,7 +126,9 @@ files:
|
|
126
126
|
- lib/eac_ruby_utils/console/docopt_runner/_settings.rb
|
127
127
|
- lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb
|
128
128
|
- lib/eac_ruby_utils/console/speaker.rb
|
129
|
+
- lib/eac_ruby_utils/console/speaker/_class_methods.rb
|
129
130
|
- lib/eac_ruby_utils/console/speaker/list.rb
|
131
|
+
- lib/eac_ruby_utils/console/speaker/node.rb
|
130
132
|
- lib/eac_ruby_utils/contextualizable.rb
|
131
133
|
- lib/eac_ruby_utils/core_ext.rb
|
132
134
|
- lib/eac_ruby_utils/envs.rb
|