atk_toolbox 0.0.112 → 0.0.118

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37776e8c6e6c44fe09c02f3dbc6dd8b3c813d4ac259a94416c9f6210c678a913
4
- data.tar.gz: '08b12599df0c89cc9f549406b110f8ee6c7ef3751e1f6e0231673ad1191929c4'
3
+ metadata.gz: c22229ec1aadfc5230eff6738e829b9fbec25d970b69ac5d6b64f11654782cf0
4
+ data.tar.gz: ada37fb2a9e89f6a3b54e39e76aca3e7a7aa59f74705cbb0cffce1f7252aa8b5
5
5
  SHA512:
6
- metadata.gz: 25edd0904e0b6f7279f0cd9a9146d5496f6477301d7540025b8fc8fd7b9d1d8e4b3d7171a81f7a28d8327fb6e38d674cc13ecdafba62544b0c4982a25dcaa613
7
- data.tar.gz: a1d2178d173f3cf55281178314b62dbb9f071eb5db02f33f32698f6d2d9eb780386beaa4f225df33d229f89ba3cedcc61bf4d1a0f2958e3ebc8a91fd42d1ae3b
6
+ metadata.gz: c5804933da27fa131de7681ce7d53292cb1c885d40f32a7613c9e0f55ef594d67931870875dca57a8a6fa701418e4a473e51333adfe6f4328a5f72c91369ca78
7
+ data.tar.gz: b9bc241363daa8112ca35aefbeb6ead246165830390735288c1753559acf834dd805a858c0fa0c6cd08db2efab1bff55822d56e010edae2306f7aee5d39fd1c5
data/lib/atk/atk_info.rb CHANGED
@@ -32,12 +32,9 @@ class AtkPaths
32
32
  ruby_path = OS.path_for_executable("ruby")
33
33
  end
34
34
  return ruby_path
35
- when 'core_yaml'
36
- return HOME/"atk"/"core.yaml"
37
- when 'installed_yaml'
38
- return HOME/"atk"/"installers.yaml"
39
- when 'installers_folder'
40
- return HOME/"atk"/"installers"
35
+ when 'gem'
36
+ # TODO: this eventually needs to link to a specific version of ruby
37
+ return OS.path_for_executable("gem")
41
38
  when 'repos'
42
39
  return HOME/"atk"/"repos"
43
40
  end
@@ -110,7 +107,7 @@ module Atk
110
107
  project_path = project_folder/project_name
111
108
  Git.ensure_cloned_and_up_to_date(project_path, repo_url)
112
109
  FS.in_dir(project_path) do
113
- setup_command = Info.project_commands['(setup)']
110
+ setup_command = Info.commands['(setup)']
114
111
  if setup_command.is_a?(Code) || setup_command.is_a?(String)
115
112
  puts "\n\nRunning (setup) command:\n".green
116
113
  sleep 1
@@ -136,6 +133,10 @@ module Atk
136
133
  def self.not_yet_implemented()
137
134
  puts "Sorry, this feature is still under development"
138
135
  end
136
+
137
+ def self.update()
138
+ system(Atk.paths['gem'], 'install', "atk_toolbox")
139
+ end
139
140
  end
140
141
 
141
142
 
@@ -159,21 +160,9 @@ class AtkPackage
159
160
  def url
160
161
  if @url == nil
161
162
  simple_name = self.simple_name()
162
- # if the package name does not have a slash in it, then assume it is a core / approved installer
163
+ # if the package name does not have a slash in it, then assume it is a core / approved package
163
164
  if not (simple_name =~ /.*\/.*/)
164
- # TODO: turn this into a check for is_core_repo?(package_name)
165
- # path_to_core_listing = Atk.paths[:core_yaml]
166
- # core = YAML.load_file(path_to_core_listing)
167
- # if core[package_name] == nil
168
- # puts "I don't see that package in the core, let me make sure I have the latest info"
169
- # download("https://raw.githubusercontent.com/aggie-tool-kit/atk/master/interface/core.yaml", as: path_to_core_listing)
170
- # core = YAML.load_file(path_to_core_listing)
171
- # end
172
- # if core[package_name] != nil
173
- # repo_url = core[package_name]["source"]
174
- # else
175
- raise "That package #{@init_name} doesn't seem to be a core package"
176
- # end
165
+ raise "That package #{@init_name} doesn't seem to be a core package"
177
166
  # if it does have a slash, and isn't a full url, then assume its a github repo
178
167
  elsif not simple_name.start_with?(/https?:\/\//)
179
168
  repo_url = "https://github.com/"+simple_name
@@ -3,7 +3,7 @@ module Atk
3
3
  if which_command == '_'
4
4
  require_relative './yaml_info_parser.rb'
5
5
  begin
6
- puts Info.project_commands().keys.map { |each| each.gsub(' ', '\ ') }.join(' ')
6
+ puts Info.commands().keys.map { |each| each.gsub(' ', '\ ') }.join(' ')
7
7
  rescue => exception
8
8
  puts ""
9
9
  end
@@ -7,13 +7,10 @@ module Atk
7
7
  puts "if you don't know how to use #{"project".blue} just run #{"project help".blue}"
8
8
  puts ""
9
9
  # if there are commands then show them
10
- begin
11
- commands = Info.project_commands
12
- if commands.is_a?(Hash) && commands.keys.size > 0
13
- puts "commands for current project:"
14
- puts `project commands`
15
- end
16
- rescue => exception
10
+ commands = Info.commands
11
+ if commands.is_a?(Hash) && commands.keys.size > 0
12
+ puts "commands for current project:"
13
+ puts `project commands`
17
14
  end
18
15
  else
19
16
  #
@@ -71,12 +68,12 @@ module Atk
71
68
  Info.init
72
69
  when 'synchronize', 'sync'
73
70
  # if there is an argument
74
- git_folder_path = FS.dirname(Info.source_path)/".git"
71
+ git_folder_path = FS.dirname(Info.path)/".git"
75
72
  if not FS.is_folder(git_folder_path)
76
73
  raise <<-HEREDOC.remove_indent
77
74
 
78
75
 
79
- The `project sync` command was called inside of #{FS.dirname(Info.source_path)}
76
+ The `project sync` command was called inside of #{FS.dirname(Info.path)}
80
77
  However, there doesn't seem to be a git repository in this folder
81
78
  (and changes can't be saved/synced without a git repository)
82
79
  HEREDOC
@@ -136,7 +133,7 @@ module Atk
136
133
  # then find the command with the same name as args[1] and run it
137
134
  # TODO: use https://github.com/piotrmurach/tty-markdown#ttymarkdown- to highlight the ruby code
138
135
  _, command_name, *command_args = args
139
- command = Info.project_commands[command_name]
136
+ command = Info.commands[command_name]
140
137
  # temporairly set the dir to be the same as the info.yaml
141
138
  FS.in_dir(Info.folder()) do
142
139
  if command.is_a?(String)
@@ -149,7 +146,7 @@ module Atk
149
146
  end
150
147
  when 'commands'
151
148
  max_number_of_chars_to_show = 80
152
- commands = Info.project_commands
149
+ commands = Info.commands
153
150
  if commands.keys.size == 0
154
151
  puts "0 avalible commands".cyan
155
152
  else
@@ -3,23 +3,11 @@
3
3
  name: Your Project Name Here
4
4
  description: Describe your project here
5
5
 
6
- commands: &commands # if you dont know what the & means, see https://blog.daemonl.com/2016/02/yaml.html
6
+ (commands):
7
7
  run: echo 'no run command written yet'
8
8
  run_ruby_example: !language/ruby |
9
- puts 'this is just a default value'
10
9
  puts 'replace this with your own ruby code'
11
10
  (setup): echo 'setup command unset'
12
11
 
13
- (advanced_setup):
14
- (project_commands):
15
- <<: *commands
16
- # caveats for a specific OS
17
- when(--os is 'mac'):
18
- (project_commands):
19
- <<: *commands
20
- when(--os is 'windows'):
21
- (project_commands):
22
- <<: *commands
23
- when(--os is 'linux'):
24
- (project_commands):
25
- <<: *commands
12
+ (paths):
13
+ project_root: ./
data/lib/atk/version.rb CHANGED
@@ -11,6 +11,17 @@ class Version
11
11
  end
12
12
 
13
13
  def initialize(version_as_string)
14
+ # if there are no digits
15
+ if !(version_as_string.to_s =~ /\d/)
16
+ raise <<-HEREDOC.remove_indent
17
+
18
+
19
+ When calling Version.new(arg1)
20
+ the `arg1.to_s` was #{version_as_string.to_s}
21
+ which does not contain any digits
22
+ so the Version class doesn't know what to do with it
23
+ HEREDOC
24
+ end
14
25
  @levels = version_as_string.split('.')
15
26
  @comparable = @levels[0] =~ /\A\d+\z/
16
27
  # convert values into integers where possible
@@ -87,6 +98,21 @@ class Version
87
98
  return value && value == 0
88
99
  end
89
100
 
101
+ def >=(other_version)
102
+ value = (self <=> other_version)
103
+ return value && value != -1
104
+ end
105
+
106
+ def <=(other_version)
107
+ value = (self <=> other_version)
108
+ return value && value != 1
109
+ end
110
+
111
+ def !=(other_version)
112
+ value = (self <=> other_version)
113
+ return value && value != 0
114
+ end
115
+
90
116
  def to_s
91
117
  return @levels.map(&:to_s).join('.')
92
118
  end
@@ -1,8 +1,18 @@
1
1
  require "yaml"
2
2
  require "colorize"
3
- require_relative './os'
4
3
  require 'fileutils'
4
+ require_relative './os'
5
5
  require_relative './remove_indent.rb'
6
+ require_relative './version.rb'
7
+
8
+
9
+ #
10
+ # yaml format
11
+ #
12
+ # (using_atk_version)
13
+ # (project)
14
+ # (commands)
15
+ # (paths)
6
16
 
7
17
  # duplicated for the sake of efficieny (so that the parser doesn't need to import all of FileSystem)
8
18
  module FileSystem
@@ -89,205 +99,155 @@ end
89
99
  #
90
100
  # setting/getting values via an object (instead of opening/closing a file)
91
101
  class Info
92
- # main keys
93
- # (using_atk_version)
94
- # (project)
95
- # (advanced_setup)
96
- # any-level project detail keys:
97
- # (paths)
98
- # (dependencies)
99
- # (project_commands)
100
- # (structures)
101
- # (local_package_managers)
102
- # (put_new_dependencies_under)
103
- # (environment_variables)
104
102
 
105
- # TODO: figure out a way of adding write access to the info.yaml
106
- # TODO: if there is no (using_atk_version), then add one with the current version
107
- # TODO:
108
- # if there is no (project) or no (advanced_setup), then assume its not an ATK setup
109
- # (quit somehow depending on how this code was invoked)
110
- # TODO:
111
- # if there are ()'s in a key inside of the (project)
112
- # but the key isn't part of the standard keys
113
- # then issue a warning, and give them a suggestion to the next-closest key
103
+ # standard attributes
104
+ @data = {}
105
+ @paths = {}
106
+ @commands = {}
107
+ @path = nil
114
108
 
115
- @@data = nil
116
- @@valid_variables = ['context', 'os']
117
- @@valid_operators = ['is']
118
-
119
- def self.init
120
- current_dir = Dir.pwd/"info.yaml"
121
- # if there isn't a info.yaml then create one
122
- if not File.file?(current_dir)
123
- # copy the default yaml to the current dir
124
- FileUtils.cp(__dir__/"default_info.yaml", current_dir)
125
- puts "info.yaml created successfully"
126
- else
127
- puts "There appears to already be an info.yaml file\nThe init method is not yet able to merge the ATK init data with the current data\n(this will be fixed in the future)"
128
- end
109
+ # a helper error class
110
+ class ReRaiseException < Exception
129
111
  end
130
112
 
131
- # TODO: write tests for this function
132
- def self.parse_when_statment(statement)
133
- # remove the 'when' and paraentheses
134
- expression = statement.sub( /when\((.*)\)/, "\\1" )
135
- # create the pattern for finding variables
136
- variable_pattern = /\A\s*--(?<variable>#{@@valid_variables.join('|')})\s+(?<operator>#{@@valid_operators.join('|')})\s+(?<value>.+)/
137
- groups = expression.match(variable_pattern)
138
- if groups == nil
139
- raise "\n\nIn the info.yaml file\nI couldn't any of the variables in #{statement}\nMake sure the format is:\n when( --VARIABLE *space* OPERATOR *space* VALUE )\nvalid variables are: #{valid_variables}\nvalid operators are: #{valid_operators}"
113
+ def initialize()
114
+ #
115
+ # find the yaml file
116
+ #
117
+ begin
118
+ @path = Info.path
119
+ rescue
120
+ raise <<-HEREDOC.remove_indent
121
+
122
+
123
+ When calling Info.new
124
+ I looked for an info.yaml in #{Dir.pwd}
125
+ (and I also looked in all of its parent folders)
126
+ but I couldn't find an info.yaml file in any of them
127
+ HEREDOC
140
128
  end
141
- value = groups['value'].strip
142
-
143
- substitutions = ->(value) do
144
- value.gsub!( /\\'/, "'" )
145
- value.gsub!( /\\"/, '"' )
146
- value.gsub!( /\\n/, "\n" )
147
- value.gsub!( /\\t/, "\t" )
129
+ #
130
+ # open the yaml file
131
+ #
132
+ begin
133
+ @data = YAML.load_file(@path)
134
+ rescue => exception
135
+ raise <<-HEREDOC.remove_indent
136
+
137
+ When calling Info.new
138
+ I found an info.yaml file
139
+ however, when I tried to load it I received an error:
140
+ #{exception}
141
+ HEREDOC
148
142
  end
149
-
150
- # if it has single quotes
151
- if value =~ /'.+'/
152
- value.sub!( /'(.+)'/, "\\1" )
153
- substitutions[value]
154
- # if double quotes
155
- elsif value =~ /".+"/
156
- value.sub!( /"(.+)"/, "\\1" )
157
- substitutions[value]
158
- else
159
- raise "\n\nIn the info.yaml file\nthe value: #{value} in the statment:\n#{statement}\n\nwas invalid. It probably needs single or double quotes around it"
143
+ #
144
+ # check the version, and parse accordingly
145
+ #
146
+ version = nil
147
+ begin
148
+ version = Version.new(@data['(using_atk_version)'].to_s)
149
+ rescue => exception
150
+ # if no version, then don't worry about parsing
160
151
  end
161
-
162
- return {
163
- variable: groups['variable'],
164
- operator: groups['operator'],
165
- value: value
166
- }
167
- end
168
-
169
- def self.evaluate_when_condition(data)
170
- case data[:variable]
171
- when 'context'
172
- raise "\n\ncontext functionality has not been implemented yet"
173
- when 'os'
174
- case data[:operator]
175
- when 'is'
176
- return OS.is?(data[:value])
152
+ if nil != version
153
+ begin
154
+ if version <= Version.new("1.0.0")
155
+ self.parser_version1(@data)
177
156
  else
178
- raise "unknown operator: #{data[:operator]}"
157
+ # TODO: in the future do an online check to see if the latest ATK could handle this
158
+ raise <<-HEREDOC.remove_indent
159
+
160
+ Hey I think you need to update atk:
161
+ `atk update`
162
+ Why?
163
+ The (using_atk_version) in the info.yaml is: #{version}
164
+ However, I (your current version of ATK) don't know
165
+ how to handle that version.
166
+ HEREDOC
167
+ end
168
+ rescue ReRaiseException => exception
169
+ raise exception
170
+ rescue => exception
171
+ raise <<-HEREDOC.remove_indent
172
+
173
+ Original error message:
174
+ """
175
+ #{exception}
176
+ """
177
+
178
+ This error is almost certainly not your fault
179
+ It is likely a bug inside the atk_toolbox library
180
+ Specifically the info.yaml parser
181
+
182
+ If you agree and think this is a problem with the atk_toolbox library
183
+ please go here:
184
+ https://github.com/aggie-tool-kit/atk-toolbox/issues/new
185
+ and tell us what happened before getting this message
186
+ and also paste the original error message:
187
+
188
+ Sorry for the bug!
189
+ HEREDOC
179
190
  end
180
- else
181
- raise "\n\nunknown variable: #{data[:variable]}"
182
191
  end
183
192
  end
184
-
185
- # def self.parse_language_evaluations(value)
186
- # if value.is_a?(Evaluation)
187
- # return Info.parse_language_evaluations(value.run())
188
- # elsif value.is_a?(Hash)
189
- # new_hash = {}
190
- # for each_key, each_value in value
191
- # new_hash[each_key] = Info.parse_language_evaluations(each_value)
192
- # end
193
- # return new_hash
194
- # elsif value.is_a?(Array)
195
- # new_array = []
196
- # for each in value
197
- # new_array.push(Info.parse_language_evaluations(each))
198
- # end
199
- # return new_array
200
- # else
201
- # return value
202
- # end
203
- # end
204
-
205
- def self.parse_advanced_setup(unchecked_hashmap, current_project_settings)
206
- for each_key, each_value in unchecked_hashmap.clone()
207
- case
208
- # check for yaml-when statements
209
- when each_key =~ /\Awhen\(.*\)\z/ && each_value.is_a?(Hash)
210
- statement_data = Info.parse_when_statment(each_key)
211
- # if the when condition was true
212
- if Info.evaluate_when_condition(statement_data)
213
- # recursively parse the tree
214
- Info.parse_advanced_setup(each_value, current_project_settings)
215
- end
216
- # transfer all the normal keys to the current_project_settings
217
- else
218
- current_project_settings[each_key] = each_value
193
+
194
+ def self.folder()
195
+ folder = Dir.pwd
196
+ loop do
197
+ # if the info.yaml exists in that folder
198
+ if FileSystem.file?( FileSystem.join(folder, "info.yaml"))
199
+ return folder
200
+ end
201
+
202
+ next_location = File.dirname(folder)
203
+
204
+ # if all folders exhausted
205
+ if next_location == folder
206
+ raise <<-HEREDOC.remove_indent.red
207
+
208
+ #{"Couldn't find an info.yaml in the current directory or any parent directory".red}
209
+ #{Dir.pwd}
210
+ Are you sure you're running the command from the correct directory?
211
+ HEREDOC
219
212
  end
213
+
214
+ folder = next_location
220
215
  end
221
216
  end
222
217
 
223
- def self.load_if_needed
224
- # if the data hasn't been loaded then load it first
225
- if @@data == nil
226
- Info.load_from_yaml
227
- end
218
+ def self.path()
219
+ return FileSystem.join( self.folder(), "info.yaml")
228
220
  end
229
221
 
230
- def self.load_from_yaml
231
- # this function sets up:
232
- # @@data
233
- # @@project
234
- # @@settings
235
- # and also
236
- # @@dependencies
237
- # @@project_commands
238
- # @@structures
239
- # @@local_package_managers
240
- # @@put_new_dependencies_under
241
- # @@environment_variables
242
-
243
- # get the local yaml file
244
- absolute_parent_path = File.absolute_path(Info.folder())
245
- source = FileSystem.join(absolute_parent_path, "info.yaml")
222
+ def parser_version1(data)
223
+ #
224
+ # parse the commands
225
+ #
246
226
  begin
247
- @@data = YAML.load_file(source)
248
- if @@data['(using_atk_version)'] != 1.0
249
- raise <<-HEREDOC.remove_indent
250
-
251
-
252
- When opening the info.yaml file in '#{self.folder}'
253
- the (using_atk_version) was listed as: #{@@data['(using_atk_version)'].inspect}
254
- The version of atk_toolbox you have installed is only capable of handling version 1.0
255
- either atk_toolbox needs to be changed, or the (using_atk_version) version needs to be changed.
256
- HEREDOC
227
+ @commands = data['(project)']['(commands)']
228
+ if !(@commands.is_a?(Hash))
229
+ @commands = {}
257
230
  end
258
231
  rescue
259
- if File.file?(source)
260
- puts "\n\nI'm having trouble loading the info.yaml file. Here's the error:\n".red
261
- raise exception
262
- else
263
- raise "\n\nCouldn't find an info.yaml file in #{Dir.pwd}".red
264
- end
265
- end
266
- @@project = @@data['(project)']
267
- if @@project == nil
268
- return
232
+ @commands = {}
269
233
  end
270
-
271
- @@settings = @@project['(advanced_setup)']
272
- if @@settings == nil
273
- # TODO: maybe change this to be optional in the future and have default settings
274
- raise "\n\nThere is no (advanced_setup): key in the (project) of the info.yaml\n(so ATK is unable to parse the project settings)".red
234
+ #
235
+ # parse the paths
236
+ #
237
+ begin
238
+ @paths = data['(project)']['(paths)']
239
+ if !(@paths.is_a?(Hash))
240
+ @paths = {}
241
+ end
242
+ rescue
243
+ @paths = {}
275
244
  end
276
- Info.parse_advanced_setup(@@settings, @@settings)
277
- @@dependencies = @@settings['(dependencies)']
278
- @@project_commands = @@settings['(project_commands)']
279
- @@structures = @@settings['(structures)']
280
- @@local_package_managers = @@settings['(local_package_managers)']
281
- @@put_new_dependencies_under = @@settings['(put_new_dependencies_under)']
282
- @@environment_variables = @@settings['(environment_variables)']
283
-
284
- @@paths = @@settings['(paths)'] || {}
285
- # TODO: make this deeply recursive
286
- for each_key, each_value in @@paths
245
+ for each_key, each_value in @paths
287
246
  # if its an array, just join it together
288
247
  if each_value.is_a?(Array)
289
248
  each_value = FileSystem.join(*each_value)
290
249
  end
250
+ # make all paths absolute
291
251
  if each_value.is_a?(String)
292
252
  # remove the ./ if it exists
293
253
  if each_value =~ /\A\.\//
@@ -296,55 +256,55 @@ class Info
296
256
  # Dont add a source_path if its an absolute path
297
257
  if not each_value.size > 0 && each_value[0] == '/'
298
258
  # convert the path into an absolute path
299
- @@paths[each_key] = FileSystem.join(absolute_parent_path , each_value)
259
+ @paths[each_key] = FileSystem.join(absolute_parent_path , each_value)
300
260
  end
301
261
  end
302
262
  end
303
263
  end
304
264
 
305
- # accessors
306
- def self.data() Info.load_if_needed; return @@data end
307
- def self.project() Info.load_if_needed; return @@project end
308
- def self.settings() Info.load_if_needed; return @@settings end
309
- def self.dependencies() Info.load_if_needed; return @@dependencies end
310
- def self.project_commands() Info.load_if_needed; return @@project_commands end
311
- def self.structures() Info.load_if_needed; return @@structures end
312
- def self.local_package_managers() Info.load_if_needed; return @@local_package_managers end
313
- def self.put_new_dependencies_under() Info.load_if_needed; return @@put_new_dependencies_under end
314
- def self.environment_variables() Info.load_if_needed; return @@environment_variables end
315
- def self.paths() Info.load_if_needed; return @@paths end
265
+ def self.init
266
+ current_dir = Dir.pwd/"info.yaml"
267
+ # if there isn't a info.yaml then create one
268
+ if not File.file?(current_dir)
269
+ # copy the default yaml to the current dir
270
+ FileUtils.cp(__dir__/"default_info.yaml", current_dir)
271
+ puts "info.yaml created successfully"
272
+ else
273
+ puts "There appears to already be an info.yaml file\nThe init method is not yet able to merge the ATK init data with the current data\n(this will be fixed in the future)"
274
+ end
275
+ end
276
+
277
+ # read access
278
+ def [](element)
279
+ return @data[element]
280
+ end
316
281
 
317
- # read access to the yaml file
318
282
  def self.[](element)
319
- Info.load_if_needed
320
- return @@data[element.to_s]
283
+ return (Info.new)[element]
321
284
  end
322
285
 
323
- def self.folder()
324
- folder = Dir.pwd
325
- loop do
326
- # if the info.yaml exists in that folder
327
- if FileSystem.join(folder, "info.yaml")
328
- return folder
329
- end
330
-
331
- next_location = File.dirname(folder)
332
-
333
- # if all folders exhausted
334
- if next_location == folder
335
- raise <<-HEREDOC.remove_indent.red
336
-
337
- #{"Couldn't find an info.yaml in the current directory or any parent directory".red}
338
- #{Dir.pwd}
339
- Are you sure you're running the command from the correct directory?
340
- HEREDOC
341
- end
342
-
343
- folder = next_location
344
- end
286
+ # data access
287
+ def data
288
+ return @data
289
+ end
290
+ def self.data
291
+ return (Info.new).data
345
292
  end
346
293
 
347
- def self.source_path()
348
- return FileSystem.join( self.folder(), "info.yaml")
294
+ # command access
295
+ def commands
296
+ return @commands || {}
349
297
  end
298
+ def self.commands
299
+ return (Info.new).commands
300
+ end
301
+
302
+ # path access
303
+ def paths
304
+ return @paths || {}
305
+ end
306
+ def self.paths
307
+ return (Info.new).paths
308
+ end
309
+
350
310
  end
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.112'
2
+ VERSION = '0.0.118'
3
3
  end
@@ -0,0 +1,21 @@
1
+ #
2
+ # right before gem install
3
+ #
4
+ pre_version = nil
5
+ Gem.pre_install do
6
+ begin
7
+ # if atk is already installed
8
+ require 'atk_toolbox'
9
+ pre_version = Atk.version
10
+ rescue
11
+ end
12
+ end
13
+
14
+ #
15
+ # right after gem install
16
+ #
17
+ Gem.post_install do
18
+ post_version = Atk.version
19
+ require_relative './update_handler.rb'
20
+ Atk.migrate(pre_version, post_version)
21
+ end
@@ -0,0 +1,30 @@
1
+ module Atk
2
+ def self.migrate(old_version, new_version)
3
+ require 'atk_toolbox'
4
+
5
+ # helper function
6
+ download_and_install_command = ->(command) do
7
+ atk_command_download_path = Atk.temp_path("#{command}.rb")
8
+ source = "https://raw.githubusercontent.com/aggie-tool-kit/atk-toolbox/master/custom_bin"
9
+ FS.download("#{source}/#{command}" , to: atk_command_download_path)
10
+ Console.set_command(command, FS.read(atk_command_download_path))
11
+ end
12
+
13
+ #
14
+ # overwrite the commands
15
+ #
16
+ download_and_install_command["atk"]
17
+ download_and_install_command["project"]
18
+ download_and_install_command["_"]
19
+
20
+ #
21
+ # print success
22
+ #
23
+ puts ""
24
+ puts ""
25
+ puts ""
26
+ puts "=============================="
27
+ puts " ATK installed "
28
+ puts "=============================="
29
+ end
30
+ end
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.112
4
+ version: 0.0.118
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-12-20 00:00:00.000000000 Z
11
+ date: 2019-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip
@@ -114,6 +114,8 @@ files:
114
114
  - lib/atk/zip.rb
115
115
  - lib/atk_toolbox.rb
116
116
  - lib/atk_toolbox/version.rb
117
+ - lib/rubygems_plugin.rb
118
+ - lib/update_handler.rb
117
119
  - test/info.yaml
118
120
  - test/main.rb
119
121
  homepage: http://github.com//atk-toolbox
@@ -123,7 +125,7 @@ metadata: {}
123
125
  post_install_message:
124
126
  rdoc_options: []
125
127
  require_paths:
126
- - lib
128
+ - "./lib"
127
129
  required_ruby_version: !ruby/object:Gem::Requirement
128
130
  requirements:
129
131
  - - ">="