Class: GemWizard

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_wizard.rb

Class Method Summary collapse

Class Method Details

.better_errorsObject



26
27
28
29
30
31
32
# File 'lib/gem_wizard.rb', line 26

def self.better_errors
  puts 'Do you want to use better errros gem to view errors in the browser? [Y/N]'
  @better_errors = true if %w[Y y].include?(gets.chomp)

  puts 'Want to use advanced better error features like REPL, local/instance variable inspection, pretty stack frame names?'
  @advanced_better_errors = true if %w[Y y].include?(gets.chomp)
end

.gemify!Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/gem_wizard.rb', line 39

def self.gemify!
  # add gems to gemfile
  system('bundle add haml-rails') if @use_haml
  system('bundle add better_errors') if @better_errors
  system('bundle add binding_of_caller') if @advanced_better_errors
  system('hashid-rails') if @hashid

  # install gems
  system('bundle install')

  # post install setup
  system('HAML_RAILS_DELETE_ERB=true rails haml:erb2haml') if @convert_to_haml
end

.haml_railsObject



18
19
20
21
22
23
24
# File 'lib/gem_wizard.rb', line 18

def self.haml_rails
  puts 'Do you want to use haml views instead of erb? [Y/N]'
  @use_haml = true if %w[Y y].include?(gets.chomp)

  puts 'Convert all existing view files to haml? [Y/N]'
  @convert_to_haml = true if %w[Y y].include?(gets.chomp)
end

.hashidObject



34
35
36
37
# File 'lib/gem_wizard.rb', line 34

def self.hashid
  puts 'Want to use hashid for record ids?'
  @hashid = true if %w[Y y].include?(gets.chomp)
end

.startObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gem_wizard.rb', line 3

def self.start
  @use_haml = false
  @convert_to_haml = false
  @better_errors = false
  @advanced_better_errors = false
  @hashid = false

  puts 'Hello! Welcome to GemWizard. Lets setup some essential gems.'

  haml_rails
  better_errors

  gemify!
end