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 27 28 29 |
# File 'lib/timber/cli/io/messages.rb', line 21 def application_details(app) = "Woot! Your API \u{1F511} is valid:\n\nName: \#{app.name} (\#{app.environment})\nPlatform: \#{app.platform_type}\n" .rstrip end |
.bad_experience_message ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/timber/cli/io/messages.rb', line 35 def = "Bummer! That is certainly not the experience we were going for.\n\nCould you tell us why you a bad experience?\n\n(this will be sent directly to the Timber engineering team)\n" .rstrip end |
.console_url(app) ⇒ Object
54 55 56 57 58 |
# File 'lib/timber/cli/io/messages.rb', line 54 def console_url(app) = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n" end |
.contact ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/timber/cli/io/messages.rb', line 60 def contact = "Website: \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport: \#{SUPPORT_EMAIL}\n" .rstrip end |
.copied_to_clipboard ⇒ Object
69 70 71 |
# File 'lib/timber/cli/io/messages.rb', line 69 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
.edit_app_url(app) ⇒ Object
31 32 33 |
# File 'lib/timber/cli/io/messages.rb', line 31 def edit_app_url(app) "#{APP_URL}" end |
.failed ⇒ Object
177 178 179 |
# File 'lib/timber/cli/io/messages.rb', line 177 def failed "Failed :(" end |
.free_data ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/timber/cli/io/messages.rb', line 92 def free_data = "Get free data:\n\n* Get \u2728 250mb\u2728 for starring our repo: \#{IO::ANSI.colorize(REPO_URL, :blue)}\n* Get \u2728 250mb\u2728 for tweeting your experience to \#{IO::ANSI.colorize(TWITTER_HANDLE, :blue)}\n" .rstrip end |
.git_commands ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/timber/cli/io/messages.rb', line 46 def git_commands = " \#{ANSI.colorize(\"git add config/initializers/timber.rb\", :blue)}\n \#{ANSI.colorize(\"git commit -am 'Install the timber logger'\", :blue)}\n" .rstrip end |
.header ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/timber/cli/io/messages.rb', line 102 def header = "\u{1F332} Timber.io Ruby Installer - Sane logging for Ruby developers.\n\n ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n/|\\\\/|\\\\/|\\\\ /|\\\\ /\\\\-_--\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ / \\\\_-__\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ |[]| [] | /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n" .rstrip end |
.heroku_install(app) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/timber/cli/io/messages.rb', line 114 def heroku_install(app) command = "heroku drains:add #{app.heroku_drain_url}" copied = OSHelper.copy_to_clipboard(command) = "First, let's setup your Heroku drain. Run this command in a separate window:\n\n \#{ANSI.colorize(command, :blue)}\n" = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
.http_environment_variables(api_key) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/timber/cli/io/messages.rb', line 73 def http_environment_variables(api_key) command = "export TIMBER_API_KEY=\"#{api_key}\"" copied = OSHelper.copy_to_clipboard(command) = "Great! Add this variable to your environment:\n\n \#{ANSI.colorize(command, :blue)}\n\n" = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
.no_api_key_provided ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/timber/cli/io/messages.rb', line 132 def no_api_key_provided = "Hey there! Welcome to Timber. In order to proceed, you'll need an API key.\nIf you already have one, you can run this installer like:\n\n \#{ANSI.colorize(\"bundle exec timber install my-api-key\", :blue)}\n\n\#{obtain_key_instructions}\n" .rstrip end |
.obtain_key_instructions ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/timber/cli/io/messages.rb', line 144 def obtain_key_instructions = "Don't have a key? Head over to:\n\n \#{ANSI.colorize(APP_URL, :blue)}\n\nFor a simple guide, checkout out:\n\n \#{ANSI.colorize(OBTAIN_KEY_DOCS_URL, :blue)}\n\nIf you're stuck, contact us:\n\n \#{ANSI.colorize(SUPPORT_EMAIL, :blue)}\n" .rstrip end |
.separator ⇒ Object
161 162 163 |
# File 'lib/timber/cli/io/messages.rb', line 161 def separator "--------------------------------------------------------------------------------" end |
.spinner(iteration) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/timber/cli/io/messages.rb', line 165 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
.success ⇒ Object
181 182 183 |
# File 'lib/timber/cli/io/messages.rb', line 181 def success "✓ Success!" end |
.task_complete(message) ⇒ Object
185 186 187 188 189 190 |
# File 'lib/timber/cli/io/messages.rb', line 185 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{message}#{dots}#{success}" end |
.task_failed(message) ⇒ Object
192 193 194 195 196 197 |
# File 'lib/timber/cli/io/messages.rb', line 192 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{message}#{dots}#{failed}" end |
.task_start(message) ⇒ Object
199 200 201 202 203 |
# File 'lib/timber/cli/io/messages.rb', line 199 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{message}" + ("." * remainder) end |
.we_love_you_too ⇒ Object
205 206 207 |
# File 'lib/timber/cli/io/messages.rb', line 205 def we_love_you_too "Thanks! We 💖 you too!" end |
Instance Method Details
#application_details(app) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/timber/cli/io/messages.rb', line 21 def application_details(app) = "Woot! Your API \u{1F511} is valid:\n\nName: \#{app.name} (\#{app.environment})\nPlatform: \#{app.platform_type}\n" .rstrip end |
#bad_experience_message ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/timber/cli/io/messages.rb', line 35 def = "Bummer! That is certainly not the experience we were going for.\n\nCould you tell us why you a bad experience?\n\n(this will be sent directly to the Timber engineering team)\n" .rstrip end |
#console_url(app) ⇒ Object
54 55 56 57 58 |
# File 'lib/timber/cli/io/messages.rb', line 54 def console_url(app) = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n" end |
#contact ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/timber/cli/io/messages.rb', line 60 def contact = "Website: \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport: \#{SUPPORT_EMAIL}\n" .rstrip end |
#copied_to_clipboard ⇒ Object
69 70 71 |
# File 'lib/timber/cli/io/messages.rb', line 69 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
#edit_app_url(app) ⇒ Object
31 32 33 |
# File 'lib/timber/cli/io/messages.rb', line 31 def edit_app_url(app) "#{APP_URL}" end |
#failed ⇒ Object
177 178 179 |
# File 'lib/timber/cli/io/messages.rb', line 177 def failed "Failed :(" end |
#free_data ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/timber/cli/io/messages.rb', line 92 def free_data = "Get free data:\n\n* Get \u2728 250mb\u2728 for starring our repo: \#{IO::ANSI.colorize(REPO_URL, :blue)}\n* Get \u2728 250mb\u2728 for tweeting your experience to \#{IO::ANSI.colorize(TWITTER_HANDLE, :blue)}\n" .rstrip end |
#git_commands ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/timber/cli/io/messages.rb', line 46 def git_commands = " \#{ANSI.colorize(\"git add config/initializers/timber.rb\", :blue)}\n \#{ANSI.colorize(\"git commit -am 'Install the timber logger'\", :blue)}\n" .rstrip end |
#header ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/timber/cli/io/messages.rb', line 102 def header = "\u{1F332} Timber.io Ruby Installer - Sane logging for Ruby developers.\n\n ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n/|\\\\/|\\\\/|\\\\ /|\\\\ /\\\\-_--\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ / \\\\_-__\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ |[]| [] | /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n" .rstrip end |
#heroku_install(app) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/timber/cli/io/messages.rb', line 114 def heroku_install(app) command = "heroku drains:add #{app.heroku_drain_url}" copied = OSHelper.copy_to_clipboard(command) = "First, let's setup your Heroku drain. Run this command in a separate window:\n\n \#{ANSI.colorize(command, :blue)}\n" = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
#http_environment_variables(api_key) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/timber/cli/io/messages.rb', line 73 def http_environment_variables(api_key) command = "export TIMBER_API_KEY=\"#{api_key}\"" copied = OSHelper.copy_to_clipboard(command) = "Great! Add this variable to your environment:\n\n \#{ANSI.colorize(command, :blue)}\n\n" = .rstrip if copied << "\n #{copied_to_clipboard}" end end |
#no_api_key_provided ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/timber/cli/io/messages.rb', line 132 def no_api_key_provided = "Hey there! Welcome to Timber. In order to proceed, you'll need an API key.\nIf you already have one, you can run this installer like:\n\n \#{ANSI.colorize(\"bundle exec timber install my-api-key\", :blue)}\n\n\#{obtain_key_instructions}\n" .rstrip end |
#obtain_key_instructions ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/timber/cli/io/messages.rb', line 144 def obtain_key_instructions = "Don't have a key? Head over to:\n\n \#{ANSI.colorize(APP_URL, :blue)}\n\nFor a simple guide, checkout out:\n\n \#{ANSI.colorize(OBTAIN_KEY_DOCS_URL, :blue)}\n\nIf you're stuck, contact us:\n\n \#{ANSI.colorize(SUPPORT_EMAIL, :blue)}\n" .rstrip end |
#separator ⇒ Object
161 162 163 |
# File 'lib/timber/cli/io/messages.rb', line 161 def separator "--------------------------------------------------------------------------------" end |
#spinner(iteration) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/timber/cli/io/messages.rb', line 165 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
#success ⇒ Object
181 182 183 |
# File 'lib/timber/cli/io/messages.rb', line 181 def success "✓ Success!" end |
#task_complete(message) ⇒ Object
185 186 187 188 189 190 |
# File 'lib/timber/cli/io/messages.rb', line 185 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{message}#{dots}#{success}" end |
#task_failed(message) ⇒ Object
192 193 194 195 196 197 |
# File 'lib/timber/cli/io/messages.rb', line 192 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{message}#{dots}#{failed}" end |
#task_start(message) ⇒ Object
199 200 201 202 203 |
# File 'lib/timber/cli/io/messages.rb', line 199 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{message}" + ("." * remainder) end |
#we_love_you_too ⇒ Object
205 206 207 |
# File 'lib/timber/cli/io/messages.rb', line 205 def we_love_you_too "Thanks! We 💖 you too!" end |