atk_toolbox 0.0.129 → 0.0.130
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atk/console.rb +33 -6
- data/lib/atk/os.rb +22 -22
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b369f7ae82e59686f07304f57e859e8437c3b369ee59c7b8ee8885a0a1fc3d2d
|
4
|
+
data.tar.gz: d5e67cd57d72c8e42464158912f566266cee10cd23922ded50610f9b437f12eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b7cb087906053a8523a2b185239ded611a0b908a20d85ae5a91d62fec8cb6dcda3e32919e0e7ada286bda483dbe114bdae658c87646d9cd124023c189816389
|
7
|
+
data.tar.gz: a579e2622583111e1a6abecba07c4002ec7f4f5be99ddc2adfe08f5da64c33e75c15ddaa7c9b4698a53cdc2ff537acbe3aeee8319a02fe442a48abdc7faa7209
|
data/lib/atk/console.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "tty-prompt"
|
2
1
|
require_relative "./os.rb"
|
3
2
|
require_relative "../console_colors.rb"
|
4
3
|
|
@@ -16,9 +15,39 @@ end
|
|
16
15
|
#
|
17
16
|
# Console
|
18
17
|
#
|
19
|
-
|
20
|
-
|
18
|
+
Console = Class.new do
|
19
|
+
|
20
|
+
CACHE = Class.new do
|
21
|
+
attr_accessor :prompt
|
22
|
+
end.new
|
23
|
+
|
24
|
+
#
|
25
|
+
# prompt properties
|
26
|
+
#
|
27
|
+
# see https://github.com/piotrmurach/tty-prompt
|
28
|
+
def _load_prompt
|
29
|
+
require "tty-prompt"
|
30
|
+
CACHE::prompt = TTY::Prompt.new
|
31
|
+
end
|
32
|
+
# generate interface for TTY prompt with lazy require
|
33
|
+
for each in [ :ask, :keypress, :multiline, :mask, :yes?, :no?, :select, :multi_select, :enum_select, :expand, :collect, :suggest, :slider, :say, :ok, :warn, :error, :on ]
|
34
|
+
eval(<<-HEREDOC)
|
35
|
+
def #{each}(*args, **kwargs)
|
36
|
+
self._load_prompt() if CACHE::prompt == nil
|
37
|
+
if block_given?
|
38
|
+
CACHE::prompt.#{each}(*args, **kwargs) do |*block_args, **block_kwargs|
|
39
|
+
yield(*block_args, **block_kwargs)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
CACHE::prompt.#{each}(*args, **kwargs)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
HEREDOC
|
46
|
+
end
|
47
|
+
|
48
|
+
|
21
49
|
attr_accessor :verbose
|
50
|
+
|
22
51
|
def _save_args
|
23
52
|
if @args == nil
|
24
53
|
@args = []
|
@@ -150,9 +179,7 @@ class TTY::Prompt
|
|
150
179
|
end
|
151
180
|
end
|
152
181
|
end
|
153
|
-
end
|
154
|
-
|
155
|
-
Console = TTY::Prompt.new
|
182
|
+
end.new
|
156
183
|
|
157
184
|
def log(*args)
|
158
185
|
if Console.verbose
|
data/lib/atk/os.rb
CHANGED
@@ -22,9 +22,9 @@ end
|
|
22
22
|
module OS
|
23
23
|
|
24
24
|
# create a singleton class
|
25
|
-
|
25
|
+
CACHE = Class.new do
|
26
26
|
attr_accessor :is_windows, :is_mac, :is_linux, :is_unix, :is_debian, :is_ubuntu, :version
|
27
|
-
end
|
27
|
+
end.new
|
28
28
|
|
29
29
|
def self.is?(adjective)
|
30
30
|
# summary:
|
@@ -34,40 +34,40 @@ module OS
|
|
34
34
|
adjective = adjective.to_s.downcase
|
35
35
|
case adjective
|
36
36
|
when 'windows'
|
37
|
-
if
|
38
|
-
|
37
|
+
if CACHE::is_windows == nil
|
38
|
+
CACHE::is_windows = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
39
39
|
end
|
40
|
-
return
|
40
|
+
return CACHE::is_windows
|
41
41
|
when 'mac'
|
42
|
-
if
|
43
|
-
|
42
|
+
if CACHE::is_mac == nil
|
43
|
+
CACHE::is_mac = (/darwin/ =~ RUBY_PLATFORM) != nil
|
44
44
|
end
|
45
|
-
return
|
45
|
+
return CACHE::is_mac
|
46
46
|
when 'linux'
|
47
|
-
if
|
48
|
-
|
47
|
+
if CACHE::is_linux == nil
|
48
|
+
CACHE::is_linux = (not OS.is?(:windows)) && (not OS.is?(:mac))
|
49
49
|
end
|
50
|
-
return
|
50
|
+
return CACHE::is_linux
|
51
51
|
when 'unix'
|
52
|
-
if
|
53
|
-
|
52
|
+
if CACHE::is_unix == nil
|
53
|
+
CACHE::is_unix = not(OS.is?(:windows))
|
54
54
|
end
|
55
|
-
return
|
55
|
+
return CACHE::is_unix
|
56
56
|
when 'debian'
|
57
|
-
if
|
58
|
-
|
57
|
+
if CACHE::is_debian == nil
|
58
|
+
CACHE::is_debian = File.file?('/etc/debian_version')
|
59
59
|
end
|
60
|
-
return
|
60
|
+
return CACHE::is_debian
|
61
61
|
when 'ubuntu'
|
62
|
-
if
|
63
|
-
|
62
|
+
if CACHE::is_ubuntu == nil
|
63
|
+
CACHE::is_ubuntu = OS.has_command('lsb_release') && `lsb_release -a`.match(/Distributor ID:[\s\t]*Ubuntu/)
|
64
64
|
end
|
65
|
-
return
|
65
|
+
return CACHE::is_ubuntu
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.version
|
70
|
-
return
|
70
|
+
return CACHE::version if CACHE::version != nil
|
71
71
|
# these statements need to be done in order from least to greatest
|
72
72
|
if OS.is?("ubuntu")
|
73
73
|
version_info = `lsb_release -a`
|
@@ -89,7 +89,7 @@ module OS
|
|
89
89
|
elsif OS.is?('windows')
|
90
90
|
version = nil
|
91
91
|
end
|
92
|
-
|
92
|
+
CACHE::version = version
|
93
93
|
end
|
94
94
|
|
95
95
|
def self.path_for_executable(name_of_executable)
|
data/lib/atk_toolbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atk_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.130
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|