atk_toolbox 0.0.129 → 0.0.130

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2f9360594ff9688633f537e595460ce9f4047ab4e7683a55453f4ddd852f702
4
- data.tar.gz: 85259724896a5f69ab8bc4ef16ffd859063d1658758d1f29f2988d6dc15aea0d
3
+ metadata.gz: b369f7ae82e59686f07304f57e859e8437c3b369ee59c7b8ee8885a0a1fc3d2d
4
+ data.tar.gz: d5e67cd57d72c8e42464158912f566266cee10cd23922ded50610f9b437f12eb
5
5
  SHA512:
6
- metadata.gz: 0f27efc85e09e207e15b78d465d8e56cb4a7ec4c7c9b6b46f7c431d0a5d62919e4b2c8b3a58ca38f34d924f3b00966f8bb511632bf1ac3498893c98eaddef3fe
7
- data.tar.gz: 468182f80cc8fe99b60a4b65188429698bf857342fbdf8997ee57bbe0eacd6bc65fb2e97269a2dcc7b733cfe5112c5d42c048d99ac3325db197a603ce3aaa62d
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
- # see https://github.com/piotrmurach/tty-prompt
20
- class TTY::Prompt
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
- class << (OS::CACHE = Object.new)
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 OS::CACHE::is_windows == nil
38
- OS::CACHE::is_windows = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
37
+ if CACHE::is_windows == nil
38
+ CACHE::is_windows = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
39
39
  end
40
- return OS::CACHE::is_windows
40
+ return CACHE::is_windows
41
41
  when 'mac'
42
- if OS::CACHE::is_mac == nil
43
- OS::CACHE::is_mac = (/darwin/ =~ RUBY_PLATFORM) != nil
42
+ if CACHE::is_mac == nil
43
+ CACHE::is_mac = (/darwin/ =~ RUBY_PLATFORM) != nil
44
44
  end
45
- return OS::CACHE::is_mac
45
+ return CACHE::is_mac
46
46
  when 'linux'
47
- if OS::CACHE::is_linux == nil
48
- OS::CACHE::is_linux = (not OS.is?(:windows)) && (not OS.is?(:mac))
47
+ if CACHE::is_linux == nil
48
+ CACHE::is_linux = (not OS.is?(:windows)) && (not OS.is?(:mac))
49
49
  end
50
- return OS::CACHE::is_linux
50
+ return CACHE::is_linux
51
51
  when 'unix'
52
- if OS::CACHE::is_unix == nil
53
- OS::CACHE::is_unix = not(OS.is?(:windows))
52
+ if CACHE::is_unix == nil
53
+ CACHE::is_unix = not(OS.is?(:windows))
54
54
  end
55
- return OS::CACHE::is_unix
55
+ return CACHE::is_unix
56
56
  when 'debian'
57
- if OS::CACHE::is_debian == nil
58
- OS::CACHE::is_debian = File.file?('/etc/debian_version')
57
+ if CACHE::is_debian == nil
58
+ CACHE::is_debian = File.file?('/etc/debian_version')
59
59
  end
60
- return OS::CACHE::is_debian
60
+ return CACHE::is_debian
61
61
  when 'ubuntu'
62
- if OS::CACHE::is_ubuntu == nil
63
- OS::CACHE::is_ubuntu = OS.has_command('lsb_release') && `lsb_release -a`.match(/Distributor ID:[\s\t]*Ubuntu/)
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 OS::CACHE::is_ubuntu
65
+ return CACHE::is_ubuntu
66
66
  end
67
67
  end
68
68
 
69
69
  def self.version
70
- return OS::CACHE::version if OS::CACHE::version != nil
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
- OS::CACHE::version = version
92
+ CACHE::version = version
93
93
  end
94
94
 
95
95
  def self.path_for_executable(name_of_executable)
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.129'
2
+ VERSION = '0.0.130'
3
3
  end
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.129
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 00:00:00.000000000 Z
11
+ date: 2020-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt