Class: Oboe::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/oboe/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rails/generators/oboe/install_generator.rb', line 9

def copy_initializer
  # Set defaults
  @tracing_mode = 'through'
  @sample_rate = '300000'
  @verbose = 'false'

  print_header

  while true do
    print_body

    user_tracing_mode = ask shell.set_color "* Tracing Mode? [through]:", :yellow
    user_tracing_mode.downcase!

    break if user_tracing_mode.blank?
    valid = ['always', 'through', 'never'].include?(user_tracing_mode)
    
    say shell.set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
    if valid
      @tracing_mode = user_tracing_mode
      break
    end
  end

  print_footer

  template "oboe_initializer.rb", "config/initializers/oboe.rb"
end