Sha256: 18798cc590aaf9ceab3fbc74517dd3d5bda5a0ecd9ee7d765e5421d9cc785565
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
require 'thor/group' module Heartcheck class Generator < Thor::Group include Thor::Actions desc 'generate default files and instructions to use the Heartcheck' argument :framework def self.source_root File.join(File.dirname(__FILE__), 'templates') end def show_framework box framework.capitalize, :green end def generate_initializer template('config.rb', initializer_path) end 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 def include_empty_lines puts "\n\n" end private def instructions(file_name, file_content) box "Include the following content to file #{file_name}" say file_content, :blue end def box(content, color = :red) size = content.size say "#{'=' * (size + 2)}\n #{content}\n#{'=' * (size + 2)}\n", color end def initializer_path case framework when 'rails' then 'config/initializers/heartcheck.rb' when 'padrino', 'sinatra' then 'app/app.rb' end end end end
Version data entries
10 entries across 10 versions & 1 rubygems