Sha256: 5a3eddeaeeac4d81ea16c0eccf9eb1242f04fb6b9b55d58fa8343913030e715c

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 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.puts ""
            io.task_complete("#{config_file.path} already created")
            return true
          end

          if logrageify?
            config_file.logrageify!
          end

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

        private
          def logrageify?
            if defined?(::Lograge)
              io.puts ""
              io.puts IO::Messages.separator
              io.puts ""
              io.puts "We noticed you have lograge installed. Would you like to configure "
              io.puts "Timber to function similarly?"
              io.puts "(This silences template renders, sql queries, and controller calls."
              io.puts "You can always do this later in config/initialzers/timber.rb)"
              io.puts ""
              io.puts "y) Yes, configure Timber like lograge", :blue
              io.puts "n) No, use the Rails logging defaults", :blue
              io.puts ""

              case io.ask_yes_no("Enter your choice:", event_prompt: "Logrageify?")
              when :yes
                true
              when :no
                false
              end
            else
              false
            end
          end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
timber-2.1.4 lib/timber/cli/installers/config_file.rb
timber-2.1.3 lib/timber/cli/installers/config_file.rb
timber-2.1.2 lib/timber/cli/installers/config_file.rb
timber-2.1.1 lib/timber/cli/installers/config_file.rb
timber-2.1.0 lib/timber/cli/installers/config_file.rb
timber-2.1.0.rc6 lib/timber/cli/installers/config_file.rb