Sha256: d2fd189bff391041e6bcd1ccdf065e2bc3a07d95d98cf985140c33881d6c583e

Contents?: true

Size: 1.79 KB

Versions: 17

Compression:

Stored size: 1.79 KB

Contents

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

module Timber
  class CLI
    module Installers
      class Other < Installer
        def run(app)
          if app.heroku?
            install_stdout
          else
            api_key_storage_preference = get_api_key_storage_preference
            api_key_code = get_api_key_code(api_key_storage_preference)
            install_http(api_key_code)
          end

          ask_to_proceed
        end

        private
          def install_stdout
            io.puts ""
            io.puts IO::Messages.separator
            io.puts ""
            io.puts "To integrate Timber, simply use the Timber::Logger. Just set your"
            io.puts "global logger to something like this:"
            io.puts ""
            io.puts IO::ANSI.colorize("    LOGGER = Timber::Logger.new(STDOUT)", :blue)
            io.puts ""
            io.ask_to_proceed
          end

          def install_http(api_key_code)
            io.puts ""
            io.puts IO::Messages.separator
            io.puts ""
            io.puts "To integrate Timber, simply use the Timber::Logger. Just set your"
            io.puts "global logger to something like this:"
            io.puts ""
            io.puts IO::ANSI.colorize("    log_device = Timber::LogDevices::HTTP.new(#{api_key_code})", :blue)
            io.puts IO::ANSI.colorize("    LOGGER = Timber::Logger.new(log_device)", :blue)
            io.puts ""
            io.ask_to_proceed
          end

          def ask_to_proceed
            io.puts ""
            io.puts IO::Messages.separator
            io.puts ""
            io.puts "We're going to send a few test messages to ensure communication is working."
            io.puts ""
            io.ask_to_proceed
            io.puts ""
          end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
timber-2.2.2 lib/timber/cli/installers/other.rb
timber-2.2.1 lib/timber/cli/installers/other.rb
timber-2.2.0 lib/timber/cli/installers/other.rb
timber-2.1.10 lib/timber/cli/installers/other.rb
timber-2.1.9 lib/timber/cli/installers/other.rb
timber-2.1.8 lib/timber/cli/installers/other.rb
timber-2.1.7 lib/timber/cli/installers/other.rb
timber-2.1.6 lib/timber/cli/installers/other.rb
timber-2.1.5 lib/timber/cli/installers/other.rb
timber-2.1.4 lib/timber/cli/installers/other.rb
timber-2.1.3 lib/timber/cli/installers/other.rb
timber-2.1.2 lib/timber/cli/installers/other.rb
timber-2.1.1 lib/timber/cli/installers/other.rb
timber-2.1.0 lib/timber/cli/installers/other.rb
timber-2.1.0.rc6 lib/timber/cli/installers/other.rb
timber-2.1.0.rc5 lib/timber/cli/installers/other.rb
timber-2.1.0.rc4 lib/timber/cli/installers/other.rb