atk_toolbox 0.0.143 → 0.0.148

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: de7ba62b27e47339fe0c109dc7db53c60094149a8aefbf7bcf358f547d5d0b21
4
- data.tar.gz: 79b2cde743d104e097c7a34cede13b716b3c36c7655ff4b4a6c089218b9a2eac
3
+ metadata.gz: a2ef80e16df596fae11f5ea313ae4b4afd0285a1bc135658507b938f9d6cc54f
4
+ data.tar.gz: b56eaac7e7a1a68a400d40afe7fde07b539355aa9f98b59c98c920f01994c8ff
5
5
  SHA512:
6
- metadata.gz: 199a19bd45445d06488eca2818204fc6065be733f4d34ebfbd03bf943c0536b71a84eb6daf4298b99171cbc8d55880828565f6cac7a47800bdb04bb6eed0596d
7
- data.tar.gz: b201cab5a9706de28850c84df490ac32c36e72fb5a69b046a3776bfa61fd4771a3c011c7d65589b62a85ade741b458ac0f3e8dd474090cdf5418df054b6d3c0a
6
+ metadata.gz: adbca59652831fbeeb6e3a3c0a17886bbe4e301ca93a237788edd86479e7891753c7f935028c1ede02dacf66a0abaa59e0ad5d6d252f0d5001581183750638ad
7
+ data.tar.gz: ee3d50bc9cf2b9270c8ea21833ae7aa7a82fe4b3ba415ff0e9763d67fa9115c907dc524255b990e3633e3f316efc458dabecc0d008ccc1a553445f1221110db0
@@ -33,7 +33,11 @@ class AtkPaths
33
33
  end
34
34
  return ruby_path
35
35
  when 'gem'
36
- # FUTURE: this should eventually link to a specific version of ruby instead of the global version
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("3.0.0")
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("there was no info.yaml for that package")}
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("there was a info.yaml for that package")}
408
- #{bad("the info.yaml is not parseable")}
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("there was a info.yaml for that package")}
415
- #{good("the info.yaml was parseable")}
416
- #{@dont_exist[:using_atk_version] && bad("the info.yaml didn't have a (using_atk_version) key")}
417
- #{@dont_exist[:package_info] && bad("the info.yaml didn't have a (package_info) key")}
418
- #{@dont_exist[:actions] && bad("the info.yaml didn't have a (package_info): (actions) key")}
419
- #{@dont_exist[:run_action] && bad("the info.yaml didn't have a (package_info): (actions): (run) key")}
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
 
@@ -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
@@ -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
- class String
7
- # add a - operator to strings that makes it behave like a system() call
8
- def -@
9
- return system(self)
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, :ok, :warn, :error, :on ]
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
 
@@ -235,7 +242,7 @@ Console = Class.new do
235
242
 
236
243
  # users are going to have to manually escape things like ^, !, % etc depending on the context they're used in
237
244
 
238
- simple_char = "[a-zA-Z0-9_.,;`=-*?\\/\\[\\]]"
245
+ simple_char = "[a-zA-Z0-9_.,;`=\\-*?\\/\\[\\]]"
239
246
 
240
247
  # if its a simple argument just pass it on
241
248
  if argument =~ /\A(#{simple_char})*\z/
@@ -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 = `echo %HOMEPATH%`.chomp
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
- # make sure the path is clear
182
- if force
183
- FileSystem.delete(to)
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
@@ -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"))
@@ -1,3 +1,5 @@
1
+ require 'ruby2_keywords'
2
+
1
3
  # require all the ruby files
2
4
  files = Dir.glob(File.join(__dir__, "atk", "**/*.rb"))
3
5
  for each in files
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.143'
2
+ VERSION = '0.0.148'
3
3
  end
@@ -64,7 +64,7 @@ class String
64
64
  end
65
65
 
66
66
  def unstyle
67
- self.gsub!(/\e\[([;0-9]+)m/,"")
67
+ self.gsub!(/\e\[([;0-9]+)m/,"") || self
68
68
  end
69
69
 
70
70
  def self.color_samples
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.143
4
+ version: 0.0.148
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-02-28 00:00:00.000000000 Z
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
- rubyforge_project:
77
- rubygems_version: 2.7.6.2
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: []