sanctuary 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sanctuary/cli.rb +17 -4
- data/lib/sanctuary/generator.rb +14 -5
- 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: b272002de4008edcb3dc5985a67366bfa523a4c50958733e75754eb3e7010710
|
4
|
+
data.tar.gz: 27872f2b7dc30902c64ca71b65906f421b91d865e9beea53675d6d835ef3fa3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae86775d3b68ed9c06b1861b78eaa71c57e785e7b5fe16d916c0b7d68214d1d76f707fcdba7fb51d2ddf8415b49334c536c481fe627de7317d84dea8e6ccc4d9
|
7
|
+
data.tar.gz: bcdab96c2e34d036f453a5e4b0829173f416be85996828956d539d553033abb9c0e44df4d54b66e5e2abbe7c429e15378cb76a1bfbcc58d646dae2f87536dbc1
|
data/Gemfile.lock
CHANGED
data/lib/sanctuary/cli.rb
CHANGED
@@ -8,14 +8,17 @@ module Sanctuary
|
|
8
8
|
if ARGV.include?("-m")
|
9
9
|
results = multi_select
|
10
10
|
results.each do |result|
|
11
|
-
Generator.start([result[1..-1], ''])
|
11
|
+
Generator.start([result[1..-1], '', ''])
|
12
12
|
end
|
13
|
+
elsif ARGV.include?("-r")
|
14
|
+
result = present_recipe_choices
|
15
|
+
Generator.start([result[1..-1], '', 'true'])
|
13
16
|
else
|
14
17
|
result = present_choices
|
15
18
|
if ARGV.include?("-p")
|
16
|
-
Generator.start([result[1..-1], ARGV.last])
|
19
|
+
Generator.start([result[1..-1], ARGV.last, ''])
|
17
20
|
else
|
18
|
-
Generator.start([result[1..-1], ''])
|
21
|
+
Generator.start([result[1..-1], '', ''])
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -26,12 +29,22 @@ module Sanctuary
|
|
26
29
|
choices = Reader.read_templates(path)[2..-1].sort
|
27
30
|
prompt = TTY::Prompt.new
|
28
31
|
prompt_choice = prompt.enum_select("Select a template?", choices)
|
29
|
-
if Reader.directory?(prompt_choice)
|
32
|
+
if Reader.directory?(path.empty? ? prompt_choice : path + "/" + prompt_choice)
|
30
33
|
return present_choices(path + "/" + prompt_choice)
|
31
34
|
end
|
32
35
|
return path + "/" + prompt_choice
|
33
36
|
end
|
34
37
|
|
38
|
+
def self.present_recipe_choices(path = "")
|
39
|
+
choices = Reader.read_recipes(path)[2..-1].sort
|
40
|
+
prompt = TTY::Prompt.new
|
41
|
+
prompt_choice = prompt.enum_select("Select a template?", choices)
|
42
|
+
if Reader.directory?(path.empty? ? prompt_choice : path + "/" + prompt_choice)
|
43
|
+
return present_recipe_choices(path + "/" + prompt_choice)
|
44
|
+
end
|
45
|
+
return path + "/" + prompt_choice
|
46
|
+
end
|
47
|
+
|
35
48
|
def self.multi_select(path = "")
|
36
49
|
choices = Reader.read_templates(path)[2..-1].sort
|
37
50
|
prompt = TTY::Prompt.new
|
data/lib/sanctuary/generator.rb
CHANGED
@@ -6,18 +6,27 @@ module Sanctuary
|
|
6
6
|
include Thor::Actions
|
7
7
|
argument :template
|
8
8
|
argument :name
|
9
|
+
argument :recipe
|
9
10
|
|
10
11
|
def self.source_root
|
11
12
|
Sanctuary::HOME_DIR
|
12
13
|
end
|
13
14
|
|
14
15
|
def create_lib_file
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
unless recipe.empty?
|
17
|
+
File.open(Sanctuary::HOME_DIR.gsub("templates", "recipes/") + template) do |file|
|
18
|
+
file.each do |line|
|
19
|
+
copy_file "#{line.chomp}", "#{line.split("/")[1..-1].join("/").chomp}"
|
20
|
+
end
|
21
|
+
end
|
18
22
|
else
|
19
|
-
|
20
|
-
|
23
|
+
if name.empty?
|
24
|
+
# only copy the file and not the directory the file resides in
|
25
|
+
copy_file "#{template}", "#{template.split("/").last}"
|
26
|
+
else
|
27
|
+
copy_file "#{template}", "#{name + "." + template.split("/").last.split(".").last}"
|
28
|
+
gsub_file "#{name + "." + template.split("/").last.split(".").last}", "#name", name
|
29
|
+
end
|
21
30
|
end
|
22
31
|
end
|
23
32
|
end
|
data/lib/sanctuary/reader.rb
CHANGED
@@ -5,6 +5,10 @@ module Sanctuary
|
|
5
5
|
Dir.open(HOME_DIR + "/#{path}").to_a
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.read_recipes(path = "")
|
9
|
+
Dir.open(HOME_DIR.gsub("templates", "recipes") + "/#{path}").to_a
|
10
|
+
end
|
11
|
+
|
8
12
|
def self.directory?(path = "")
|
9
13
|
Pathname.new(HOME_DIR + "/#{path}").directory?
|
10
14
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin-Kawai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|