Module: Timber::CLI::IO::Messages

Extended by:
Messages
Included in:
Messages
Defined in:
lib/timber/cli/io/messages.rb

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

Instance Method Summary collapse

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)
  message = "Woot! Your API \u{1F511}  is valid:\n\nName:      \#{app.name} (\#{app.environment})\nFramework: \#{app.framework_type}\nPlatform:  \#{app.platform_type}\n"
  message.rstrip
end

.bad_experience_messageObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/timber/cli/io/messages.rb', line 36

def bad_experience_message
  message = "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"
  message.rstrip
end

.console_url(app) ⇒ Object



55
56
57
58
59
# File 'lib/timber/cli/io/messages.rb', line 55

def console_url(app)
  message = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n"
end

.contactObject



61
62
63
64
65
66
67
68
# File 'lib/timber/cli/io/messages.rb', line 61

def contact
  message = "Website:       \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport:       \#{SUPPORT_EMAIL}\n"
  message.rstrip
end

.copied_to_clipboardObject



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

.failedObject



178
179
180
# File 'lib/timber/cli/io/messages.rb', line 178

def failed
  "Failed :("
end

.free_dataObject



93
94
95
96
97
98
99
100
101
# File 'lib/timber/cli/io/messages.rb', line 93

def free_data
  message = "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"
  message.rstrip
end

.git_commandsObject



47
48
49
50
51
52
53
# File 'lib/timber/cli/io/messages.rb', line 47

def git_commands
  message = "    \#{ANSI.colorize(\"git add config/initializers/timber.rb\", :blue)}\n    \#{ANSI.colorize(\"git commit -am 'Install the timber logger'\", :blue)}\n"
  message.rstrip
end

.headerObject



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/timber/cli/io/messages.rb', line 103

def header
  message = "\u{1F332} Timber.io Ruby Installer\n\n ^  ^  ^   ^      ___I_      ^  ^   ^  ^  ^   ^  ^\n/|\\\\/|\\\\/|\\\\ /|\\\\    /\\\\-_--\\\\    /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\   /  \\\\_-__\\\\   /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\   |[]| [] |   /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n"
  message.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)

  message = "First, let's setup your Heroku drain. Run this command in a separate window:\n\n    \#{ANSI.colorize(command, :blue)}\n"
  message = message.rstrip

  if copied
    message << "\n    #{copied_to_clipboard}"
  end

  message
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)

  message = "Great! Add this variable to your environment:\n\n    \#{ANSI.colorize(command, :blue)}\n\n"
  message = message.rstrip

  if copied
    message << "\n    #{copied_to_clipboard}"
  end

  message
end

.no_api_key_providedObject



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
  message = "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"
  message.rstrip
end

.obtain_key_instructionsObject



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
  message = "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"
  message.rstrip
end

.separatorObject



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

.successObject



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(message)
  remainder = MAX_LENGTH - message.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(message)
  remainder = MAX_LENGTH - message.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(message)
  remainder = MAX_LENGTH - message.length - success.length

  "\r#{message}" + ("." * remainder)
end

.we_love_you_tooObject



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)
  message = "Woot! Your API \u{1F511}  is valid:\n\nName:      \#{app.name} (\#{app.environment})\nFramework: \#{app.framework_type}\nPlatform:  \#{app.platform_type}\n"
  message.rstrip
end

#bad_experience_messageObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/timber/cli/io/messages.rb', line 36

def bad_experience_message
  message = "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"
  message.rstrip
end

#console_url(app) ⇒ Object



55
56
57
58
59
# File 'lib/timber/cli/io/messages.rb', line 55

def console_url(app)
  message = "Your console URL: https://app.timber.io/organizations/timber/apps/\#{app.slug}/console\n"
end

#contactObject



61
62
63
64
65
66
67
68
# File 'lib/timber/cli/io/messages.rb', line 61

def contact
  message = "Website:       \#{WEBSITE_URL}\nDocumentation: \#{DOCS_URL}\nSupport:       \#{SUPPORT_EMAIL}\n"
  message.rstrip
end

#copied_to_clipboardObject



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

#failedObject



178
179
180
# File 'lib/timber/cli/io/messages.rb', line 178

def failed
  "Failed :("
end

#free_dataObject



93
94
95
96
97
98
99
100
101
# File 'lib/timber/cli/io/messages.rb', line 93

def free_data
  message = "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"
  message.rstrip
end

#git_commandsObject



47
48
49
50
51
52
53
# File 'lib/timber/cli/io/messages.rb', line 47

def git_commands
  message = "    \#{ANSI.colorize(\"git add config/initializers/timber.rb\", :blue)}\n    \#{ANSI.colorize(\"git commit -am 'Install the timber logger'\", :blue)}\n"
  message.rstrip
end

#headerObject



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/timber/cli/io/messages.rb', line 103

def header
  message = "\u{1F332} Timber.io Ruby Installer\n\n ^  ^  ^   ^      ___I_      ^  ^   ^  ^  ^   ^  ^\n/|\\\\/|\\\\/|\\\\ /|\\\\    /\\\\-_--\\\\    /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\   /  \\\\_-__\\\\   /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n/|\\\\/|\\\\/|\\\\ /|\\\\   |[]| [] |   /|\\\\/|\\\\ /|\\\\/|\\\\/|\\\\ /|\\\\/|\\\\\n"
  message.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)

  message = "First, let's setup your Heroku drain. Run this command in a separate window:\n\n    \#{ANSI.colorize(command, :blue)}\n"
  message = message.rstrip

  if copied
    message << "\n    #{copied_to_clipboard}"
  end

  message
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)

  message = "Great! Add this variable to your environment:\n\n    \#{ANSI.colorize(command, :blue)}\n\n"
  message = message.rstrip

  if copied
    message << "\n    #{copied_to_clipboard}"
  end

  message
end

#no_api_key_providedObject



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
  message = "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"
  message.rstrip
end

#obtain_key_instructionsObject



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
  message = "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"
  message.rstrip
end

#separatorObject



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

#successObject



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(message)
  remainder = MAX_LENGTH - message.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(message)
  remainder = MAX_LENGTH - message.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(message)
  remainder = MAX_LENGTH - message.length - success.length

  "\r#{message}" + ("." * remainder)
end

#we_love_you_tooObject



206
207
208
# File 'lib/timber/cli/io/messages.rb', line 206

def we_love_you_too
  "Thanks! We 💖 you too!"
end