passenger 5.0.0.rc2 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +10 -0
  5. data/CONTRIBUTORS +1 -0
  6. data/build/agents.rb +6 -0
  7. data/build/cxx_tests.rb +6 -0
  8. data/build/misc.rb +22 -1
  9. data/doc/Users guide Nginx.txt +12 -0
  10. data/ext/common/ApplicationPool2/Options.h +2 -1
  11. data/ext/common/ApplicationPool2/Pool.h +15 -744
  12. data/ext/common/ApplicationPool2/Pool/AnalyticsCollection.h +255 -0
  13. data/ext/common/ApplicationPool2/Pool/Debug.h +63 -0
  14. data/ext/common/ApplicationPool2/Pool/GarbageCollection.h +197 -0
  15. data/ext/common/ApplicationPool2/Pool/GeneralUtils.h +127 -0
  16. data/ext/common/ApplicationPool2/Pool/Inspection.h +214 -0
  17. data/ext/common/ApplicationPool2/Pool/ProcessUtils.h +85 -0
  18. data/ext/common/ApplicationPool2/Process.h +5 -7
  19. data/ext/common/Constants.h +1 -1
  20. data/ext/common/Hooks.h +2 -1
  21. data/ext/common/Utils.cpp +1 -1
  22. data/ext/common/Utils/JsonUtils.h +37 -1
  23. data/ext/common/agents/Base.cpp +45 -40
  24. data/ext/common/agents/Base.h +3 -2
  25. data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +12 -10
  26. data/ext/nginx/Configuration.c +4 -1
  27. data/lib/phusion_passenger.rb +1 -1
  28. data/lib/phusion_passenger/common_library.rb +7 -1
  29. data/lib/phusion_passenger/config/restart_app_command.rb +40 -2
  30. data/lib/phusion_passenger/config/utils.rb +3 -5
  31. data/lib/phusion_passenger/utils/ansi_colors.rb +28 -21
  32. data/lib/phusion_passenger/utils/terminal_choice_menu.rb +27 -10
  33. data/resources/templates/standalone/config.erb +4 -4
  34. data/test/cxx/CxxTestMain.cpp +10 -22
  35. metadata +10 -4
  36. metadata.gz.asc +7 -7
@@ -112,7 +112,7 @@
112
112
 
113
113
  #define NGINX_DOC_URL "https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html"
114
114
 
115
- #define PASSENGER_VERSION "5.0.0.rc2"
115
+ #define PASSENGER_VERSION "5.0.1"
116
116
 
117
117
  #define POOL_HELPER_THREAD_STACK_SIZE 262144
118
118
 
data/ext/common/Hooks.h CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2013 Phusion
3
+ * Copyright (c) 2010-2015 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -29,6 +29,7 @@
29
29
  #include <vector>
30
30
  #include <utility>
31
31
 
32
+ #include <boost/foreach.hpp>
32
33
  #include <oxt/backtrace.hpp>
33
34
 
34
35
  #include <sys/types.h>
data/ext/common/Utils.cpp CHANGED
@@ -1081,7 +1081,7 @@ runCommandAndCaptureOutput(const char **command) {
1081
1081
  syscalls::kill(SIGKILL, pid);
1082
1082
  syscalls::waitpid(pid, NULL, 0);
1083
1083
  throw SystemException(string("Cannot read output from the '") +
1084
- command[1] + "' command", e);
1084
+ command[0] + "' command", e);
1085
1085
  }
1086
1086
  done = ret == 0;
1087
1087
  result.append(buf, ret);
@@ -36,6 +36,24 @@ namespace Passenger {
36
36
 
37
37
  using namespace std;
38
38
 
39
+
40
+ /**************************************************************
41
+ *
42
+ * Methods for generating JSON.
43
+ *
44
+ **************************************************************/
45
+
46
+ /**
47
+ * Returns a JSON document as its string representation.
48
+ * This string is not prettified and does not contain a
49
+ * trailing newline.
50
+ *
51
+ * Json::Value doc;
52
+ * doc["foo"] = "bar";
53
+ * cout << stringifyJson(doc) << endl;
54
+ * // Prints:
55
+ * // {"foo": "bar"}
56
+ */
39
57
  inline string
40
58
  stringifyJson(const Json::Value &value) {
41
59
  Json::FastWriter writer;
@@ -44,12 +62,29 @@ stringifyJson(const Json::Value &value) {
44
62
  return str;
45
63
  }
46
64
 
47
- /** `str` MUST be NULL-terminated! */
65
+ /**
66
+ * Encodes the given string as a JSON string. `str` MUST be NULL-terminated!
67
+ *
68
+ * cout << jsonString("hello \"user\"") << endl;
69
+ * // Prints:
70
+ * // "hello \"user\""
71
+ */
48
72
  inline string
49
73
  jsonString(const Passenger::StaticString &str) {
50
74
  return stringifyJson(Json::Value(Json::StaticString(str.data())));
51
75
  }
52
76
 
77
+ /**
78
+ * Encodes the given Unix timestamp into a JSON object that
79
+ * describes it.
80
+ *
81
+ * timeToJson(time(NULL) - 10);
82
+ * // {
83
+ * // "timestamp": 1424887842,
84
+ * // "local": "Wed Feb 25 19:10:34 CET 2015",
85
+ * // "relative": "10s ago"
86
+ * // }
87
+ */
53
88
  inline Json::Value
54
89
  timeToJson(unsigned long long timestamp) {
55
90
  Json::Value doc;
@@ -107,6 +142,7 @@ signedByteSizeToJson(long long size) {
107
142
  return doc;
108
143
  }
109
144
 
145
+
110
146
  } // namespace Passenger
111
147
 
112
148
  #endif /* _PASSENGER_UTILS_JSON_UTILS_H_ */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2014 Phusion
3
+ * Copyright (c) 2010-2015 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -1082,7 +1082,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
1082
1082
  #endif /* __APPLE__ */
1083
1083
 
1084
1084
  void
1085
- installAbortHandler() {
1085
+ installAgentAbortHandler() {
1086
1086
  alternativeStackSize = MINSIGSTKSZ + 128 * 1024;
1087
1087
  alternativeStack = (char *) malloc(alternativeStackSize);
1088
1088
  if (alternativeStack == NULL) {
@@ -1492,7 +1492,7 @@ initializeAgent(int argc, char **argv[], const char *processName,
1492
1492
  stopOnAbort = hasEnvOption("PASSENGER_STOP_ON_ABORT");
1493
1493
  IGNORE_SYSCALL_RESULT(pipe(emergencyPipe1));
1494
1494
  IGNORE_SYSCALL_RESULT(pipe(emergencyPipe2));
1495
- installAbortHandler();
1495
+ installAgentAbortHandler();
1496
1496
  }
1497
1497
  oxt::initialize();
1498
1498
  setup_syscall_interruption_support();
@@ -1518,43 +1518,7 @@ initializeAgent(int argc, char **argv[], const char *processName,
1518
1518
  argc - argStartIndex);
1519
1519
  }
1520
1520
 
1521
- ResourceLocator locator;
1522
- string ruby;
1523
-
1524
- if (options.has("passenger_root")) {
1525
- string path;
1526
- locator = ResourceLocator(options.get("passenger_root", true));
1527
- ruby = options.get("default_ruby", false, DEFAULT_RUBY);
1528
-
1529
- rubyLibDir = strdup(locator.getRubyLibDir().c_str());
1530
- passengerRoot = strdup(options.get("passenger_root", true).c_str());
1531
- defaultRuby = strdup(ruby.c_str());
1532
-
1533
- #ifdef __linux__
1534
- path = ruby + " \"" + locator.getHelperScriptsDir() +
1535
- "/backtrace-sanitizer.rb\"";
1536
- backtraceSanitizerCommand = strdup(path.c_str());
1537
- #endif
1538
-
1539
- path = locator.getHelperScriptsDir() + "/crash-watch.rb";
1540
- crashWatch = strdup(path.c_str());
1541
- } else {
1542
- shouldDumpWithCrashWatch = false;
1543
- }
1544
-
1545
- if (backtraceSanitizerCommand == NULL) {
1546
- backtraceSanitizerCommand = "c++filt -n";
1547
- backtraceSanitizerPassProgramInfo = false;
1548
- }
1549
-
1550
- if (preinit != NULL) {
1551
- preinit(options);
1552
- }
1553
- options.setDefaultInt("log_level", DEFAULT_LOG_LEVEL);
1554
- setLogLevel(options.getInt("log_level"));
1555
- if (options.has("debug_log_file")) {
1556
- setLogFile(options.get("debug_log_file").c_str());
1557
- }
1521
+ initializeAgentOptions(options, preinit);
1558
1522
  } catch (const tracable_exception &e) {
1559
1523
  P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
1560
1524
  exit(1);
@@ -1581,4 +1545,45 @@ initializeAgent(int argc, char **argv[], const char *processName,
1581
1545
  return options;
1582
1546
  }
1583
1547
 
1548
+ void
1549
+ initializeAgentOptions(VariantMap &options, PreinitializationFunc preinit) {
1550
+ ResourceLocator locator;
1551
+ string ruby;
1552
+
1553
+ if (options.has("passenger_root")) {
1554
+ string path;
1555
+ locator = ResourceLocator(options.get("passenger_root", true));
1556
+ ruby = options.get("default_ruby", false, DEFAULT_RUBY);
1557
+
1558
+ rubyLibDir = strdup(locator.getRubyLibDir().c_str());
1559
+ passengerRoot = strdup(options.get("passenger_root", true).c_str());
1560
+ defaultRuby = strdup(ruby.c_str());
1561
+
1562
+ #ifdef __linux__
1563
+ path = ruby + " \"" + locator.getHelperScriptsDir() +
1564
+ "/backtrace-sanitizer.rb\"";
1565
+ backtraceSanitizerCommand = strdup(path.c_str());
1566
+ #endif
1567
+
1568
+ path = locator.getHelperScriptsDir() + "/crash-watch.rb";
1569
+ crashWatch = strdup(path.c_str());
1570
+ } else {
1571
+ shouldDumpWithCrashWatch = false;
1572
+ }
1573
+
1574
+ if (backtraceSanitizerCommand == NULL) {
1575
+ backtraceSanitizerCommand = "c++filt -n";
1576
+ backtraceSanitizerPassProgramInfo = false;
1577
+ }
1578
+
1579
+ if (preinit != NULL) {
1580
+ preinit(options);
1581
+ }
1582
+ options.setDefaultInt("log_level", DEFAULT_LOG_LEVEL);
1583
+ setLogLevel(options.getInt("log_level"));
1584
+ if (options.has("debug_log_file")) {
1585
+ setLogFile(options.get("debug_log_file").c_str());
1586
+ }
1587
+ }
1588
+
1584
1589
  } // namespace Passenger
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010, 2011, 2012 Phusion
3
+ * Copyright (c) 2010-2015 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -43,7 +43,8 @@ bool feedbackFdAvailable();
43
43
  VariantMap initializeAgent(int argc, char **argv[], const char *processName,
44
44
  OptionParserFunc optionParser = NULL, PreinitializationFunc preinit = NULL,
45
45
  int argStartIndex = 1);
46
- void installAbortHandler();
46
+ void initializeAgentOptions(VariantMap &options, PreinitializationFunc preinit = NULL);
47
+ void installAgentAbortHandler();
47
48
  void installDiagnosticsDumper(DiagnosticsDumper func, void *userData);
48
49
 
49
50
  }
@@ -415,16 +415,18 @@ setStickySessionId(Client *client, Request *req) {
415
415
  // headers, although this is in practice extremely rare.
416
416
  // http://stackoverflow.com/questions/16305814/are-multiple-cookie-headers-allowed-in-an-http-request
417
417
  const LString *cookieHeader = req->headers.lookup(HTTP_COOKIE);
418
- const LString *cookieName = getStickySessionCookieName(req);
419
- vector< pair<StaticString, StaticString> > cookies;
420
- pair<StaticString, StaticString> cookie;
421
-
422
- parseCookieHeader(req->pool, cookieHeader, cookies);
423
- foreach (cookie, cookies) {
424
- if (psg_lstr_cmp(cookieName, cookie.first)) {
425
- // This cookie matches the one we're looking for.
426
- req->options.stickySessionId = stringToUint(cookie.second);
427
- return;
418
+ if (cookieHeader != NULL) {
419
+ const LString *cookieName = getStickySessionCookieName(req);
420
+ vector< pair<StaticString, StaticString> > cookies;
421
+ pair<StaticString, StaticString> cookie;
422
+
423
+ parseCookieHeader(req->pool, cookieHeader, cookies);
424
+ foreach (cookie, cookies) {
425
+ if (psg_lstr_cmp(cookieName, cookie.first)) {
426
+ // This cookie matches the one we're looking for.
427
+ req->options.stickySessionId = stringToUint(cookie.second);
428
+ return;
429
+ }
428
430
  }
429
431
  }
430
432
  }
@@ -745,7 +745,10 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
745
745
  conf->upstream_config.upstream = prev->upstream_config.upstream;
746
746
  }
747
747
 
748
- if (conf->enabled) {
748
+ if (conf->enabled == 1 /* and not NGX_CONF_UNSET */
749
+ && passenger_main_conf.root_dir.len != 0
750
+ && clcf->handler == NULL /* no handler set by other modules */)
751
+ {
749
752
  clcf->handler = passenger_content_handler;
750
753
  }
751
754
 
@@ -30,7 +30,7 @@ module PhusionPassenger
30
30
 
31
31
  PACKAGE_NAME = 'passenger'
32
32
  # Run 'rake ext/common/Constants.h' after changing this number.
33
- VERSION_STRING = '5.0.0.rc2'
33
+ VERSION_STRING = '5.0.1'
34
34
 
35
35
  PREFERRED_NGINX_VERSION = '1.6.2'
36
36
  NGINX_SHA256_CHECKSUM = 'b5608c2959d3e7ad09b20fc8f9e5bd4bc87b3bc8ba5936a513c04ed8f1391a18'
@@ -1,5 +1,5 @@
1
1
  # Phusion Passenger - https://www.phusionpassenger.com/
2
- # Copyright (c) 2012-2014 Phusion
2
+ # Copyright (c) 2012-2015 Phusion
3
3
  #
4
4
  # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
5
5
  #
@@ -412,6 +412,12 @@ COMMON_LIBRARY = CommonLibraryBuilder.new do
412
412
  ApplicationPool2/Spawner.h
413
413
  ApplicationPool2/Common.h
414
414
  ApplicationPool2/Pool.h
415
+ ApplicationPool2/Pool/AnalyticsCollection.h
416
+ ApplicationPool2/Pool/GarbageCollection.h
417
+ ApplicationPool2/Pool/GeneralUtils.h
418
+ ApplicationPool2/Pool/ProcessUtils.h
419
+ ApplicationPool2/Pool/Inspection.h
420
+ ApplicationPool2/Pool/Debug.h
415
421
  ApplicationPool2/SuperGroup.h
416
422
  ApplicationPool2/Group.h
417
423
  ApplicationPool2/Process.h
@@ -1,5 +1,5 @@
1
1
  # Phusion Passenger - https://www.phusionpassenger.com/
2
- # Copyright (c) 2013-2014 Phusion
2
+ # Copyright (c) 2013-2015 Phusion
3
3
  #
4
4
  # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
5
5
  #
@@ -30,6 +30,8 @@ PhusionPassenger.require_passenger_lib 'admin_tools/instance_registry'
30
30
  PhusionPassenger.require_passenger_lib 'config/command'
31
31
  PhusionPassenger.require_passenger_lib 'config/utils'
32
32
  PhusionPassenger.require_passenger_lib 'utils/json'
33
+ PhusionPassenger.require_passenger_lib 'utils/ansi_colors'
34
+ PhusionPassenger.require_passenger_lib 'utils/terminal_choice_menu'
33
35
 
34
36
  module PhusionPassenger
35
37
  module Config
@@ -104,7 +106,7 @@ module PhusionPassenger
104
106
  super
105
107
  case @argv.size
106
108
  when 0
107
- if !@options[:app_group_name]
109
+ if !@options[:app_group_name] && !STDIN.tty?
108
110
  abort "Please pass either an app path prefix or an app group name. " +
109
111
  "See --help for more information."
110
112
  end
@@ -124,6 +126,9 @@ module PhusionPassenger
124
126
  @groups = []
125
127
  if app_group_name = @options[:app_group_name]
126
128
  select_app_group_name_exact(app_group_name)
129
+ elsif @argv.empty?
130
+ # STDIN is guaranteed to be a TTY thanks to the check in #parse_options.
131
+ select_app_group_name_interactively
127
132
  else
128
133
  select_app_group_name_by_app_root_regex(@argv.first)
129
134
  end
@@ -141,6 +146,39 @@ module PhusionPassenger
141
146
  end
142
147
  end
143
148
 
149
+ def query_group_names
150
+ result = []
151
+ query_pool_xml.elements.each("info/supergroups/supergroup/group") do |group|
152
+ result << group.elements["name"].text
153
+ end
154
+ result << "Cancel"
155
+ result
156
+ end
157
+
158
+ def select_app_group_name_interactively
159
+ colors = PhusionPassenger::Utils::AnsiColors.new
160
+
161
+ puts "Please select the application to restart."
162
+ puts colors.ansi_colorize("<gray>Tip: re-run this command with --help to learn how to automate it.</gray>")
163
+ puts colors.ansi_colorize("<dgray>If the menu doesn't display correctly, press '!'</dgray>")
164
+ puts
165
+
166
+ choices = query_group_names
167
+ menu = PhusionPassenger::Utils::TerminalChoiceMenu.new(choices, :single_choice)
168
+ begin
169
+ index, name = menu.query
170
+ rescue Interrupt
171
+ abort
172
+ end
173
+
174
+ if index == choices.size - 1
175
+ abort
176
+ else
177
+ puts
178
+ select_app_group_name_exact(name)
179
+ end
180
+ end
181
+
144
182
  def select_app_group_name_by_app_root_regex(app_root)
145
183
  regex = /^#{Regexp.escape(app_root)}/
146
184
  query_pool_xml.elements.each("info/supergroups/supergroup/group") do |group|
@@ -89,12 +89,10 @@ module PhusionPassenger
89
89
  def list_all_passenger_instances(instances)
90
90
  puts "The following #{PROGRAM_NAME} instances are running:"
91
91
  puts
92
+ printf "%-25s %s\n", "Name", "Description"
93
+ puts "------------------------------------------------------------------"
92
94
  instances.each do |instance|
93
- printf "%-25s %s\n", "Name", "Description"
94
- puts "------------------------------------------------------------------"
95
- instances.each do |instance|
96
- printf "%-25s %s\n", instance.name, instance.server_software
97
- end
95
+ printf "%-25s %s\n", instance.name, instance.server_software
98
96
  end
99
97
  end
100
98
 
@@ -1,5 +1,5 @@
1
1
  # Phusion Passenger - https://www.phusionpassenger.com/
2
- # Copyright (c) 2010-2014 Phusion
2
+ # Copyright (c) 2010-2015 Phusion
3
3
  #
4
4
  # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
5
5
  #
@@ -27,6 +27,7 @@ module PhusionPassenger
27
27
  module AnsiColors
28
28
  RESET = "\e[0m".freeze
29
29
  BOLD = "\e[1m".freeze
30
+ GRAY = "\e[38;5;248m".freeze
30
31
  DGRAY = "\e[90m".freeze
31
32
  RED = "\e[31m".freeze
32
33
  ORANGE = "\e[38;5;214m".freeze
@@ -40,7 +41,7 @@ module PhusionPassenger
40
41
  extend self # Make methods available as class methods.
41
42
 
42
43
  def self.new(type = :auto)
43
- return AnsiColorsPrinter.new(type)
44
+ AnsiColorsPrinter.new(type)
44
45
  end
45
46
 
46
47
  def self.included(klass)
@@ -54,23 +55,25 @@ module PhusionPassenger
54
55
  def ansi_colorize(text)
55
56
  text = text.gsub(%r{<b>(.*?)</b>}m, "#{BOLD}\\1#{DEFAULT_TERMINAL_COLOR}")
56
57
  text.gsub!(%r{<dgray>(.*?)</dgray>}m, "#{BOLD}#{DGRAY}\\1#{DEFAULT_TERMINAL_COLOR}")
58
+ text.gsub!(%r{<gray>(.*?)</gray>}m, "#{BOLD}#{GRAY}\\1#{DEFAULT_TERMINAL_COLOR}")
57
59
  text.gsub!(%r{<red>(.*?)</red>}m, "#{BOLD}#{RED}\\1#{DEFAULT_TERMINAL_COLOR}")
58
60
  text.gsub!(%r{<orange>(.*?)</orange>}m, "#{BOLD}#{ORANGE}\\1#{DEFAULT_TERMINAL_COLOR}")
59
61
  text.gsub!(%r{<green>(.*?)</green>}m, "#{BOLD}#{GREEN}\\1#{DEFAULT_TERMINAL_COLOR}")
60
62
  text.gsub!(%r{<yellow>(.*?)</yellow>}m, "#{BOLD}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}")
61
63
  text.gsub!(%r{<banner>(.*?)</banner>}m, "#{BOLD}#{BLUE_BG}#{YELLOW}\\1#{DEFAULT_TERMINAL_COLOR}")
62
- return text
64
+ text
63
65
  end
64
66
 
65
67
  def strip_color_tags(text)
66
68
  text = text.gsub(%r{<b>(.*?)</b>}m, "\\1")
67
69
  text = text.gsub(%r{<dgray>(.*?)</dgray>}m, "\\1")
70
+ text = text.gsub(%r{<gray>(.*?)</gray>}m, "\\1")
68
71
  text.gsub!(%r{<red>(.*?)</red>}m, "\\1")
69
72
  text.gsub!(%r{<orange>(.*?)</orange>}m, "\\1")
70
73
  text.gsub!(%r{<green>(.*?)</green>}m, "\\1")
71
74
  text.gsub!(%r{<yellow>(.*?)</yellow>}m, "\\1")
72
75
  text.gsub!(%r{<banner>(.*?)</banner>}m, "\\1")
73
- return text
76
+ text
74
77
  end
75
78
  end
76
79
 
@@ -80,71 +83,75 @@ module PhusionPassenger
80
83
  end
81
84
 
82
85
  def reset
83
- return maybe_colorize(AnsiColors::RESET)
86
+ maybe_colorize(AnsiColors::RESET)
84
87
  end
85
88
 
86
89
  def bold
87
- return maybe_colorize(AnsiColors::BOLD)
90
+ maybe_colorize(AnsiColors::BOLD)
88
91
  end
89
92
 
90
93
  def dgray
91
- return maybe_colorize(AnsiColors::DGRAY)
94
+ maybe_colorize(AnsiColors::DGRAY)
95
+ end
96
+
97
+ def gray
98
+ maybe_colorize(AnsiColors::GRAY)
92
99
  end
93
100
 
94
101
  def red
95
- return maybe_colorize(AnsiColors::RED)
102
+ maybe_colorize(AnsiColors::RED)
96
103
  end
97
104
 
98
105
  def orange
99
- return maybe_colorize(AnsiColors::ORANGE)
106
+ maybe_colorize(AnsiColors::ORANGE)
100
107
  end
101
108
 
102
109
  def green
103
- return maybe_colorize(AnsiColors::GREEN)
110
+ maybe_colorize(AnsiColors::GREEN)
104
111
  end
105
112
 
106
113
  def yellow
107
- return maybe_colorize(AnsiColors::YELLOW)
114
+ maybe_colorize(AnsiColors::YELLOW)
108
115
  end
109
116
 
110
117
  def white
111
- return maybe_colorize(AnsiColors::WHITE)
118
+ maybe_colorize(AnsiColors::WHITE)
112
119
  end
113
120
 
114
121
  def black_bg
115
- return maybe_colorize(AnsiColors::BLACK_BG)
122
+ maybe_colorize(AnsiColors::BLACK_BG)
116
123
  end
117
124
 
118
125
  def blue_bg
119
- return maybe_colorize(AnsiColors::BLUE_BG)
126
+ maybe_colorize(AnsiColors::BLUE_BG)
120
127
  end
121
128
 
122
129
  def default_terminal_color
123
- return maybe_colorize(AnsiColors::DEFAULT_TERMINAL_COLOR)
130
+ maybe_colorize(AnsiColors::DEFAULT_TERMINAL_COLOR)
124
131
  end
125
132
 
126
133
  def ansi_colorize(text)
127
134
  if should_output_color?
128
- return AnsiColors.ansi_colorize(text)
135
+ AnsiColors.ansi_colorize(text)
129
136
  else
130
- return AnsiColors.strip_color_tags(text)
137
+ AnsiColors.strip_color_tags(text)
131
138
  end
132
139
  end
133
140
 
134
141
  private
135
142
  def maybe_colorize(ansi_color)
136
143
  if should_output_color?
137
- return ansi_color
144
+ ansi_color
138
145
  else
139
- return ""
146
+ ""
140
147
  end
141
148
  end
142
149
 
143
150
  def should_output_color?
144
151
  if @enabled == :auto
145
- return STDOUT.tty?
152
+ STDOUT.tty?
146
153
  else
147
- return @enabled
154
+ @enabled
148
155
  end
149
156
  end
150
157
  end