gem-wizard 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8722cfef1601c110b1ec49089abf5c8d7072853dcc94ed92b258fde38998e93f
4
- data.tar.gz: 1717fe571b2de4dc7032030db77ca7025b34cce085bd92449addce2b2bcf8462
3
+ metadata.gz: 7610f896cb1e67c4986c3210058b3ec2fe07e5580d113fe864fdd7f89ff88304
4
+ data.tar.gz: 3346f06c038f59f03cf1706810a8d2097b8699abdce14f9a73dc8f4178ba6a60
5
5
  SHA512:
6
- metadata.gz: 7dfc33e6d3b911223e65b7a629ddc1237707814ac7404614db4e45b2b67319c3b22dd48f0ab11e9d1bae3c8b67df57b78da89b7892633b5f5b2c369f9d2c9c53
7
- data.tar.gz: ac526ac84afaca7e52a22af5fc686f2d3d433f1edd083457c68619b621a480fa1e24a415abc088f3f2a12b84a6a55e02428d10c4e647677e98cb57a8e79baf6b
6
+ metadata.gz: 2fa42d2c17b6513383d776ac2dbbb5b1501972e133ce55f73f43d2cc4aa1f6614b7bd6e68843a7659b6744de98f3907aae9c88d4758fd035b65edf74521b5116
7
+ data.tar.gz: aa5ac997985f27eb67aed5236a0bc560522a771c5d045df4a2289fe0f07eb8b5c375a8dec7c319900cd19e83a4cdf69bafc4a1e75e71227bb5b7578722709d33
File without changes
data/lib/gem_wizard.rb CHANGED
@@ -1,27 +1,44 @@
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
7
+ file_path = File.join( File.dirname(__FILE__), 'gems.json')
8
+ file = File.read(file_path)
9
+ gems = JSON.parse(file)
10
+
11
+ @post_install_commands = []
12
+
13
+ gems.each do |gem|
14
+ puts gem['prompt']
6
15
 
7
- puts "Hello! Let's gemify your rails application install some essential gems."
16
+ system("bundle add #{gem['name']}") if boolean(gets.chomp)
8
17
 
9
- setup_haml
18
+ ask_sub_prompts(gem['sub_prompts'])
19
+ end
10
20
 
11
21
  gemify!
12
22
  end
13
23
 
14
- def self.setup_haml
15
- puts "Do you want to use haml views instead of erb? [Y/N]"
16
- @use_haml = true if gets.chomp == 'Y' || 'y'
24
+ def self.ask_sub_prompts(sub_prompts)
25
+ sub_prompts.each do |prompt|
26
+ puts prompt['message']
17
27
 
18
- puts "Convert all existing view files to haml? [Y/N]"
19
- @convert_to_haml = true if gets.chomp == 'Y' || 'y'
28
+ @post_install_commands << prompt['commands_if_accepted'] if boolean(gets.chomp)
29
+ end
20
30
  end
21
31
 
32
+ #----- where the magic happens -----#
22
33
  def self.gemify!
23
- system('bundle add haml-rails') if @use_haml == true
24
34
  system('bundle install')
25
- system('HAML_RAILS_DELETE_ERB=true rails haml:erb2haml')
35
+ system(@post_install_commands.flatten.join(' '))
36
+ end
37
+
38
+ #----- helper methods -----#
39
+ def self.boolean(string)
40
+ return true if 'y'.casecmp(string).zero? || 'yes'.casecmp(string).zero? || 'true'.casecmp(string).zero?
41
+
42
+ false
26
43
  end
27
- end
44
+ end
data/lib/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
+ ]
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.1
4
+ version: 0.1.1
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