sanctuary 0.1.12 → 0.1.17
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/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -11
- data/lib/sanctuary/cli.rb +16 -3
- data/lib/sanctuary/generator.rb +7 -2
- data/lib/sanctuary/reader.rb +6 -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: bbb4358f1bcaf0631a6722056748abe18f0a866ec0cc74303714df08f08f9a4c
|
4
|
+
data.tar.gz: a489a2a59ff9f93c345b6c7d3149933c2acd43adf3cb0af42e72ea88776ede83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa0d2ab1cdcf737ac83599c41c189c04882f1216e3cc4bc861116614892627cf16a95fc7d240f679d43a3e47df6e08ef9f1a0020d8d7daefe82e3823b6e035a0
|
7
|
+
data.tar.gz: 40404b1f5da2d89ae98db0c166f2f3145f02fa39b8d61cbf415d8f2d929ae376b085c13ca3de2b0bc97ee64c6a4524555fd8ba3944e9a735bd341823cf025396
|
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
@@ -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,24 @@ 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
|
+
if Dir.entries(".").include?('sanctuary-post-recipe-copy-hook.sh')
|
23
|
+
system "sh ./sanctuary-post-recipe-copy-hook.sh"
|
24
|
+
end
|
25
|
+
elsif type == 'script'
|
26
|
+
system "sh #{Sanctuary::HOME_DIR.gsub("templates", "scripts/")}#{template}"
|
22
27
|
else
|
23
28
|
if name.empty?
|
24
29
|
# only copy the file and not the directory the file resides in
|
data/lib/sanctuary/reader.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require("pathname")
|
2
|
+
|
1
3
|
module Sanctuary
|
2
4
|
HOME_DIR = Dir.home + "/.sanctuary/templates"
|
3
5
|
class Reader
|
@@ -9,6 +11,10 @@ module Sanctuary
|
|
9
11
|
Dir.open(HOME_DIR.gsub("templates", "recipes") + "/#{path}").to_a
|
10
12
|
end
|
11
13
|
|
14
|
+
def self.read_scripts(path = "")
|
15
|
+
Dir.open(HOME_DIR.gsub("templates", "scripts") + "/#{path}").to_a
|
16
|
+
end
|
17
|
+
|
12
18
|
def self.directory?(path = "")
|
13
19
|
Pathname.new(HOME_DIR + "/#{path}").directory?
|
14
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.17
|
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-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|