sanctuary 0.1.10 → 0.1.11

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: 90ba10ddc4f20c59327de5281997944aad091dda73e207b63fbf0833a10e99df
4
- data.tar.gz: 2b36c0b8ac9e525e750b2d99e54442a8ee3e006434548ceca9cfaa2209bd02cd
3
+ metadata.gz: b272002de4008edcb3dc5985a67366bfa523a4c50958733e75754eb3e7010710
4
+ data.tar.gz: 27872f2b7dc30902c64ca71b65906f421b91d865e9beea53675d6d835ef3fa3c
5
5
  SHA512:
6
- metadata.gz: 6fffe3aab3ae82db3ebe1eee3ce68066889bbbe87b0e241885e6c9e5731d908a4fea322bd52294135682ae67c3202125afaabb19f42e0ef1ac68461c817b6fb1
7
- data.tar.gz: ab6e426fc0aa1820de3f9c6ed916cb329dfecf254a74c2838d6ba24ee9f258538b368011fcb010c70692e3db11aeef8a7aeb8bd28e0b2726b78e65f50f134cef
6
+ metadata.gz: ae86775d3b68ed9c06b1861b78eaa71c57e785e7b5fe16d916c0b7d68214d1d76f707fcdba7fb51d2ddf8415b49334c536c481fe627de7317d84dea8e6ccc4d9
7
+ data.tar.gz: bcdab96c2e34d036f453a5e4b0829173f416be85996828956d539d553033abb9c0e44df4d54b66e5e2abbe7c429e15378cb76a1bfbcc58d646dae2f87536dbc1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanctuary (0.1.9)
4
+ sanctuary (0.1.10)
5
5
  thor (~> 0.2)
6
6
  tty-prompt (~> 0.0)
7
7
 
@@ -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
@@ -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
- if name.empty?
16
- # only copy the file and not the directory the file resides in
17
- copy_file "#{template}", "#{template.split("/").last}"
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
- copy_file "#{template}", "#{name + "." + template.split("/").last.split(".").last}"
20
- gsub_file "#{name + "." + template.split("/").last.split(".").last}", "#name", name
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Sanctuary
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
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.10
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-25 00:00:00.000000000 Z
11
+ date: 2019-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt