toolrack 0.3.0 → 0.4.0

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: 9695907a18e7af223dc46afdede9aadf6a63860cd85600eac575d1707f92122a
4
- data.tar.gz: 33b7a5e328a97b336f75d74e87adfd11c9d2e4e4db65096db9657cbc8d438a3b
3
+ metadata.gz: 1a314f6fdcefecc70740c69187204bcdcf16924ee2bf13845831a0f67cf5c357
4
+ data.tar.gz: 3127b384041d20294eccc27335f0996825232d69dc3c6ac0c0d6035d0feab9e9
5
5
  SHA512:
6
- metadata.gz: ed2140ad2e0ddd44977b8375e02f4d81ce30e2c5c3c8ade312d0ebb24213373d38783a3f509994f23bb866977d74825e42f8ea585f78a1bd64afdb24d017294c
7
- data.tar.gz: ec78c82697275f8ad85900892a017dfe0be6edbc5a19f761d382d53dcf372c9f3c68f7d7bb4678b7af02d25a77346f2ba082c6d099d002ac563c9173fb40d8d3
6
+ metadata.gz: 48ce83ab6d84b1aea27f6743d4330f6849bd09da2316f695250ebdab376bc29722cbdc5667ee13e4a7dbe22aa0f95685d4bff959274b7f03339019c50479038f
7
+ data.tar.gz: 1be997f86cd433d3a9d02c5ffe2bc5dae517bb3d9ac62fe1e91787ed7a07dc75e2deb6b05d94af0c411a05644fb235859c89434f9791a2f41e65cce1bb353566
@@ -5,7 +5,7 @@ require 'singleton'
5
5
 
6
6
  require_relative 'toolrack/exception_utils'
7
7
  require_relative 'toolrack/condition_utils'
8
- #require_relative 'toolrack/process_utils'
8
+ require_relative 'toolrack/process_utils'
9
9
  require_relative 'toolrack/runtime_utils'
10
10
 
11
11
  module Antrapol
@@ -10,6 +10,34 @@ module Antrapol
10
10
  module ToolRack
11
11
  module ProcessUtils
12
12
 
13
+ def exec(cmd, opts = { }, &block)
14
+ type = opts[:exec_type]
15
+ if not type.nil?
16
+ exec2(type, cmd, opts, &block)
17
+ else
18
+ exec2(:basic, cmd, opts, &block)
19
+ end
20
+ end
21
+
22
+ def exec2(type, cmd, opts = { }, &block)
23
+ case type
24
+ when :basic
25
+ Antrapol::ToolRack::Logger.instance.glogger.debug "Basic execution"
26
+ basic_exec(cmd)
27
+ when :system
28
+ Antrapol::ToolRack::Logger.instance.glogger.debug "System execution"
29
+ system_exec(cmd, opts, &block)
30
+ when :popen3
31
+ Antrapol::ToolRack::Logger.instance.glogger.debug "Popen3 execution"
32
+ popen3_exec(cmd, opts, &block)
33
+ else
34
+ Antrapol::ToolRack::Logger.instance.glogger.debug "Basic (fallback) execution"
35
+ # basic
36
+ basic_exec(cmd)
37
+ end
38
+ end
39
+
40
+ private
13
41
  # backtick
14
42
  # backtick will only return at the end of the process.
15
43
  # If in the event there is a prompt to user, this should nto be used.
@@ -4,21 +4,26 @@ module Antrapol
4
4
  module ToolRack
5
5
  module RuntimeUtils
6
6
 
7
- def detect_os
8
- case RbConfig::CONFIG['host_os']
9
- when /cygwin|mswin|mingw|bccwin|wince|emx/
10
- :win
11
- when /darwin|mac/
12
- :mac
13
- else
14
- :linux
15
- end
7
+ def RuntimeUtils.on_window?
8
+ (RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
16
9
  end
17
10
 
18
- def detect_ruby
19
-
11
+ def RuntimeUtils.on_mac?
12
+ (RbConfig::CONFIG['host_os'] =~ /darwin|mac/) != nil
20
13
  end
21
14
 
22
- end
23
- end
24
- end
15
+ def RuntimeUtils.on_linux?
16
+ (RbConfig::CONFIG['host_os'] =~ /linux/) != nil
17
+ end
18
+
19
+ def RuntimeUtils.on_ruby?
20
+ not on_jruby?
21
+ end
22
+
23
+ def RuntimeUtils.on_jruby?
24
+ (RUBY_PLATFORM =~ /java/) != nil
25
+ end
26
+
27
+ end # RuntimeUtils
28
+ end # ToolRack
29
+ end #Antrapol
@@ -1,6 +1,6 @@
1
1
  module Antrapol
2
2
  module ToolRack
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tlogger
@@ -55,7 +55,7 @@ licenses: []
55
55
  metadata:
56
56
  homepage_uri: https://github.com/chrisliaw/toolrack
57
57
  source_code_uri: https://github.com/chrisliaw/toolrack
58
- post_install_message:
58
+ post_install_message:
59
59
  rdoc_options: []
60
60
  require_paths:
61
61
  - lib
@@ -70,8 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.1.4
74
- signing_key:
73
+ rubygems_version: 3.1.2
74
+ signing_key:
75
75
  specification_version: 4
76
76
  summary: Collection of simple utilities but I find it increase clarity
77
77
  test_files: []