gem-wizard 0.1.0 → 0.2.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gem_wizard.rb +20 -4
  3. data/lib/gems.json +27 -0
  4. metadata +2 -2
  5. data/gems.json +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9f1aa5185cb36ab4192c009056224ff587a103610f02618d1737dfc6144560b
4
- data.tar.gz: 8ebd83ba2902d3eda43e90860659c04f22ce0aa974c405eb6a72bfc2b790cfa4
3
+ metadata.gz: 7ffab99fc4d966a8b8892e22efddacfcfee2f3d24fdcaddf896cd7c5c3b23d1d
4
+ data.tar.gz: 761b41cf68af8ebf89732ef88a040ebe9d4e3327a2e9b2e5b4bf14b5502a7bf2
5
5
  SHA512:
6
- metadata.gz: b7ee4da89959f7b5a417cc95d248103926886dfd15bb338d69c48981ae267552719debd05fbf3e5bef75775b41b6d56167a29c6ad987d8e745d7e87cc3f1eb65
7
- data.tar.gz: 86957fc2f526a5994b4ec91d73c61d12dfcb3767230dd5d17eefbedcd4415433421128469639a381eac6a09c4a4d893f7e369333ccec357182b07e3a53baa0e5
6
+ metadata.gz: a5e2cade34ccd43d2ba68bbc3f50497998626c4f02f744a50a4d5c9dbe1205f9116fe7f52d66f3aad52ea1c25654ed2e40ade3c3370b37da8f42ca334d7aab1c
7
+ data.tar.gz: 400eb905f2e148ae675c9a329ecc9ec812d9baef77dfe7e5c47c757ac8db174ff74f0834e413a99873d72d4a9787f6a897b3bd95d07382d5646303196c04524c
data/lib/gem_wizard.rb CHANGED
@@ -4,15 +4,21 @@ class GemWizard
4
4
 
5
5
  #----- asking the right questions -----#
6
6
  def self.start
7
- file = File.read('./gems.json')
7
+ file_path = File.join( File.dirname(__FILE__), 'gems.json')
8
+ file = File.read(file_path)
8
9
  gems = JSON.parse(file)
9
10
 
11
+ @pre_install_commands = []
10
12
  @post_install_commands = []
11
13
 
12
14
  gems.each do |gem|
13
15
  puts gem['prompt']
14
16
 
15
- system("bundle add #{gem['name']}") if boolean(gets.chomp)
17
+ next unless boolean(gets.chomp)
18
+
19
+ gem_groups = gem['gem_groups'].join(' ') unless gem['gem_groups'].nil?
20
+ command = "bundle add #{gem['name']} #{!gem_groups.nil? ? "--group #{gem_groups}" : nil}"
21
+ @pre_install_commands << command
16
22
 
17
23
  ask_sub_prompts(gem['sub_prompts'])
18
24
  end
@@ -24,14 +30,24 @@ class GemWizard
24
30
  sub_prompts.each do |prompt|
25
31
  puts prompt['message']
26
32
 
27
- @post_install_commands << prompt['commands_if_accepted'] if boolean(gets.chomp)
33
+ if boolean(gets.chomp)
34
+ @pre_install_commands << prompt['pre_install_commands'] unless prompt['pre_install_commands'].nil?
35
+ @post_install_commands << prompt['post_install_commands'] unless prompt['post_install_commands'].nil?
36
+ end
28
37
  end
29
38
  end
30
39
 
31
40
  #----- where the magic happens -----#
32
41
  def self.gemify!
42
+ @pre_install_commands.each do |command|
43
+ system(command)
44
+ end
45
+
33
46
  system('bundle install')
34
- system(@post_install_commands.flatten.join(' '))
47
+
48
+ @post_install_commands.each do |command|
49
+ system(command)
50
+ end
35
51
  end
36
52
 
37
53
  #----- helper methods -----#
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.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Paul
@@ -32,8 +32,8 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - bin/gem-wizard-start
35
- - gems.json
36
35
  - lib/gem_wizard.rb
36
+ - lib/gems.json
37
37
  homepage:
38
38
  licenses:
39
39
  - MIT
data/gems.json DELETED
@@ -1,14 +0,0 @@
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
- ]