atk_toolbox 0.0.103 → 0.0.104
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 +4 -4
- data/lib/atk/os.rb +56 -11
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a6d59658071c79365f3123c13fea6f273b40e5bbed9c5f72043d6361a0a630
|
4
|
+
data.tar.gz: 64064bdc88621871c55c26cfc9471de3234703c9d7111303b3464e9f79065c6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769fdbdc25e60ca4cb623ee49e54b8c9f54da4947fb4ca74c635661488c3b7a72a161f85737e9893eec46cb1012417aba1d3230747532a0532ac96489a75449d
|
7
|
+
data.tar.gz: e2acfbfeec69c4cfa3a38308b18908454486995f401526bb1605fdcf988226e685b3840411d8770f878f45d7bbe385bdf1bb3db1b7bc556f487a029679549de3
|
data/lib/atk/os.rb
CHANGED
@@ -43,6 +43,20 @@ os_heirarchy = {
|
|
43
43
|
"android" => {},
|
44
44
|
}
|
45
45
|
|
46
|
+
# this statment was extracted from the ptools gem, credit should go to them
|
47
|
+
# https://github.com/djberg96/ptools/blob/master/lib/ptools.rb
|
48
|
+
# The WIN32EXTS string is used as part of a Dir[] call in certain methods.
|
49
|
+
if File::ALT_SEPARATOR
|
50
|
+
MSWINDOWS = true
|
51
|
+
if ENV['PATHEXT']
|
52
|
+
WIN32EXTS = ('.{' + ENV['PATHEXT'].tr(';', ',').tr('.','') + '}').downcase
|
53
|
+
else
|
54
|
+
WIN32EXTS = '.{exe,com,bat}'
|
55
|
+
end
|
56
|
+
else
|
57
|
+
MSWINDOWS = false
|
58
|
+
end
|
59
|
+
|
46
60
|
# TODO: look into using https://github.com/piotrmurach/tty-platform
|
47
61
|
|
48
62
|
#
|
@@ -105,21 +119,52 @@ module OS
|
|
105
119
|
end
|
106
120
|
|
107
121
|
def self.path_for_executable(name_of_executable)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
122
|
+
# this method was extracted from the ptools gem, credit should go to them
|
123
|
+
# https://github.com/djberg96/ptools/blob/master/lib/ptools.rb
|
124
|
+
# this complex method is in favor of just calling the command line because command line calls are slow
|
125
|
+
path=ENV['PATH']
|
126
|
+
if path.nil? || path.empty?
|
127
|
+
raise ArgumentError, "path cannot be empty"
|
128
|
+
end
|
129
|
+
|
130
|
+
# Bail out early if an absolute path is provided.
|
131
|
+
if program =~ /^\/|^[a-z]:[\\\/]/i
|
132
|
+
program += WIN32EXTS if MSWINDOWS && File.extname(program).empty?
|
133
|
+
found = Dir[program].first
|
134
|
+
if found && File.executable?(found) && !File.directory?(found)
|
135
|
+
return found
|
136
|
+
else
|
137
|
+
return nil
|
115
138
|
end
|
116
|
-
return output
|
117
|
-
else
|
118
|
-
return `which '#{name_of_executable}'`.strip
|
119
139
|
end
|
140
|
+
|
141
|
+
# Iterate over each path glob the dir + program.
|
142
|
+
path.split(File::PATH_SEPARATOR).each{ |dir|
|
143
|
+
dir = File.expand_path(dir)
|
144
|
+
|
145
|
+
next unless File.exist?(dir) # In case of bogus second argument
|
146
|
+
file = File.join(dir, program)
|
147
|
+
|
148
|
+
# Dir[] doesn't handle backslashes properly, so convert them. Also, if
|
149
|
+
# the program name doesn't have an extension, try them all.
|
150
|
+
if MSWINDOWS
|
151
|
+
file = file.tr("\\", "/")
|
152
|
+
file += WIN32EXTS if File.extname(program).empty?
|
153
|
+
end
|
154
|
+
|
155
|
+
found = Dir[file].first
|
156
|
+
|
157
|
+
# Convert all forward slashes to backslashes if supported
|
158
|
+
if found && File.executable?(found) && !File.directory?(found)
|
159
|
+
found.tr!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
160
|
+
return found
|
161
|
+
end
|
162
|
+
}
|
163
|
+
|
164
|
+
return nil
|
120
165
|
end
|
121
166
|
|
122
167
|
def self.has_command(name_of_executable)
|
123
|
-
return OS.path_for_executable(name_of_executable) !=
|
168
|
+
return OS.path_for_executable(name_of_executable) != nil
|
124
169
|
end
|
125
170
|
end
|
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.104
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zip
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.7.
|
138
|
+
rubygems_version: 2.7.6.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: The Ruby gem for all the standard tools ATK uses internally
|