toolrack 0.5.0 → 0.6.2

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: 9b1c1f58f027b8a0b847c9c196c2f2e74ba75f2df78595cb1024f06560bf8ee6
4
- data.tar.gz: bdbb04df325bf9f979de7497051267e6925ffc74c8a91c2e49008f03c1021401
3
+ metadata.gz: 91dc7e7717dc84f13f1cf0e7f3da03a68b6ed891d3900bd1b23abd5e8148734c
4
+ data.tar.gz: ff6f780710d0f7d7e21583e4a0c24e9e4508d02f089ca19d5f92f99e61773b7d
5
5
  SHA512:
6
- metadata.gz: 97627d8aba3e40cc3cba8f3fe3e0639f349001f548627267fca52d4ee820b8af027ebb33ae1dfff1b46f719b26d36d5aaaf4d2d7e392a918f59dc2bd4ec9e921
7
- data.tar.gz: 932804f41294d61ceaa32eec0bdb20a8e6eb32d9abb746861cf5591ab09b29aba2980ad3b4d0508d8d2881240d91e2a64d28d83a9552cca669f3fd54521a4c90
6
+ metadata.gz: c5ff196e18d97bdd54096490b5ab9450dd074ae31a6e59c15030772e16953e2e7f5b345bdd61a9caf51e7617b1727773edb244fa97cff1341c355644360b2769
7
+ data.tar.gz: 3358f972376beff09830a084019b9b4cb5fe8ef2adb3e7f29c376d5097e858c9ab137496b41a6ea1a4316ffdcad4eebb4c10edfb90358a713e98616a3d63bfc8
data/lib/toolrack.rb CHANGED
@@ -5,6 +5,7 @@ require 'singleton'
5
5
 
6
6
  require 'fileutils'
7
7
 
8
+ require_relative 'toolrack/global'
8
9
  require_relative 'toolrack/exception_utils'
9
10
  require_relative 'toolrack/condition_utils'
10
11
  require_relative 'toolrack/process_utils'
@@ -15,30 +16,9 @@ module Antrapol
15
16
  class Error < StandardError; end
16
17
  # Your code goes here...
17
18
 
18
- class Logger
19
- include Singleton
20
- include Antrapol::ToolRack::ConditionUtils
21
-
22
- attr_reader :glogger
23
- def initialize
24
- # boolean
25
- loggerDebug = ENV['TOOLRACK_DEBUG']
26
- logFile = ENV['TOOLRACK_LOGFILE'] || File.join(Dir.home, 'antrapol_logs','toolrack.log')
27
- maxLogNo = ENV['TOOLRACK_MAX_LOGFILE'] || 10
28
- logFileSize = ENV['TOOLRACK_MAX_LOGFILE_SIZE'] || 10*1024*1024
29
-
30
- logFileDir = File.dirname(logFile)
31
- if not File.exist?(logFileDir)
32
- FileUtils.mkdir_p(logFileDir)
33
- end
34
-
35
- if not_empty?(loggerDebug) and (loggerDebug.downcase == 'true')
36
- @glogger = Tlogger.new(STDOUT)
37
- else
38
- @glogger = Tlogger.new(logFile,maxLogNo,logFileSize)
39
- end
40
- end
41
- end
42
-
43
19
  end
44
20
  end
21
+
22
+ ToolRack = Antrapol::ToolRack
23
+
24
+
@@ -10,7 +10,11 @@ module Antrapol
10
10
  elsif obj.nil?
11
11
  true
12
12
  elsif obj.respond_to?(:empty?)
13
- obj.empty?
13
+ if obj.respond_to?(:strip)
14
+ obj.strip.empty?
15
+ else
16
+ obj.empty?
17
+ end
14
18
  else
15
19
  false
16
20
  end
@@ -20,6 +24,11 @@ module Antrapol
20
24
  !is_empty?(obj)
21
25
  end # not empty
22
26
 
27
+ def is_boolean?(val)
28
+ !!val == val
29
+ end
30
+ alias_method :is_bool?, :is_boolean?
31
+
23
32
  end # ConditionUtils
24
33
  end # MyToolRack
25
34
  end # Antrapol
@@ -0,0 +1,35 @@
1
+
2
+ require 'singleton'
3
+ require_relative 'condition_utils'
4
+
5
+ module Antrapol
6
+ module ToolRack
7
+
8
+ class Logger
9
+ include Singleton
10
+ include Antrapol::ToolRack::ConditionUtils
11
+
12
+ attr_reader :glogger
13
+ def initialize
14
+ # boolean
15
+ loggerDebug = ENV['TOOLRACK_DEBUG']
16
+ logFile = ENV['TOOLRACK_LOGFILE'] || File.join(Dir.home, 'antrapol_logs','toolrack.log')
17
+ maxLogNo = ENV['TOOLRACK_MAX_LOGFILE'] || 10
18
+ logFileSize = ENV['TOOLRACK_MAX_LOGFILE_SIZE'] || 10*1024*1024
19
+
20
+ logFileDir = File.dirname(logFile)
21
+ if not File.exist?(logFileDir)
22
+ FileUtils.mkdir_p(logFileDir)
23
+ end
24
+
25
+ if not_empty?(loggerDebug) and (loggerDebug.downcase == 'true')
26
+ @glogger = Tlogger.new(STDOUT)
27
+ else
28
+ @glogger = Tlogger.new(logFile,maxLogNo,logFileSize)
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+
@@ -1,11 +1,21 @@
1
1
 
2
- require 'pty'
2
+ require_relative 'global'
3
+ require_relative 'runtime_utils'
4
+
5
+ if Antrapol::ToolRack::RuntimeUtils.on_windows?
6
+ # pty causing "function 'openpty' not found in msvcrt.dll" in some
7
+ # windows platform. Due to patches?
8
+ Antrapol::ToolRack::Logger.instance.glogger.debug "On Windows. Not going to load gem 'pty'"
9
+ else
10
+ require 'pty'
11
+ end
3
12
  require 'expect'
4
13
  require 'io/console'
5
14
  require 'tlogger'
6
15
  require 'open3'
7
16
 
8
17
 
18
+
9
19
  module Antrapol
10
20
  module ToolRack
11
21
  module ProcessUtils
@@ -79,6 +89,11 @@ module Antrapol
79
89
 
80
90
  Antrapol::ToolRack::Logger.instance.glogger.debug "PTY exec command : #{cmd}"
81
91
 
92
+ # pty seems error running on windows + jruby
93
+ if Antrapol::ToolRack::RuntimeUtils.on_windows?
94
+ raise Exception, "You're running on Windows. There have been report that error \"function 'openpty' not found in msvcrt.dll\". Probably due to patches. For now pty_exec() shall be halted"
95
+ end
96
+
82
97
  logger = opts[:logger] || Tlogger.new(STDOUT)
83
98
  expect = opts[:expect] || { }
84
99
  bufSize = opts[:intBufSize] || 1024000
@@ -1,6 +1,6 @@
1
1
  module Antrapol
2
2
  module ToolRack
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.2"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toolrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tlogger
@@ -56,6 +56,7 @@ files:
56
56
  - lib/toolrack.rb
57
57
  - lib/toolrack/condition_utils.rb
58
58
  - lib/toolrack/exception_utils.rb
59
+ - lib/toolrack/global.rb
59
60
  - lib/toolrack/process_utils.rb
60
61
  - lib/toolrack/runtime_utils.rb
61
62
  - lib/toolrack/utils.rb
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  requirements: []
88
- rubygems_version: 3.1.2
89
+ rubygems_version: 3.2.22
89
90
  signing_key:
90
91
  specification_version: 4
91
92
  summary: Collection of simple utilities but I find it increase clarity