Class: Suspenders::ProfilerGenerator

Inherits:
Generators::Base show all
Defined in:
lib/suspenders/generators/profiler_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

default_source_root, inherited

Methods included from Actions

#action_mailer_asset_host, #action_mailer_host, #configure_environment, #expand_json, #replace_in_file

Instance Method Details

#add_gemObject


17
18
19
20
# File 'lib/suspenders/generators/profiler_generator.rb', line 17

def add_gem
  gem "rack-mini-profiler", require: false
  Bundler.with_unbundled_env { run "bundle install" }
end

#augment_default_envObject


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/suspenders/generators/profiler_generator.rb', line 5

def augment_default_env
  append_to_file ".sample.env", "RACK_MINI_PROFILER=0\n"
rescue Errno::ENOENT
  create_file ".sample.env", "RACK_MINI_PROFILER=0\n"
rescue Thor::Error => e
  if e.message.match?(/does not appear to exist/)
    create_file ".sample.env", "RACK_MINI_PROFILER=0\n"
  else
    raise
  end
end

#configure_rack_mini_profilerObject


22
23
24
25
26
27
28
29
# File 'lib/suspenders/generators/profiler_generator.rb', line 22

def configure_rack_mini_profiler
  copy_file(
    "rack_mini_profiler.rb",
    "config/initializers/rack_mini_profiler.rb",
    force: false,
    skip: true
  )
end

#update_readmeObject


31
32
33
# File 'lib/suspenders/generators/profiler_generator.rb', line 31

def update_readme
  append_template_to_file "README.md", "partials/profiler_readme.md"
end