gem-wizard 0.0.2 → 0.2.0
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/bin/{gem-wizard → gem-wizard-start} +0 -0
- data/lib/gem_wizard.rb +36 -34
- data/lib/gems.json +27 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0308f010276c86971acb8eeff4c0bea275a307e2dde8d39e93e544225dae295
|
4
|
+
data.tar.gz: 2b0ef8d841129b958c1b35b222411835ea02dcb18d7da1a2e19a4368b7c0ea97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5e3c8744359d39c844d5cb17a766ca1383c245b34e3de28254e9795fb035be27a8ad2f6e3458cce4d7d0115c91e296b156f276cb26e7c7ea642ee39080b7d3
|
7
|
+
data.tar.gz: cd53651c2cad1d34b8fcc49f5d6544f0dc8d3d41141cbd81f7988a8889c6e155642bcaedcbac74500ad36244a4166fb0c3ff1487a185df8da2f929122876a26b
|
File without changes
|
data/lib/gem_wizard.rb
CHANGED
@@ -1,52 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
class GemWizard
|
2
4
|
|
5
|
+
#----- asking the right questions -----#
|
3
6
|
def self.start
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@advanced_better_errors = false
|
8
|
-
@hashid = false
|
7
|
+
file_path = File.join( File.dirname(__FILE__), 'gems.json')
|
8
|
+
file = File.read(file_path)
|
9
|
+
gems = JSON.parse(file)
|
9
10
|
|
10
|
-
|
11
|
+
@pre_install_commands = []
|
12
|
+
@post_install_commands = []
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
gems.each do |gem|
|
15
|
+
puts gem['prompt']
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
if boolean(gets.chomp)
|
18
|
+
gem_groups = gem['gem_groups'].join(' ') unless gem['gem_groups'].nil?
|
19
|
+
command = "bundle add #{gem['name']} #{!gem_groups.nil? ? "--group #{gem_groups}" : nil}"
|
17
20
|
|
18
|
-
|
19
|
-
puts 'Do you want to use haml views instead of erb? [Y/N]'
|
20
|
-
@use_haml = true if %w[Y y].include?(gets.chomp)
|
21
|
-
|
22
|
-
puts 'Convert all existing view files to haml? [Y/N]'
|
23
|
-
@convert_to_haml = true if %w[Y y].include?(gets.chomp)
|
24
|
-
end
|
21
|
+
@pre_install_commands << command
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
ask_sub_prompts(gem['sub_prompts'])
|
24
|
+
end
|
25
|
+
end
|
29
26
|
|
30
|
-
|
31
|
-
@advanced_better_errors = true if %w[Y y].include?(gets.chomp)
|
27
|
+
gemify!
|
32
28
|
end
|
33
29
|
|
34
|
-
def self.
|
35
|
-
|
36
|
-
|
30
|
+
def self.ask_sub_prompts(sub_prompts)
|
31
|
+
sub_prompts.each do |prompt|
|
32
|
+
puts prompt['message']
|
33
|
+
|
34
|
+
if boolean(gets.chomp)
|
35
|
+
@pre_install_commands << prompt['pre_install_commands'] unless prompt['pre_install_commands'].nil?
|
36
|
+
@post_install_commands << prompt['post_install_commands'] unless prompt['post_install_commands'].nil?
|
37
|
+
end
|
38
|
+
end
|
37
39
|
end
|
38
40
|
|
41
|
+
#----- where the magic happens -----#
|
39
42
|
def self.gemify!
|
40
|
-
|
41
|
-
system('bundle add haml-rails') if @use_haml
|
42
|
-
system('bundle add better_errors') if @better_errors
|
43
|
-
system('bundle add binding_of_caller') if @advanced_better_errors
|
44
|
-
system('hashid-rails') if @hashid
|
45
|
-
|
46
|
-
# install gems
|
43
|
+
system(@pre_install_commands.flatten.join(' '))
|
47
44
|
system('bundle install')
|
45
|
+
system(@post_install_commands.flatten.join(' '))
|
46
|
+
end
|
47
|
+
|
48
|
+
#----- helper methods -----#
|
49
|
+
def self.boolean(string)
|
50
|
+
return true if 'y'.casecmp(string).zero? || 'yes'.casecmp(string).zero? || 'true'.casecmp(string).zero?
|
48
51
|
|
49
|
-
|
50
|
-
system('HAML_RAILS_DELETE_ERB=true rails haml:erb2haml') if @convert_to_haml
|
52
|
+
false
|
51
53
|
end
|
52
54
|
end
|
data/lib/gems.json
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "haml-rails",
|
4
|
+
"prompt": "Do you want to use haml views instead of erb? [Y/N]",
|
5
|
+
"sub_prompts": [
|
6
|
+
{
|
7
|
+
"message": "Convert all existing view files to haml? [Y/N]",
|
8
|
+
"post_install_commands:": [
|
9
|
+
"HAML_RAILS_DELETE_ERB=true rails haml:erb2haml"
|
10
|
+
]
|
11
|
+
}
|
12
|
+
]
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "better_errors",
|
16
|
+
"gem_groups": ["development"],
|
17
|
+
"prompt": "Do you want to use better errors to view errors on the browser? [Y/N]",
|
18
|
+
"sub_prompts": [
|
19
|
+
{
|
20
|
+
"message": "Do you want to use advanced features like REPL, local/instance variable inspection and pretty stack frame names? [Y/N]",
|
21
|
+
"pre_install_commands:": [
|
22
|
+
"bundle add binding_of_caller --group 'development'"
|
23
|
+
]
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-wizard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Paul
|
@@ -9,16 +9,31 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-07-28 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.1
|
13
27
|
description: Install and setup essential gems for a rails application.
|
14
28
|
email: john@rockfort.city
|
15
29
|
executables:
|
16
|
-
- gem-wizard
|
30
|
+
- gem-wizard-start
|
17
31
|
extensions: []
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
20
|
-
- bin/gem-wizard
|
34
|
+
- bin/gem-wizard-start
|
21
35
|
- lib/gem_wizard.rb
|
36
|
+
- lib/gems.json
|
22
37
|
homepage:
|
23
38
|
licenses:
|
24
39
|
- MIT
|