sanctuary 0.1.8 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -11
- data/lib/sanctuary/cli.rb +38 -5
- 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: 79bb6b95bb3af7881965ecd8784a1f12b10a56caf12f31ec59625d7d72815ab3
|
4
|
+
data.tar.gz: 7184bb6bcb331d4eb55bc2339cf744593fbd6fa385efa53a074bce9a3bcef1f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b30985e818e3d90f5c4f8a41187e3d799d7fffbbbb2a894b7cbe3559880b3c564fab9ae9c9d3e2d4e6c5b1a0c6504a2e4e4ea4a35e8b610149a33f0091daaf4c
|
7
|
+
data.tar.gz: 92de7a9a904585e21231240eeb5d32e94f0a0ec0abcc84253ec45716a7e55f531725f0c64a46c0a2143f39dd5c567f48e7d3ff5a1b710d3066e61ef9f75c89d2
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
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
|
-
|
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).
|
data/lib/sanctuary/cli.rb
CHANGED
@@ -5,11 +5,21 @@ require_relative "reader"
|
|
5
5
|
module Sanctuary
|
6
6
|
class CLI
|
7
7
|
def self.start
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
if ARGV.include?("-m")
|
9
|
+
results = multi_select
|
10
|
+
results.each do |result|
|
11
|
+
Generator.start([result[1..-1], '', ''])
|
12
|
+
end
|
13
|
+
elsif ARGV.include?("-r")
|
14
|
+
result = present_recipe_choices
|
15
|
+
Generator.start([result[1..-1], '', 'true'])
|
11
16
|
else
|
12
|
-
|
17
|
+
result = present_choices
|
18
|
+
if ARGV.include?("-p")
|
19
|
+
Generator.start([result[1..-1], ARGV.last, ''])
|
20
|
+
else
|
21
|
+
Generator.start([result[1..-1], '', ''])
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
|
@@ -19,10 +29,33 @@ module Sanctuary
|
|
19
29
|
choices = Reader.read_templates(path)[2..-1].sort
|
20
30
|
prompt = TTY::Prompt.new
|
21
31
|
prompt_choice = prompt.enum_select("Select a template?", choices)
|
22
|
-
if Reader.directory?(prompt_choice)
|
32
|
+
if Reader.directory?(path.empty? ? prompt_choice : path + "/" + prompt_choice)
|
23
33
|
return present_choices(path + "/" + prompt_choice)
|
24
34
|
end
|
25
35
|
return path + "/" + prompt_choice
|
26
36
|
end
|
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
|
+
|
48
|
+
def self.multi_select(path = "")
|
49
|
+
choices = Reader.read_templates(path)[2..-1].sort
|
50
|
+
prompt = TTY::Prompt.new
|
51
|
+
prompt_choices = prompt.multi_select("Select a templates", choices)
|
52
|
+
if Reader.directory?(prompt_choices[0])
|
53
|
+
return multi_select(path + "/" + prompt_choices[0])
|
54
|
+
end
|
55
|
+
|
56
|
+
prompt_choices.map do |choice|
|
57
|
+
path + "/" + choice
|
58
|
+
end
|
59
|
+
end
|
27
60
|
end
|
28
61
|
end
|
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.gsub("||", "/").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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin-Kawai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|