atk_toolbox 0.0.88 → 0.0.89

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: 56ed386c598760ad632d38b24699c1e161ef24ebf58596d6db1ba19787d22ce5
4
- data.tar.gz: 11e708122a15021df2a99aa9c970fc086b45b69d9b4e7c91ecc2b12cd7108ed0
3
+ metadata.gz: 88ed1b2cf8888eddfb039a4b9f72c81098dcfeae285f93d839ba2453b53e01cc
4
+ data.tar.gz: 600a3100cdcc26220e6f1b96521dbfa9d930756a5b155c8896df04adb28483bc
5
5
  SHA512:
6
- metadata.gz: 90ad3c2aed654ad3ff77dc19416ae1c349a0fb6b2246489a8c912d5068b36f24de9fd8ef8ef348ce62182625b8212e72bd37598b832043cb6a92906bc9cd89b0
7
- data.tar.gz: b1c962f58fe49d0706b4304abeeafcc77ac78771a4fd4390cc23ca59a976cc7db2772b0be2a046cac2196acb867f0391a29c2b60e35b251d92f4186040a8226e
6
+ metadata.gz: 18b48ff2f1aeadaab20067aa3adbf4d6f9fa3bdfcc5fb08c9fb17df1dc8cbaf581ca1b1afc43d291f55962ffcf08758942659a7a351934220ac4228f172cd576
7
+ data.tar.gz: dfb0ad8d070cafeed7c45ddd2e242a0787e1b074468fcaff273f523fbdf9073a09ca7227e6962d1b7dc9f19f593ecd7d0ab8c8cd135ea6fe5bb0d23b1d8f0230
data/lib/atk/atk_info.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require_relative './file_sys'
2
+ require_relative './console'
3
+ require_relative './yaml_info_parser'
2
4
  require_relative './os'
5
+ require_relative './git'
3
6
  require 'yaml'
4
7
 
5
8
  class AtkPaths
@@ -41,6 +44,7 @@ class AtkPaths
41
44
  end
42
45
 
43
46
  module ATK
47
+ @@atk_settings_key = "atk_settings"
44
48
  def self.paths
45
49
  return AtkPaths
46
50
  end
@@ -55,20 +59,96 @@ module ATK
55
59
 
56
60
  def self.info
57
61
  settings_path = ATK.paths[:info]
58
- atk_settings_key = "atk_settings"
59
62
  # if it doesn't exist then create it
60
63
  if not FS.exist?(settings_path)
61
- FS.write("#{atk_settings_key}: {}", to: settings_path)
64
+ FS.write("#{@@atk_settings_key}: {}", to: settings_path)
62
65
  return {}
63
66
  else
64
67
  data = YAML.load_file(settings_path)
65
68
  if data.is_a?(Hash)
66
- if data[atk_settings_key].is_a?(Hash)
67
- return data[atk_settings_key]
69
+ if data[@@atk_settings_key].is_a?(Hash)
70
+ return data[@@atk_settings_key]
68
71
  end
69
72
  else
70
73
  return {}
71
74
  end
72
75
  end
73
76
  end
77
+
78
+ def self.save_info(new_hash)
79
+ settings_path = ATK.paths[:info]
80
+ current_settings = ATK.info
81
+ updated_settings = current_settings.merge(new_hash)
82
+
83
+ info_data = YAML.load_file(ATK.paths[:info])
84
+ if info_file.is_a?(Hash)
85
+ info_data[@@atk_settings_key] = updated_settings
86
+ else
87
+ info_data = { @@atk_settings_key => updated_settings }
88
+ end
89
+
90
+ FS.save(info_data, to: ATK.paths[:info], as: :yaml )
91
+ end
92
+
93
+ def self.simplify_package_name(source)
94
+ source = source.strip
95
+ # if its starts with "atk/", just remove that part
96
+ source = source.sub( /^atk\//, "" )
97
+ # if it starts with "https://github.com/", just remove that part
98
+ source = source.sub( /^https:\/\/github.com\//, "" )
99
+ return source
100
+ end
101
+
102
+ def self.package_name_to_url(package_name)
103
+ # if its starts with "atk/", just remove that part
104
+ installer_name = ATK.simplify_package_name(package_name)
105
+ # if the package name does not have a slash in it, then assume it is a core / approved installer
106
+ if not (package_name =~ /.*\/.*/)
107
+ # TODO: turn this into a check for is_core_repo?(package_name)
108
+ # path_to_core_listing = ATK.paths[:core_yaml]
109
+ # core = YAML.load_file(path_to_core_listing)
110
+ # if core[installer_name] == nil
111
+ # puts "I don't see that package in the core, let me make sure I have the latest info"
112
+ # download("https://raw.githubusercontent.com/aggie-tool-kit/atk/master/interface/core.yaml", as: path_to_core_listing)
113
+ # core = YAML.load_file(path_to_core_listing)
114
+ # end
115
+ # if core[installer_name] != nil
116
+ # repo_url = core[installer_name]["source"]
117
+ # else
118
+ # raise "That package doesn't seem to be a core package"
119
+ # end
120
+ # if it does have a slash, then assume its a github repo
121
+ else
122
+ repo_url = "https://github.com/"+package_name
123
+ end
124
+ return repo_url
125
+ end
126
+
127
+ def self.setup(package_name, arguments)
128
+ repo_url = Console.args[1]
129
+ project_folder = ATK.info["project_folder"]
130
+ # if there's a project folder
131
+ if not project_folder
132
+ # then use the Desktop folder
133
+ # TODO: improve this to ask the user for a defaul location for storing their project
134
+ project_folder = HOME/"Desktop"
135
+ end
136
+ project_name = Console.ask("What do you want to name the project?")
137
+ project_path = project_folder/project_name
138
+ Git.ensure_cloned_and_up_to_date(project_path, repo_url)
139
+ FS.in_dir(project_path) do
140
+ setup_command = Info.project_commands['(setup)']
141
+ if setup_command.is_a?(Code) || setup_command.is_a?(String)
142
+ puts "\n\nRunning (setup) command:\n".green
143
+ sleep 1
144
+ if setup_command.is_a?(Code)
145
+ setup_command.run(arguments)
146
+ else
147
+ command_and_args = setup_command.split(/ */)
148
+ console_args = command_and_args.concat(*arguments)
149
+ system(*console_args)
150
+ end
151
+ end
152
+ end
153
+ end
74
154
  end
File without changes
data/lib/atk/git.rb CHANGED
@@ -1,2 +1,21 @@
1
1
  require 'git'
2
2
  require 'logger'
3
+
4
+ module Git
5
+ def self.ensure_cloned_and_up_to_date(target_dir, git_repo_url)
6
+ # check if it exists
7
+ if FS.directory?(target_dir)
8
+ if Console.verbose
9
+ git_repo = Git.open(target_dir, :log => Logger.new(STDOUT))
10
+ else
11
+ git_repo = Git.open(target_dir)
12
+ end
13
+ # if it doesn't exist, then clone it
14
+ else
15
+ git_repo = Git.clone(git_repo_url, target_dir)
16
+ end
17
+ # pull from origin master
18
+ # TODO: make this a force pull
19
+ git_repo.pull
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  require "yaml"
2
- require_relative './cmd'
2
+ require_relative './console'
3
3
  require_relative './os'
4
4
  require_relative './file_sys'
5
5
  require_relative './extra_yaml'
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.88'
2
+ VERSION = '0.0.89'
3
3
  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.88
4
+ version: 0.0.89
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-10-31 00:00:00.000000000 Z
11
+ date: 2019-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip
@@ -97,7 +97,7 @@ extensions: []
97
97
  extra_rdoc_files: []
98
98
  files:
99
99
  - lib/atk/atk_info.rb
100
- - lib/atk/cmd.rb
100
+ - lib/atk/console.rb
101
101
  - lib/atk/default_info.yaml
102
102
  - lib/atk/extra_yaml.rb
103
103
  - lib/atk/file_sys.rb