atk_toolbox 0.0.35 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atk/yaml_info_parser.rb +19 -3
- data/lib/atk_toolbox/version.rb +1 -1
- data/lib/yaml_edit/yaml_edit.rb +23 -13
- data/test/info.yaml +51 -52
- data/test/main.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: '05948ecaeb302fe7fac8223a0c9236c506c6f42b5f61f70ae599a337de1f1a82'
|
4
|
+
data.tar.gz: 332cdebeb6df4e8b3ed5d36078b1b9ec327b82c0dd2d6336f22509ed3a9d8226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b9926571e1a245bedaa1f5af9dbe40e07d41c05daf2128cb775e7e4cf0a5f97899252a877937c8fb683d1c4e29fa2f4f183966ddfcc461b370c30df1314f5f
|
7
|
+
data.tar.gz: 1ef3ed00db4fa1ac0d59c79b42983684939b212f8d2a6a4777d179293193505f46d41833165b41c400e03444e3d6c33da53daaf5857ccf2f1718ad31b37f817d
|
data/lib/atk/yaml_info_parser.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require "yaml"
|
3
3
|
require_relative './cmd'
|
4
4
|
require_relative './os'
|
5
|
+
require_relative './extra_file_utils'
|
6
|
+
require_relative '../yaml_edit/yaml_edit.rb'
|
5
7
|
require 'fileutils'
|
6
8
|
|
7
9
|
#
|
@@ -97,7 +99,7 @@ class Info
|
|
97
99
|
|
98
100
|
def self.init
|
99
101
|
# copy the default yaml to the current dir
|
100
|
-
FileUtils.cp(
|
102
|
+
FileUtils.cp(__dir__/"default_info.yaml", Dir.pwd/"info.yaml")
|
101
103
|
end
|
102
104
|
|
103
105
|
# TODO: write tests for this function
|
@@ -215,7 +217,7 @@ class Info
|
|
215
217
|
# get the local yaml file
|
216
218
|
# TODO: have this search the parent dir's to find it
|
217
219
|
begin
|
218
|
-
@@data = YAML.load_file(
|
220
|
+
@@data = YAML.load_file(Info.source_path)
|
219
221
|
rescue => exception
|
220
222
|
puts "Couldn't find an info.yaml file in #{Dir.pwd}"
|
221
223
|
exit
|
@@ -256,4 +258,18 @@ class Info
|
|
256
258
|
Info.load_if_needed
|
257
259
|
return @@data[element.to_s]
|
258
260
|
end
|
259
|
-
|
261
|
+
|
262
|
+
def self.source_path()
|
263
|
+
return "."/"info.yaml"
|
264
|
+
end
|
265
|
+
|
266
|
+
def self.set_key(key_list, new_value)
|
267
|
+
path = Info.source_path
|
268
|
+
IO.write(path, YAML.set_key(IO.read(path), key_list, new_value))
|
269
|
+
end
|
270
|
+
|
271
|
+
def self.remove_key(key_list, new_value)
|
272
|
+
path = Info.source_path
|
273
|
+
IO.write(path, YAML.remove_key(IO.read(path), key_list))
|
274
|
+
end
|
275
|
+
end
|
data/lib/atk_toolbox/version.rb
CHANGED
data/lib/yaml_edit/yaml_edit.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative '../atk/os'
|
|
2
2
|
require_relative '../atk/remove_indent'
|
3
3
|
require 'open3'
|
4
4
|
require 'json'
|
5
|
+
require 'yaml'
|
5
6
|
|
6
7
|
def execute_with_local_python(python_file_path, *args)
|
7
8
|
# save the current directory
|
@@ -15,22 +16,31 @@ def execute_with_local_python(python_file_path, *args)
|
|
15
16
|
return [stdout_str, stderr_str, status]
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
module YAML
|
20
|
+
def set_key(yaml_string, key_list, new_value)
|
21
|
+
if not key_list.is_a?(Array)
|
22
|
+
raise "when using YAML.set_key, the second argument needs to be a list of keys"
|
23
|
+
end
|
24
|
+
# run the python file with the virtual environment
|
25
|
+
stdout_str, stderr_str, status = execute_with_local_python('set_key.py', yaml_string, key_list.to_json, new_value.to_json)
|
26
|
+
if not status.success?
|
27
|
+
raise "\n\nFailed to set key in yaml file:\n#{stderr_str}"
|
28
|
+
end
|
29
|
+
return stdout_str
|
23
30
|
end
|
24
|
-
return stdout_str
|
25
|
-
end
|
26
31
|
|
27
|
-
def remove_key(yaml_string, key_list)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
def remove_key(yaml_string, key_list)
|
33
|
+
if not key_list.is_a?(Array)
|
34
|
+
raise "when using YAML.remove_key, the second argument needs to be a list of keys"
|
35
|
+
end
|
36
|
+
# run the python file with the virtual environment
|
37
|
+
stdout_str, stderr_str, status = execute_with_local_python('remove_key.py', yaml_string, key_list.to_json)
|
38
|
+
if not status.success?
|
39
|
+
raise "\n\nFailed to remove key in yaml file:\n#{stderr_str}"
|
40
|
+
end
|
41
|
+
return stdout_str
|
32
42
|
end
|
33
|
-
|
43
|
+
module_function :remove_key, :set_key
|
34
44
|
end
|
35
45
|
|
36
46
|
# yaml_test_string = <<-HEREDOC
|
data/test/info.yaml
CHANGED
@@ -1,68 +1,67 @@
|
|
1
1
|
# Example of Project settings
|
2
2
|
(using_atk_version): 1.0
|
3
3
|
(project):
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
name: The ATK Repo
|
5
|
+
description: Blah
|
6
|
+
homepage: www.blah.com
|
7
|
+
|
8
|
+
auto_generated_commands: &auto_generated_commands !evaluate/ruby |
|
9
|
+
commands = {}
|
10
|
+
# check for a scripts directory
|
11
|
+
script_file_paths = Dir["scripts/*"]
|
12
|
+
for each in script_file_paths
|
13
|
+
commands[File.basename(each, ".*")] = "./#{each}"
|
14
|
+
end
|
15
|
+
commands
|
16
|
+
|
17
|
+
basic_setup: &basic_setup_reference
|
18
|
+
(project_commands): &basic_commands
|
19
19
|
# auto-insert the !lang/console if they dont put one
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
compile: gcc *.cpp
|
20
|
+
run: !language/ruby puts "hi"
|
21
|
+
stop: \`pkill node`
|
22
|
+
compile: gcc *.cpp
|
24
23
|
# TODO: add inline support for doing things like auto-generating commands
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
24
|
+
[*auto_generated_commands]:
|
25
|
+
(environment_variables):
|
26
|
+
JAVA_VERSION: '8.9'
|
27
|
+
(structures):
|
28
|
+
npm-package: v1.0.0
|
29
|
+
vs-code-package: v1.0.0
|
30
|
+
git-repo: v1.0.0
|
31
|
+
(dependencies): &base_dependencies
|
32
|
+
python3: v3.7.0
|
33
|
+
node: v11.11.0
|
34
|
+
npm: v6.7.0
|
35
|
+
git: v2.21.0
|
36
|
+
|
37
|
+
(advanced_setup):
|
38
|
+
(local_package_managers): [npm, pip] # by default the local package managers are always here
|
39
|
+
(put_new_dependencies_under): [(project), basic_info, (dependencies)]
|
40
|
+
<<: *basic_setup_reference
|
41
|
+
# this injects all the (basic_setup) here
|
42
42
|
# caveats for a specific OS
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
when(--os is 'mac'):
|
44
|
+
(dependencies):
|
45
|
+
<<: *base_dependencies
|
46
|
+
python2: v2.7
|
47
|
+
|
48
|
+
when(--os is 'windows'):
|
49
|
+
(project_commands):
|
50
|
+
<<: *basic_commands
|
51
|
+
show_files: dir # this is a custom command specific to windows
|
52
|
+
when(--os is 'linux'):
|
53
53
|
# caveats for a specific OS sub-version
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
when(--os is 'arch'):
|
55
|
+
(project_commands):
|
56
|
+
<<: *basic_commands
|
57
|
+
# this injects all the (project_commands) here
|
58
|
+
my_ip_address: ip # this is a custom command specific to arch linux
|
59
59
|
# # caveats for a different context
|
60
60
|
# when(--context is 'testing'):
|
61
61
|
# (environment_variables):
|
62
62
|
# CMAKE_LIB: "testing"
|
63
63
|
# (project_commands):
|
64
64
|
# run: node tests.rb
|
65
|
-
|
66
65
|
# when(--os is 'windows'):
|
67
66
|
# (environment_variables):
|
68
67
|
# CMAKE_LIB: "C:\\testing"
|
data/test/main.rb
CHANGED