Module: Timber::CLI::IO::Messages
Constant Summary collapse
- APP_URL =
"https://app.timber.io"
- DOCS_URL =
"https://timber.io/docs"
- OBTAIN_KEY_DOCS_URL =
"https://timber.io/docs/app/obtain-api-key/"
- REPO_URL =
"https://github.com/timberio/timber-ruby"
- SUPPORT_EMAIL =
"[email protected]"
- TWITTER_HANDLE =
"@timberdotio"
- WEBSITE_URL =
"https://timber.io"
- MAX_LENGTH =
80.freeze
Class Method Summary collapse
- .application_details(app) ⇒ Object
- .bad_experience_message ⇒ Object
- .console_url(app) ⇒ Object
- .contact ⇒ Object
- .copied_to_clipboard ⇒ Object
- .edit_app_url(app) ⇒ Object
- .failed ⇒ Object
- .free_data ⇒ Object
- .git_commands ⇒ Object
- .header ⇒ Object
- .heroku_install(app) ⇒ Object
- .http_environment_variables(api_key) ⇒ Object
- .no_api_key_provided ⇒ Object
- .obtain_key_instructions ⇒ Object
- .separator ⇒ Object
- .spinner(iteration) ⇒ Object
- .success ⇒ Object
- .task_complete(message) ⇒ Object
- .task_failed(message) ⇒ Object
- .task_start(message) ⇒ Object
- .we_love_you_too ⇒ Object
Instance Method Summary collapse
- #application_details(app) ⇒ Object
- #bad_experience_message ⇒ Object
- #console_url(app) ⇒ Object
- #contact ⇒ Object
- #copied_to_clipboard ⇒ Object
- #edit_app_url(app) ⇒ Object
- #failed ⇒ Object
- #free_data ⇒ Object
- #git_commands ⇒ Object
- #header ⇒ Object
- #heroku_install(app) ⇒ Object
- #http_environment_variables(api_key) ⇒ Object
- #no_api_key_provided ⇒ Object
- #obtain_key_instructions ⇒ Object
- #separator ⇒ Object
- #spinner(iteration) ⇒ Object
- #success ⇒ Object
- #task_complete(message) ⇒ Object
- #task_failed(message) ⇒ Object
- #task_start(message) ⇒ Object
- #we_love_you_too ⇒ Object
Class Method Details
.application_details(app) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/timber/cli/io/messages.rb', line 21 def application_details(app) = <<-MESSAGE Woot! Your API 🔑 is valid: #{app.name} (#{app.environment}) on #{app.platform_type} MESSAGE .rstrip end |
.bad_experience_message ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/timber/cli/io/messages.rb', line 32 def = <<-MESSAGE Bummer! That is certainly not the experience we were going for. Could you tell us why you a bad experience? (this will be sent directly to the Timber engineering team) MESSAGE .rstrip end |
.console_url(app) ⇒ Object
51 52 53 54 55 |
# File 'lib/timber/cli/io/messages.rb', line 51 def console_url(app) = <<-MESSAGE Your console URL: https://app.timber.io/organizations/timber/apps/#{app.slug}/console MESSAGE end |
.contact ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/timber/cli/io/messages.rb', line 57 def contact = <<-MESSAGE Website: #{WEBSITE_URL} Documentation: #{DOCS_URL} Support: #{SUPPORT_EMAIL} MESSAGE .rstrip end |
.copied_to_clipboard ⇒ Object
66 67 68 |
# File 'lib/timber/cli/io/messages.rb', line 66 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
.edit_app_url(app) ⇒ Object
28 29 30 |
# File 'lib/timber/cli/io/messages.rb', line 28 def edit_app_url(app) "#{APP_URL}" end |
.failed ⇒ Object
174 175 176 |
# File 'lib/timber/cli/io/messages.rb', line 174 def failed "Failed :(" end |
.free_data ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/timber/cli/io/messages.rb', line 89 def free_data = <<-MESSAGE Get free data: * Get ✨ 250mb✨ for starring our repo: #{IO::ANSI.colorize(REPO_URL, :blue)} * Get ✨ 250mb✨ for tweeting your experience to #{IO::ANSI.colorize(TWITTER_HANDLE, :blue)} MESSAGE .rstrip end |
.git_commands ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/timber/cli/io/messages.rb', line 43 def git_commands = <<-MESSAGE #{ANSI.colorize("git add config/initializers/timber.rb", :blue)} #{ANSI.colorize("git commit -am 'Install the timber logger'", :blue)} MESSAGE .rstrip end |
.header ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/timber/cli/io/messages.rb', line 99 def header = <<-MESSAGE 🌲 Timber.io Ruby Installer - Great Ruby Logging Made *Easy* ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^ /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ MESSAGE .rstrip end |
.heroku_install(app) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/timber/cli/io/messages.rb', line 111 def heroku_install(app) command = "heroku drains:add #{app.heroku_drain_url}" copied = OSHelper.copy_to_clipboard(command) = <<-MESSAGE First, let's setup your Heroku drain. Run this command in a separate window: #{ANSI.colorize(command, :blue)} MESSAGE = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
.http_environment_variables(api_key) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/timber/cli/io/messages.rb', line 70 def http_environment_variables(api_key) command = "export TIMBER_API_KEY=\"#{api_key}\"" copied = OSHelper.copy_to_clipboard(command) = <<-MESSAGE Great! Add this variable to your environment: #{ANSI.colorize(command, :blue)} MESSAGE = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
.no_api_key_provided ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/timber/cli/io/messages.rb', line 129 def no_api_key_provided = <<-MESSAGE Hey there! Welcome to Timber. In order to proceed, you'll need an API key. If you already have one, you can run this installer like: #{ANSI.colorize("bundle exec timber install my-api-key", :blue)} #{obtain_key_instructions} MESSAGE .rstrip end |
.obtain_key_instructions ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/timber/cli/io/messages.rb', line 141 def obtain_key_instructions = <<-MESSAGE Don't have a key? Head over to: #{ANSI.colorize(APP_URL, :blue)} For a simple guide, checkout out: #{ANSI.colorize(OBTAIN_KEY_DOCS_URL, :blue)} If you're stuck, contact us: #{ANSI.colorize(SUPPORT_EMAIL, :blue)} MESSAGE .rstrip end |
.separator ⇒ Object
158 159 160 |
# File 'lib/timber/cli/io/messages.rb', line 158 def separator "--------------------------------------------------------------------------------" end |
.spinner(iteration) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/timber/cli/io/messages.rb', line 162 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
.success ⇒ Object
178 179 180 |
# File 'lib/timber/cli/io/messages.rb', line 178 def success "✓ Success!" end |
.task_complete(message) ⇒ Object
182 183 184 185 186 187 |
# File 'lib/timber/cli/io/messages.rb', line 182 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{}#{dots}#{success}" end |
.task_failed(message) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/timber/cli/io/messages.rb', line 189 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{}#{dots}#{failed}" end |
.task_start(message) ⇒ Object
196 197 198 199 200 |
# File 'lib/timber/cli/io/messages.rb', line 196 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{}" + ("." * remainder) end |
.we_love_you_too ⇒ Object
202 203 204 |
# File 'lib/timber/cli/io/messages.rb', line 202 def we_love_you_too "Thanks! We 💖 you too!" end |
Instance Method Details
#application_details(app) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/timber/cli/io/messages.rb', line 21 def application_details(app) = <<-MESSAGE Woot! Your API 🔑 is valid: #{app.name} (#{app.environment}) on #{app.platform_type} MESSAGE .rstrip end |
#bad_experience_message ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/timber/cli/io/messages.rb', line 32 def = <<-MESSAGE Bummer! That is certainly not the experience we were going for. Could you tell us why you a bad experience? (this will be sent directly to the Timber engineering team) MESSAGE .rstrip end |
#console_url(app) ⇒ Object
51 52 53 54 55 |
# File 'lib/timber/cli/io/messages.rb', line 51 def console_url(app) = <<-MESSAGE Your console URL: https://app.timber.io/organizations/timber/apps/#{app.slug}/console MESSAGE end |
#contact ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/timber/cli/io/messages.rb', line 57 def contact = <<-MESSAGE Website: #{WEBSITE_URL} Documentation: #{DOCS_URL} Support: #{SUPPORT_EMAIL} MESSAGE .rstrip end |
#copied_to_clipboard ⇒ Object
66 67 68 |
# File 'lib/timber/cli/io/messages.rb', line 66 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
#edit_app_url(app) ⇒ Object
28 29 30 |
# File 'lib/timber/cli/io/messages.rb', line 28 def edit_app_url(app) "#{APP_URL}" end |
#failed ⇒ Object
174 175 176 |
# File 'lib/timber/cli/io/messages.rb', line 174 def failed "Failed :(" end |
#free_data ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/timber/cli/io/messages.rb', line 89 def free_data = <<-MESSAGE Get free data: * Get ✨ 250mb✨ for starring our repo: #{IO::ANSI.colorize(REPO_URL, :blue)} * Get ✨ 250mb✨ for tweeting your experience to #{IO::ANSI.colorize(TWITTER_HANDLE, :blue)} MESSAGE .rstrip end |
#git_commands ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/timber/cli/io/messages.rb', line 43 def git_commands = <<-MESSAGE #{ANSI.colorize("git add config/initializers/timber.rb", :blue)} #{ANSI.colorize("git commit -am 'Install the timber logger'", :blue)} MESSAGE .rstrip end |
#header ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/timber/cli/io/messages.rb', line 99 def header = <<-MESSAGE 🌲 Timber.io Ruby Installer - Great Ruby Logging Made *Easy* ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^ /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\ MESSAGE .rstrip end |
#heroku_install(app) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/timber/cli/io/messages.rb', line 111 def heroku_install(app) command = "heroku drains:add #{app.heroku_drain_url}" copied = OSHelper.copy_to_clipboard(command) = <<-MESSAGE First, let's setup your Heroku drain. Run this command in a separate window: #{ANSI.colorize(command, :blue)} MESSAGE = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
#http_environment_variables(api_key) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/timber/cli/io/messages.rb', line 70 def http_environment_variables(api_key) command = "export TIMBER_API_KEY=\"#{api_key}\"" copied = OSHelper.copy_to_clipboard(command) = <<-MESSAGE Great! Add this variable to your environment: #{ANSI.colorize(command, :blue)} MESSAGE = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
#no_api_key_provided ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/timber/cli/io/messages.rb', line 129 def no_api_key_provided = <<-MESSAGE Hey there! Welcome to Timber. In order to proceed, you'll need an API key. If you already have one, you can run this installer like: #{ANSI.colorize("bundle exec timber install my-api-key", :blue)} #{obtain_key_instructions} MESSAGE .rstrip end |
#obtain_key_instructions ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/timber/cli/io/messages.rb', line 141 def obtain_key_instructions = <<-MESSAGE Don't have a key? Head over to: #{ANSI.colorize(APP_URL, :blue)} For a simple guide, checkout out: #{ANSI.colorize(OBTAIN_KEY_DOCS_URL, :blue)} If you're stuck, contact us: #{ANSI.colorize(SUPPORT_EMAIL, :blue)} MESSAGE .rstrip end |
#separator ⇒ Object
158 159 160 |
# File 'lib/timber/cli/io/messages.rb', line 158 def separator "--------------------------------------------------------------------------------" end |
#spinner(iteration) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/timber/cli/io/messages.rb', line 162 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
#success ⇒ Object
178 179 180 |
# File 'lib/timber/cli/io/messages.rb', line 178 def success "✓ Success!" end |
#task_complete(message) ⇒ Object
182 183 184 185 186 187 |
# File 'lib/timber/cli/io/messages.rb', line 182 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{}#{dots}#{success}" end |
#task_failed(message) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/timber/cli/io/messages.rb', line 189 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{}#{dots}#{failed}" end |
#task_start(message) ⇒ Object
196 197 198 199 200 |
# File 'lib/timber/cli/io/messages.rb', line 196 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{}" + ("." * remainder) end |
#we_love_you_too ⇒ Object
202 203 204 |
# File 'lib/timber/cli/io/messages.rb', line 202 def we_love_you_too "Thanks! We 💖 you too!" end |