sanctuary 0.1.10 → 0.1.15

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: bbd36291ce5f4a252abad455e401ac4d267c131a704592806c3485d6c8bcd1a7
4
+ data.tar.gz: 74eab0d68cc9972018ee20f30e646cdf1309fa7176599c3521ecf7e309984c61
5
5
  SHA512:
6
- metadata.gz: 6fffe3aab3ae82db3ebe1eee3ce68066889bbbe87b0e241885e6c9e5731d908a4fea322bd52294135682ae67c3202125afaabb19f42e0ef1ac68461c817b6fb1
7
- data.tar.gz: ab6e426fc0aa1820de3f9c6ed916cb329dfecf254a74c2838d6ba24ee9f258538b368011fcb010c70692e3db11aeef8a7aeb8bd28e0b2726b78e65f50f134cef
6
+ metadata.gz: 99e4e98cfaf716caa7c840b6c1d896802fedc1ab5d2180a3e5d78fe27e5b53ef4485fe73c37efbf4f5acbca66722357441355b72fee495e92c553f68ca5a0e55
7
+ data.tar.gz: 4f5bb871ccba555a8d66e8cf87bd402877565ffa87c660f10e4dc9ac126eaa6d025bc68e02d188aa9e3255b436704305c7210c47c1434927914014a54b3370eb
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  *.gem
10
- /.idea
10
+ /.idea
11
+ TODO.md
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanctuary (0.1.9)
4
+ sanctuary (0.1.12)
5
5
  thor (~> 0.2)
6
6
  tty-prompt (~> 0.0)
7
7
 
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Sanctuary
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sanctuary`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -22,22 +18,16 @@ Or install it yourself as:
22
18
 
23
19
  ## Usage
24
20
 
25
- TODO: Write usage instructions here
26
21
 
27
22
  ## Development
28
23
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+ Use `./bin/sanctuary` to run the app.
32
25
 
33
26
  ## Contributing
34
27
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sanctuary. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
28
 
37
29
  ## License
38
30
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
31
 
41
32
  ## Code of Conduct
42
33
 
43
- Everyone interacting in the Sanctuary project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sanctuary/blob/master/CODE_OF_CONDUCT.md).
@@ -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.gsub("||", "/").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
@@ -1,3 +1,5 @@
1
+ require("pathname")
2
+
1
3
  module Sanctuary
2
4
  HOME_DIR = Dir.home + "/.sanctuary/templates"
3
5
  class Reader
@@ -5,6 +7,10 @@ module Sanctuary
5
7
  Dir.open(HOME_DIR + "/#{path}").to_a
6
8
  end
7
9
 
10
+ def self.read_recipes(path = "")
11
+ Dir.open(HOME_DIR.gsub("templates", "recipes") + "/#{path}").to_a
12
+ end
13
+
8
14
  def self.directory?(path = "")
9
15
  Pathname.new(HOME_DIR + "/#{path}").directory?
10
16
  end
@@ -1,3 +1,3 @@
1
1
  module Sanctuary
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.15"
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.15
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: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt