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 30 |
# 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})\nFramework: \#{app.framework_type}\nPlatform: \#{app.platform_type}\n" .rstrip end |
.bad_experience_message ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/timber/cli/io/messages.rb', line 36 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
55 56 57 58 59 |
# File 'lib/timber/cli/io/messages.rb', line 55 def console_url(app) = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n" end |
.contact ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/timber/cli/io/messages.rb', line 61 def contact = "Website: \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport: \#{SUPPORT_EMAIL}\n" .rstrip end |
.copied_to_clipboard ⇒ Object
70 71 72 |
# File 'lib/timber/cli/io/messages.rb', line 70 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
.edit_app_url(app) ⇒ Object
32 33 34 |
# File 'lib/timber/cli/io/messages.rb', line 32 def edit_app_url(app) "#{APP_URL}" end |
.failed ⇒ Object
178 179 180 |
# File 'lib/timber/cli/io/messages.rb', line 178 def failed "Failed :(" end |
.free_data ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/timber/cli/io/messages.rb', line 93 def free_data = "Because you're awesome, we've credited your account with \u2728 100mb\u2728.\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
47 48 49 50 51 52 53 |
# File 'lib/timber/cli/io/messages.rb', line 47 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
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/timber/cli/io/messages.rb', line 103 def header = "\u{1F332} Timber.io Ruby Installer\n\n ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n/|\\\\/|\\\\/|\\\\ /|\\\\ /\\\\-_--\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ / \\\\_-__\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ |[]| [] | /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n" .rstrip end |
.heroku_install(app) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/timber/cli/io/messages.rb', line 115 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/timber/cli/io/messages.rb', line 74 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
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/timber/cli/io/messages.rb', line 133 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
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/timber/cli/io/messages.rb', line 145 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
162 163 164 |
# File 'lib/timber/cli/io/messages.rb', line 162 def separator "--------------------------------------------------------------------------------" end |
.spinner(iteration) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/timber/cli/io/messages.rb', line 166 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
.success ⇒ Object
182 183 184 |
# File 'lib/timber/cli/io/messages.rb', line 182 def success "✓ Success!" end |
.task_complete(message) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/timber/cli/io/messages.rb', line 186 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{message}#{dots}#{success}" end |
.task_failed(message) ⇒ Object
193 194 195 196 197 198 |
# File 'lib/timber/cli/io/messages.rb', line 193 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{message}#{dots}#{failed}" end |
.task_start(message) ⇒ Object
200 201 202 203 204 |
# File 'lib/timber/cli/io/messages.rb', line 200 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{message}" + ("." * remainder) end |
.we_love_you_too ⇒ Object
206 207 208 |
# File 'lib/timber/cli/io/messages.rb', line 206 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 30 |
# 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})\nFramework: \#{app.framework_type}\nPlatform: \#{app.platform_type}\n" .rstrip end |
#bad_experience_message ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/timber/cli/io/messages.rb', line 36 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
55 56 57 58 59 |
# File 'lib/timber/cli/io/messages.rb', line 55 def console_url(app) = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n" end |
#contact ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/timber/cli/io/messages.rb', line 61 def contact = "Website: \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport: \#{SUPPORT_EMAIL}\n" .rstrip end |
#copied_to_clipboard ⇒ Object
70 71 72 |
# File 'lib/timber/cli/io/messages.rb', line 70 def copied_to_clipboard IO::ANSI.colorize("(✓ copied to clipboard)", :green) end |
#edit_app_url(app) ⇒ Object
32 33 34 |
# File 'lib/timber/cli/io/messages.rb', line 32 def edit_app_url(app) "#{APP_URL}" end |
#failed ⇒ Object
178 179 180 |
# File 'lib/timber/cli/io/messages.rb', line 178 def failed "Failed :(" end |
#free_data ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/timber/cli/io/messages.rb', line 93 def free_data = "Because you're awesome, we've credited your account with \u2728 100mb\u2728.\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
47 48 49 50 51 52 53 |
# File 'lib/timber/cli/io/messages.rb', line 47 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
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/timber/cli/io/messages.rb', line 103 def header = "\u{1F332} Timber.io Ruby Installer\n\n ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n/|\\\\/|\\\\/|\\\\ /|\\\\ /\\\\-_--\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ / \\\\_-__\\\\ /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\ |[]| [] | /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n" .rstrip end |
#heroku_install(app) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/timber/cli/io/messages.rb', line 115 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/timber/cli/io/messages.rb', line 74 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
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/timber/cli/io/messages.rb', line 133 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
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/timber/cli/io/messages.rb', line 145 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
162 163 164 |
# File 'lib/timber/cli/io/messages.rb', line 162 def separator "--------------------------------------------------------------------------------" end |
#spinner(iteration) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/timber/cli/io/messages.rb', line 166 def spinner(iteration) rem = iteration % 3 case rem when 0 "/" when 1 "-" when 2 "\\" end end |
#success ⇒ Object
182 183 184 |
# File 'lib/timber/cli/io/messages.rb', line 182 def success "✓ Success!" end |
#task_complete(message) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/timber/cli/io/messages.rb', line 186 def task_complete() remainder = MAX_LENGTH - .length - success.length dots = "." * remainder "\r#{message}#{dots}#{success}" end |
#task_failed(message) ⇒ Object
193 194 195 196 197 198 |
# File 'lib/timber/cli/io/messages.rb', line 193 def task_failed() remainder = MAX_LENGTH - .length - failed.length dots = "." * remainder "\r#{message}#{dots}#{failed}" end |
#task_start(message) ⇒ Object
200 201 202 203 204 |
# File 'lib/timber/cli/io/messages.rb', line 200 def task_start() remainder = MAX_LENGTH - .length - success.length "\r#{message}" + ("." * remainder) end |
#we_love_you_too ⇒ Object
206 207 208 |
# File 'lib/timber/cli/io/messages.rb', line 206 def we_love_you_too "Thanks! We 💖 you too!" end |