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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44435541b7eaa93e45698d18842ae87cd42155265fff177e2204f047203cb710
4
- data.tar.gz: e398cc84425b4f95d8ba3acb0c30268cabc6b23390407a195f3fde226af590df
3
+ metadata.gz: c0308f010276c86971acb8eeff4c0bea275a307e2dde8d39e93e544225dae295
4
+ data.tar.gz: 2b0ef8d841129b958c1b35b222411835ea02dcb18d7da1a2e19a4368b7c0ea97
5
5
  SHA512:
6
- metadata.gz: '05659bd7759708ab472e6bf97dcf5f198b5826e874a6a6d301c71057b81ed82f9fd82f85a543fab3497eb31b9475f5194ef015483b016289f8c1b9b6aa7480bb'
7
- data.tar.gz: d156d6ac9db3d621222f9982ef23edd93e52b678a7f88fa0032e3019ed81e1abddc608b1e6b8c49a7246540b44ec0e12e8cfd4a7d4b7e8ba331396a5a09a4c42
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
- @use_haml = false
5
- @convert_to_haml = false
6
- @better_errors = false
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
- puts 'Hello! Welcome to GemWizard. Lets setup some essential gems.'
11
+ @pre_install_commands = []
12
+ @post_install_commands = []
11
13
 
12
- haml_rails
13
- better_errors
14
+ gems.each do |gem|
15
+ puts gem['prompt']
14
16
 
15
- gemify!
16
- end
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
- def self.haml_rails
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
- def self.better_errors
27
- puts 'Do you want to use better errros gem to view errors in the browser? [Y/N]'
28
- @better_errors = true if %w[Y y].include?(gets.chomp)
23
+ ask_sub_prompts(gem['sub_prompts'])
24
+ end
25
+ end
29
26
 
30
- puts 'Want to use advanced better error features like REPL, local/instance variable inspection, pretty stack frame names?'
31
- @advanced_better_errors = true if %w[Y y].include?(gets.chomp)
27
+ gemify!
32
28
  end
33
29
 
34
- def self.hashid
35
- puts 'Want to use hashid for record ids?'
36
- @hashid = true if %w[Y y].include?(gets.chomp)
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
- # 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
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
- # post install setup
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.2
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