sanctuary 0.1.15 → 0.1.16
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 +4 -4
- data/lib/sanctuary/cli.rb +16 -3
- data/lib/sanctuary/generator.rb +4 -2
- data/lib/sanctuary/reader.rb +4 -0
- data/lib/sanctuary/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36da4e6e9691b357ef0e13df3b1f6037f52962b420830014f83de1cd3d39daee
|
4
|
+
data.tar.gz: f5436aeb654c086f65113e7fbab36a48bdf7f2092dfef373ebf3f8fa07417ec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb55518491cf0f04df78ba3bb49ad0146d541da5abbd2eb62d6eca3cc07e72fa33b1c0a14eacc23faceca49e8d535b45138a81cd7b80424c5a8a29132d75372e
|
7
|
+
data.tar.gz: a21bccba58e56207764e630be32aea2321152b506bb2d910801c5df04dbff365a00fecae2f042277c5aeeaa988770b7da474323e97ec437dc166da83e1cf75da
|
data/lib/sanctuary/cli.rb
CHANGED
@@ -10,14 +10,17 @@ module Sanctuary
|
|
10
10
|
results.each do |result|
|
11
11
|
Generator.start([result[1..-1], '', ''])
|
12
12
|
end
|
13
|
-
elsif ARGV.include?("
|
13
|
+
elsif ARGV.include?("--recipe")
|
14
14
|
result = present_recipe_choices
|
15
|
-
Generator.start([result[1..-1], '', '
|
15
|
+
Generator.start([result[1..-1], '', 'recipe'])
|
16
|
+
elsif ARGV.include?("--script")
|
17
|
+
result = present_script_choices
|
18
|
+
Generator.start([result[1..-1], '', 'script'])
|
16
19
|
else
|
17
20
|
result = present_choices
|
18
21
|
if ARGV.include?("-p")
|
19
22
|
Generator.start([result[1..-1], ARGV.last, ''])
|
20
|
-
|
23
|
+
elsif ARGV.include?("--file")
|
21
24
|
Generator.start([result[1..-1], '', ''])
|
22
25
|
end
|
23
26
|
end
|
@@ -45,6 +48,16 @@ module Sanctuary
|
|
45
48
|
return path + "/" + prompt_choice
|
46
49
|
end
|
47
50
|
|
51
|
+
def self.present_script_choices(path = "")
|
52
|
+
choices = Reader.read_scripts(path)[2..-1].sort
|
53
|
+
prompt = TTY::Prompt.new
|
54
|
+
prompt_choice = prompt.enum_select("Select a template?", choices)
|
55
|
+
if Reader.directory?(path.empty? ? prompt_choice : path + "/" + prompt_choice)
|
56
|
+
return present_recipe_choices(path + "/" + prompt_choice)
|
57
|
+
end
|
58
|
+
return path + "/" + prompt_choice
|
59
|
+
end
|
60
|
+
|
48
61
|
def self.multi_select(path = "")
|
49
62
|
choices = Reader.read_templates(path)[2..-1].sort
|
50
63
|
prompt = TTY::Prompt.new
|
data/lib/sanctuary/generator.rb
CHANGED
@@ -6,19 +6,21 @@ module Sanctuary
|
|
6
6
|
include Thor::Actions
|
7
7
|
argument :template
|
8
8
|
argument :name
|
9
|
-
argument :
|
9
|
+
argument :type
|
10
10
|
|
11
11
|
def self.source_root
|
12
12
|
Sanctuary::HOME_DIR
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_lib_file
|
16
|
-
|
16
|
+
if type == 'recipe'
|
17
17
|
File.open(Sanctuary::HOME_DIR.gsub("templates", "recipes/") + template) do |file|
|
18
18
|
file.each do |line|
|
19
19
|
copy_file "#{line.gsub("||", "/").chomp}", "#{line.split("||")[1..-1].join("/").chomp}"
|
20
20
|
end
|
21
21
|
end
|
22
|
+
elsif type == 'script'
|
23
|
+
system "sh #{Sanctuary::HOME_DIR.gsub("templates", "scripts/")}#{template}"
|
22
24
|
else
|
23
25
|
if name.empty?
|
24
26
|
# only copy the file and not the directory the file resides in
|
data/lib/sanctuary/reader.rb
CHANGED
@@ -11,6 +11,10 @@ module Sanctuary
|
|
11
11
|
Dir.open(HOME_DIR.gsub("templates", "recipes") + "/#{path}").to_a
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.read_scripts(path = "")
|
15
|
+
Dir.open(HOME_DIR.gsub("templates", "scripts") + "/#{path}").to_a
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.directory?(path = "")
|
15
19
|
Pathname.new(HOME_DIR + "/#{path}").directory?
|
16
20
|
end
|
data/lib/sanctuary/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanctuary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin-Kawai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|