gem-wizard 0.0.2 → 0.1.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/gems.json +14 -0
- data/lib/gem_wizard.rb +25 -34
- 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: c9f1aa5185cb36ab4192c009056224ff587a103610f02618d1737dfc6144560b
|
4
|
+
data.tar.gz: 8ebd83ba2902d3eda43e90860659c04f22ce0aa974c405eb6a72bfc2b790cfa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7ee4da89959f7b5a417cc95d248103926886dfd15bb338d69c48981ae267552719debd05fbf3e5bef75775b41b6d56167a29c6ad987d8e745d7e87cc3f1eb65
|
7
|
+
data.tar.gz: 86957fc2f526a5994b4ec91d73c61d12dfcb3767230dd5d17eefbedcd4415433421128469639a381eac6a09c4a4d893f7e369333ccec357182b07e3a53baa0e5
|
File without changes
|
data/gems.json
ADDED
@@ -0,0 +1,14 @@
|
|
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
|
+
"commands_if_accepted:": [
|
9
|
+
"HAML_RAILS_DELETE_ERB=true rails haml:erb2haml"
|
10
|
+
]
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
]
|
data/lib/gem_wizard.rb
CHANGED
@@ -1,52 +1,43 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
class GemWizard
|
2
4
|
|
5
|
+
#----- asking the right questions -----#
|
3
6
|
def self.start
|
4
|
-
|
5
|
-
|
6
|
-
@better_errors = false
|
7
|
-
@advanced_better_errors = false
|
8
|
-
@hashid = false
|
7
|
+
file = File.read('./gems.json')
|
8
|
+
gems = JSON.parse(file)
|
9
9
|
|
10
|
-
|
10
|
+
@post_install_commands = []
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
gems.each do |gem|
|
13
|
+
puts gem['prompt']
|
14
14
|
|
15
|
-
|
16
|
-
end
|
15
|
+
system("bundle add #{gem['name']}") if boolean(gets.chomp)
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
@use_haml = true if %w[Y y].include?(gets.chomp)
|
17
|
+
ask_sub_prompts(gem['sub_prompts'])
|
18
|
+
end
|
21
19
|
|
22
|
-
|
23
|
-
@convert_to_haml = true if %w[Y y].include?(gets.chomp)
|
20
|
+
gemify!
|
24
21
|
end
|
25
22
|
|
26
|
-
def self.
|
27
|
-
|
28
|
-
|
23
|
+
def self.ask_sub_prompts(sub_prompts)
|
24
|
+
sub_prompts.each do |prompt|
|
25
|
+
puts prompt['message']
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.hashid
|
35
|
-
puts 'Want to use hashid for record ids?'
|
36
|
-
@hashid = true if %w[Y y].include?(gets.chomp)
|
27
|
+
@post_install_commands << prompt['commands_if_accepted'] if boolean(gets.chomp)
|
28
|
+
end
|
37
29
|
end
|
38
30
|
|
31
|
+
#----- where the magic happens -----#
|
39
32
|
def self.gemify!
|
40
|
-
# add gems to gemfile
|
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
|
47
33
|
system('bundle install')
|
34
|
+
system(@post_install_commands.flatten.join(' '))
|
35
|
+
end
|
36
|
+
|
37
|
+
#----- helper methods -----#
|
38
|
+
def self.boolean(string)
|
39
|
+
return true if 'y'.casecmp(string).zero? || 'yes'.casecmp(string).zero? || 'true'.casecmp(string).zero?
|
48
40
|
|
49
|
-
|
50
|
-
system('HAML_RAILS_DELETE_ERB=true rails haml:erb2haml') if @convert_to_haml
|
41
|
+
false
|
51
42
|
end
|
52
43
|
end
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Paul
|
@@ -9,15 +9,30 @@ 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
|
35
|
+
- gems.json
|
21
36
|
- lib/gem_wizard.rb
|
22
37
|
homepage:
|
23
38
|
licenses:
|