Class: Heartcheck::Generator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/heartcheck/generators/generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject


11
12
13
# File 'lib/heartcheck/generators/generator.rb', line 11

def self.source_root
  File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#generate_initializerObject


19
20
21
# File 'lib/heartcheck/generators/generator.rb', line 19

def generate_initializer
  template('config.rb', initializer_path)
end

#generate_routeObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/heartcheck/generators/generator.rb', line 23

def generate_route
  case framework
  when 'rails'
    instructions(
      'config/routes.rb',
      'mount Heartcheck::App.new, at: "/monitoring"'
    )
  when 'padrino', 'sinatra'
    instructions(
      'config.ru', %(require "heartcheck"
map "/monitoring" do
  use Heartcheck::App
end)
    )
  end
end

#include_empty_linesObject


40
41
42
# File 'lib/heartcheck/generators/generator.rb', line 40

def include_empty_lines
  puts "\n\n"
end

#show_frameworkObject


15
16
17
# File 'lib/heartcheck/generators/generator.rb', line 15

def show_framework
  box framework.capitalize, :green
end