Sha256: 9aa890938f81fa2d2c9fac9e335dd8f5be8407be6a3f6a379b2486e72f965141

Contents?: true

Size: 1.23 KB

Versions: 21

Compression:

Stored size: 1.23 KB

Contents

begin
  require "lograge"
rescue Exception
end

require "timber/cli/config_file"
require "timber/cli/installer"
require "timber/cli/io/messages"

module Timber
  class CLI
    module Installers
      class ConfigFile < Installer
        def run(app, path)
          config_file = Timber::CLI::ConfigFile.new(path, file_helper)

          if config_file.exists?
            io.task_complete("#{config_file.path} already created")
            return true
          end

          if lograge?
            task_message = "Enabling logrageify in #{config_file.path}"
            io.task(task_message) { config_file.logrageify! }
          elsif action_view?
            task_message = "Silencing template renders in #{config_file.path}"
            io.task(task_message) { config_file.silence_template_renders! }
          end

          task_message = "Creating #{config_file.path}"
          io.task(task_message) { config_file.create! }
        end

        private
          def lograge?
            require "lograge"
            true
          rescue Exception
            false
          end

          def action_view?
            require("action_view")
            true
          rescue Exception
            false
          end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
timber-2.1.7 lib/timber/cli/installers/config_file.rb