atk_toolbox 0.0.104 → 0.0.105
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/set_command.rb +31 -23
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0227d1d4c7c02fb3fd5b05488dc8427a00842510cc6aca8fd2334461db7992
|
4
|
+
data.tar.gz: 4f2d3a17a04671ba81034e58d039fe236d619bdcaaa30d075f55f4cad55630dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2026e33762fff5627d8cef175babdca7134a3d26cc190453db36209ab53cebaf15ed1f96b312a71939c9ad8f7dbb2b2dd6a74a41d99e6d901f466b484c0cac
|
7
|
+
data.tar.gz: 2dc8daf6aa386bd54c0bbb16b70d0012e717afd54afa9540611c40d8c328f1c38c3244bb7ecdf065bc6a77319cbed88170c2c7a44c086443bdaccb3dd943ba0c
|
data/lib/atk/set_command.rb
CHANGED
@@ -2,29 +2,37 @@ require_relative './file_sys'
|
|
2
2
|
require_relative './os'
|
3
3
|
require_relative './atk_info'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
# the reason this isn't inside of the console.rb
|
6
|
+
# is because atk_info requires console
|
7
|
+
# and this requires atk_info
|
8
|
+
# which would cause a circular dependency
|
9
|
+
|
10
|
+
# add set_command to the Console
|
11
|
+
class TTY::Prompt
|
12
|
+
def set_command(name, code)
|
13
|
+
if OS.is?("unix")
|
14
|
+
exec_path = "/usr/local/bin/#{name}"
|
15
|
+
local_place = ATK.temp_path(name)
|
16
|
+
# add the hash bang
|
17
|
+
hash_bang = "#!#{ATK.paths[:ruby]}\n"
|
18
|
+
# create the file
|
19
|
+
FS.write(hash_bang+code, to: local_place)
|
20
|
+
# copy to command folder
|
21
|
+
system("sudo", "cp", local_place, exec_path)
|
22
|
+
system("sudo", "chmod", "ugo+x", exec_path)
|
23
|
+
elsif OS.is?("windows")
|
24
|
+
# check for invalid file paths, see https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
25
|
+
if name =~ /[><:"\/\\|?*]/
|
26
|
+
puts "Sorry #{name} isn't a valid file path on windows"
|
27
|
+
return ""
|
28
|
+
end
|
29
|
+
username = FS.username
|
30
|
+
exec_path = "C:\\Users\\#{username}\\AppData\\local\\Microsoft\\WindowsApps\\#{name}"
|
31
|
+
|
32
|
+
# create the code
|
33
|
+
IO.write(exec_path+".rb", code)
|
34
|
+
# create an executable to call the code
|
35
|
+
IO.write(exec_path+".bat", "@echo off\nruby \"#{exec_path}.rb\" %*")
|
21
36
|
end
|
22
|
-
username = FS.username
|
23
|
-
exec_path = "C:\\Users\\#{username}\\AppData\\local\\Microsoft\\WindowsApps\\#{name}"
|
24
|
-
|
25
|
-
# create the code
|
26
|
-
IO.write(exec_path+".rb", code)
|
27
|
-
# create an executable to call the code
|
28
|
-
IO.write(exec_path+".bat", "@echo off\nruby \"#{exec_path}.rb\" %*")
|
29
37
|
end
|
30
38
|
end
|
data/lib/atk_toolbox/version.rb
CHANGED