atk_toolbox 0.0.144 → 0.0.149
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atk/atk_info.rb +19 -12
- data/lib/atk/autocomplete.rb +27 -0
- data/lib/atk/console.rb +12 -5
- data/lib/atk/file_system.rb +56 -7
- data/lib/atk/info.rb +1 -1
- data/lib/atk_toolbox.rb +2 -0
- data/lib/atk_toolbox/version.rb +1 -1
- data/lib/console_colors.rb +1 -1
- metadata +26 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b9a32f87edded3b92b2ea5031d206ea3e5c1f5d9f5165198208311c89a36ce
|
4
|
+
data.tar.gz: d9f84cee2603bf05a4088713853192c6ac5e09174a05a9544d8745193d73803a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deadbf426848a59eb9d9ecaa411ecf82d5948ced1b42e634b78a07fc9b9af741b6c31cff8c81a3e5d95e95cb9e11449749596f787190fb750ee91a037645b9bd
|
7
|
+
data.tar.gz: 6f2c45e3eae9ffa1d8260089263655d84ed821c7410639723cce983c67410db7b319d684178feabc0c1ebc7c8588122b13e1a0a644c9556f74a5a39da82eaa6b
|
data/lib/atk/atk_info.rb
CHANGED
@@ -33,7 +33,11 @@ class AtkPaths
|
|
33
33
|
end
|
34
34
|
return ruby_path
|
35
35
|
when 'gem'
|
36
|
-
|
36
|
+
gem_path = AtkPaths["ruby"].sub(/\/ruby$/,"\/gem")
|
37
|
+
if FS.file?(gem_path)
|
38
|
+
return gem_path
|
39
|
+
end
|
40
|
+
# FUTURE: this should eventually have better error handling
|
37
41
|
return OS.path_for_executable("gem")
|
38
42
|
when 'repos'
|
39
43
|
return HOME/"atk"/"repos"
|
@@ -103,7 +107,7 @@ module Atk
|
|
103
107
|
errors = {}
|
104
108
|
|
105
109
|
# make sure ruby is the corrct version
|
106
|
-
if VERSION_OF_RUBY >= Version.new("
|
110
|
+
if VERSION_OF_RUBY >= Version.new("2.6.0")
|
107
111
|
errors[:ruby_version_too_high] = true
|
108
112
|
elsif VERSION_OF_RUBY < Version.new("2.5")
|
109
113
|
errors[:ruby_version_too_low] = true
|
@@ -138,7 +142,10 @@ module Atk
|
|
138
142
|
#
|
139
143
|
# TODO: talk about any found errors
|
140
144
|
#
|
141
|
-
|
145
|
+
if errors.include?[:ruby_version_too_high]
|
146
|
+
puts "It looks like your ruby version is too high for ATK"
|
147
|
+
puts "some parts of ATK might still work, however expect it to be broken"
|
148
|
+
end
|
142
149
|
end
|
143
150
|
|
144
151
|
def self.setup(package_name, arguments)
|
@@ -398,25 +405,25 @@ class AtkPackage
|
|
398
405
|
|
399
406
|
if @dont_exist[:yaml_file]
|
400
407
|
custom_message += <<-HEREDOC.remove_indent
|
401
|
-
#{bad
|
408
|
+
#{bad["there was no info.yaml for that package"]}
|
402
409
|
and an info.yaml is the location for defining a run action
|
403
410
|
|
404
411
|
HEREDOC
|
405
412
|
elsif @dont_exist[:correctly_formatted_yaml_file]
|
406
413
|
custom_message += <<-HEREDOC.remove_indent
|
407
|
-
#{good
|
408
|
-
#{bad
|
414
|
+
#{good["there was a info.yaml for that package"]}
|
415
|
+
#{bad["the info.yaml is not parseable"]}
|
409
416
|
and an info.yaml is the location for defining a run action
|
410
417
|
|
411
418
|
HEREDOC
|
412
419
|
elsif @dont_exist[:using_atk_version]
|
413
420
|
custom_message += <<-HEREDOC.remove_indent
|
414
|
-
#{good
|
415
|
-
#{good
|
416
|
-
#{@dont_exist[:using_atk_version] && bad
|
417
|
-
#{@dont_exist[:package_info] && bad
|
418
|
-
#{@dont_exist[:actions] && bad
|
419
|
-
#{@dont_exist[:run_action] && bad
|
421
|
+
#{good["there was a info.yaml for that package"]}
|
422
|
+
#{good["the info.yaml was parseable"]}
|
423
|
+
#{@dont_exist[:using_atk_version] && bad["the info.yaml didn't have a (using_atk_version) key"]}
|
424
|
+
#{@dont_exist[:package_info] && bad["the info.yaml didn't have a (package_info) key"]}
|
425
|
+
#{@dont_exist[:actions] && bad["the info.yaml didn't have a (package_info): (actions) key"]}
|
426
|
+
#{@dont_exist[:run_action] && bad["the info.yaml didn't have a (package_info): (actions): (run) key"]}
|
420
427
|
HEREDOC
|
421
428
|
end
|
422
429
|
|
data/lib/atk/autocomplete.rb
CHANGED
@@ -10,4 +10,31 @@ module Atk
|
|
10
10
|
# end
|
11
11
|
# end
|
12
12
|
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# zsh autocomplete
|
16
|
+
#
|
17
|
+
#compdef _
|
18
|
+
|
19
|
+
# _atk()
|
20
|
+
# {
|
21
|
+
# orig_words=( ${words[@]} )
|
22
|
+
# local comp_words="${COMP_WORDS[1]}"
|
23
|
+
# local comp_cword="${COMP_CWORD}"
|
24
|
+
# local mylist="$( ruby -e '
|
25
|
+
# require "yaml"
|
26
|
+
# class Nil ; def [](); end; end;
|
27
|
+
# if ARGV.length == 2
|
28
|
+
# puts YAML.load_file("./info.yaml")["(project)"]["(commands)"].keys.map{|each| each.inspect}
|
29
|
+
# else
|
30
|
+
# # puts `ls`
|
31
|
+
# end
|
32
|
+
# ' $orig_words
|
33
|
+
# )"
|
34
|
+
# COMPREPLY=($(compgen -W $mylist) )
|
35
|
+
# _alternative "arguments:custom arg:(($mylist))"
|
36
|
+
# }
|
37
|
+
|
38
|
+
# complete -F _atk _
|
39
|
+
# compdef _atk _
|
13
40
|
end
|
data/lib/atk/console.rb
CHANGED
@@ -3,10 +3,12 @@ require_relative "../console_colors.rb"
|
|
3
3
|
require_relative "./remove_indent.rb"
|
4
4
|
|
5
5
|
# easy access to the commandline
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module Atk
|
7
|
+
refine String do
|
8
|
+
# add a - operator to strings that makes it behave like a system() call
|
9
|
+
def -@
|
10
|
+
return system(self)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
@@ -63,7 +65,7 @@ Console = Class.new do
|
|
63
65
|
CACHE::prompt = TTY::Prompt.new
|
64
66
|
end
|
65
67
|
# generate interface for TTY prompt with lazy require
|
66
|
-
for each in [ :ask, :keypress, :multiline, :mask, :yes?, :no?, :select, :multi_select, :enum_select, :expand, :collect, :suggest, :slider, :say, :
|
68
|
+
for each in [ :ask, :keypress, :multiline, :mask, :yes?, :no?, :select, :multi_select, :enum_select, :expand, :collect, :suggest, :slider, :say, :warn, :error ]
|
67
69
|
eval(<<-HEREDOC)
|
68
70
|
def #{each}(*args, **kwargs)
|
69
71
|
self._load_prompt() if CACHE::prompt == nil
|
@@ -78,6 +80,11 @@ Console = Class.new do
|
|
78
80
|
HEREDOC
|
79
81
|
end
|
80
82
|
|
83
|
+
def ok(message)
|
84
|
+
puts message.green + "\n[press enter to continue]".light_black
|
85
|
+
gets
|
86
|
+
end
|
87
|
+
alias :ok? :ok
|
81
88
|
|
82
89
|
attr_accessor :verbose
|
83
90
|
|
data/lib/atk/file_system.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative './remove_indent'
|
|
7
7
|
if OS.is?("unix")
|
8
8
|
HOME = Etc.getpwuid.dir
|
9
9
|
else # windows
|
10
|
-
HOME =
|
10
|
+
HOME = "C:"+`echo %HOMEPATH%`.chomp
|
11
11
|
end
|
12
12
|
|
13
13
|
class String
|
@@ -141,6 +141,52 @@ module FileSystem
|
|
141
141
|
return output
|
142
142
|
end
|
143
143
|
|
144
|
+
def self.merge(from, into: nil, force: true)
|
145
|
+
to = into
|
146
|
+
if !FS.exist?(from)
|
147
|
+
raise <<~HEREDOC
|
148
|
+
|
149
|
+
|
150
|
+
When calling FileSystem.merge(#{from.inspect}, into: #{into.inspect})
|
151
|
+
The path: #{from.inspect}
|
152
|
+
Doesn't exist
|
153
|
+
HEREDOC
|
154
|
+
end
|
155
|
+
|
156
|
+
# recursive case (folder)
|
157
|
+
if FS.is_folder(from)
|
158
|
+
# if theres a target file in the way
|
159
|
+
if FS.exist?(to) && ( !FS.is_folder(to) )
|
160
|
+
if force
|
161
|
+
# remove it
|
162
|
+
FS.delete(to)
|
163
|
+
else
|
164
|
+
# continue with the process
|
165
|
+
return
|
166
|
+
end
|
167
|
+
end
|
168
|
+
# create a folder if needed
|
169
|
+
if !FS.exist?(to)
|
170
|
+
FS.touch_dir(to)
|
171
|
+
end
|
172
|
+
# become recursive for all contents
|
173
|
+
for each in FS.ls(from)
|
174
|
+
FS.merge(from/each, into: to/each, force: force)
|
175
|
+
end
|
176
|
+
# base case (file)
|
177
|
+
else
|
178
|
+
if FS.exist?(to)
|
179
|
+
if force
|
180
|
+
FS.delete(to)
|
181
|
+
else
|
182
|
+
# do nothing
|
183
|
+
return
|
184
|
+
end
|
185
|
+
end
|
186
|
+
FS.copy(from: from, to: FS.dirname(to), new_name: nil)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
144
190
|
def self.copy(from:nil, to:nil, new_name:"", force: true, preserve: false, dereference_root: false)
|
145
191
|
if new_name == ""
|
146
192
|
raise "\n\nFileSystem.copy() needs a new_name: argument\nset new_name:nil if you wish the file/folder to keep the same name\ne.g. FileSystem.copy(from:'place/thing', to:'place', new_name:nil)"
|
@@ -178,12 +224,15 @@ module FileSystem
|
|
178
224
|
HEREDOC
|
179
225
|
end
|
180
226
|
to = FileSystem.dirname(path)/new_name
|
181
|
-
#
|
182
|
-
if
|
183
|
-
|
227
|
+
# if they are different
|
228
|
+
if FS.absolute_path(to) != FS.absolute_path(path)
|
229
|
+
# make sure the path is clear
|
230
|
+
if force
|
231
|
+
FileSystem.delete(to)
|
232
|
+
end
|
233
|
+
# perform the rename
|
234
|
+
return File.rename(path, to)
|
184
235
|
end
|
185
|
-
# perform the rename
|
186
|
-
File.rename(path, to)
|
187
236
|
end
|
188
237
|
|
189
238
|
def self.touch(path)
|
@@ -252,7 +301,7 @@ module FileSystem
|
|
252
301
|
Dir.children(path)
|
253
302
|
end
|
254
303
|
def self.pwd
|
255
|
-
Dir.pwd
|
304
|
+
FS.join(Dir.pwd, "")
|
256
305
|
end
|
257
306
|
def self.cd(*args, verbose: false)
|
258
307
|
if args.size == 0
|
data/lib/atk/info.rb
CHANGED
@@ -210,7 +210,7 @@ class Info
|
|
210
210
|
return @folder
|
211
211
|
end
|
212
212
|
def self.folder()
|
213
|
-
folder = Dir.pwd
|
213
|
+
folder = FileSystem.join(Dir.pwd, "") # join with nothing to fix windows pathing
|
214
214
|
loop do
|
215
215
|
# if the info.yaml exists in that folder
|
216
216
|
if FileSystem.file?( FileSystem.join(folder, "info.yaml"))
|
data/lib/atk_toolbox.rb
CHANGED
data/lib/atk_toolbox/version.rb
CHANGED
data/lib/console_colors.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.149
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.19.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby2_keywords
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.0.2
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.0.2
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.0.2
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.0.2
|
33
53
|
description: ''
|
34
54
|
email: jeff.hykin@gmail.com
|
35
55
|
executables: []
|
@@ -58,7 +78,7 @@ homepage: http://github.com//atk-toolbox
|
|
58
78
|
licenses:
|
59
79
|
- CC-BY-ND-4.0
|
60
80
|
metadata: {}
|
61
|
-
post_install_message:
|
81
|
+
post_install_message:
|
62
82
|
rdoc_options: []
|
63
83
|
require_paths:
|
64
84
|
- "./lib"
|
@@ -73,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
93
|
- !ruby/object:Gem::Version
|
74
94
|
version: '0'
|
75
95
|
requirements: []
|
76
|
-
|
77
|
-
|
78
|
-
signing_key:
|
96
|
+
rubygems_version: 3.1.2
|
97
|
+
signing_key:
|
79
98
|
specification_version: 4
|
80
99
|
summary: The Ruby gem for all the standard tools ATK uses internally
|
81
100
|
test_files: []
|