nanoc 3.3.7 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Gemfile.lock +133 -0
  2. data/NEWS.md +15 -0
  3. data/lib/nanoc.rb +2 -2
  4. data/lib/nanoc/base/compilation/compiler.rb +1 -1
  5. data/lib/nanoc/base/compilation/item_rep_proxy.rb +3 -3
  6. data/lib/nanoc/base/core_ext/string.rb +0 -18
  7. data/lib/nanoc/base/errors.rb +24 -19
  8. data/lib/nanoc/base/plugin_registry.rb +1 -1
  9. data/lib/nanoc/base/result_data/item_rep.rb +1 -2
  10. data/lib/nanoc/base/source_data/site.rb +1 -1
  11. data/lib/nanoc/cli.rb +46 -4
  12. data/lib/nanoc/cli/ansi_string_colorizer.rb +30 -0
  13. data/lib/nanoc/cli/cleaning_stream.rb +91 -0
  14. data/lib/nanoc/cli/command_runner.rb +3 -11
  15. data/lib/nanoc/cli/commands/compile.rb +2 -2
  16. data/lib/nanoc/cli/commands/{create_item.rb → create-item.rb} +6 -7
  17. data/lib/nanoc/cli/commands/{create_layout.rb → create-layout.rb} +9 -10
  18. data/lib/nanoc/cli/commands/{create_site.rb → create-site.rb} +13 -14
  19. data/lib/nanoc/cli/commands/deploy.rb +4 -12
  20. data/lib/nanoc/cli/commands/nanoc.rb +4 -2
  21. data/lib/nanoc/cli/commands/prune.rb +1 -1
  22. data/lib/nanoc/cli/commands/{debug.rb → show-data.rb} +6 -5
  23. data/lib/nanoc/cli/commands/{info.rb → show-plugins.rb} +6 -6
  24. data/lib/nanoc/cli/commands/show-rules.rb +69 -0
  25. data/lib/nanoc/cli/commands/update.rb +1 -2
  26. data/lib/nanoc/cli/commands/validate-css.rb +24 -0
  27. data/lib/nanoc/cli/commands/validate-html.rb +24 -0
  28. data/lib/nanoc/cli/commands/validate-links.rb +35 -0
  29. data/lib/nanoc/cli/commands/watch.rb +3 -3
  30. data/lib/nanoc/cli/error_handler.rb +142 -26
  31. data/lib/nanoc/cli/logger.rb +4 -21
  32. data/lib/nanoc/cli/stream_cleaners.rb +14 -0
  33. data/lib/nanoc/cli/stream_cleaners/abstract.rb +23 -0
  34. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +15 -0
  35. data/lib/nanoc/cli/stream_cleaners/utf8.rb +16 -0
  36. data/lib/nanoc/extra/deployers/rsync.rb +2 -7
  37. data/lib/nanoc/extra/pruner.rb +3 -3
  38. data/lib/nanoc/extra/validators/links.rb +14 -3
  39. data/lib/nanoc/filters.rb +4 -0
  40. data/lib/nanoc/filters/handlebars.rb +30 -0
  41. data/lib/nanoc/filters/mustache.rb +2 -2
  42. data/lib/nanoc/filters/pandoc.rb +20 -0
  43. data/lib/nanoc/helpers/filtering.rb +1 -1
  44. data/lib/nanoc/tasks/validate.rake +10 -68
  45. data/nanoc.gemspec +0 -16
  46. data/test/cli/commands/test_create_site.rb +1 -1
  47. data/test/cli/commands/test_deploy.rb +45 -0
  48. data/test/cli/test_cli.rb +1 -1
  49. data/test/extra/validators/test_links.rb +15 -5
  50. data/test/filters/test_handlebars.rb +42 -0
  51. data/test/filters/test_mustache.rb +19 -0
  52. data/test/filters/test_pandoc.rb +18 -0
  53. metadata +23 -33
data/Gemfile.lock ADDED
@@ -0,0 +1,133 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nanoc (3.4.0)
5
+ cri (~> 2.2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ RedCloth (4.2.9)
11
+ albino (1.3.3)
12
+ posix-spawn (>= 0.3.6)
13
+ blankslate (2.1.2.4)
14
+ bluecloth (2.2.0)
15
+ builder (3.0.0)
16
+ coderay (1.0.6)
17
+ coffee-script (2.2.0)
18
+ coffee-script-source
19
+ execjs
20
+ coffee-script-source (1.3.3)
21
+ colored (1.2)
22
+ commonjs (0.2.6)
23
+ cri (2.3.0)
24
+ colored (>= 1.2)
25
+ erubis (2.7.0)
26
+ excon (0.13.4)
27
+ execjs (1.4.0)
28
+ multi_json (~> 1.0)
29
+ ffi (1.0.11)
30
+ fog (1.3.1)
31
+ builder
32
+ excon (~> 0.13.0)
33
+ formatador (~> 0.2.0)
34
+ mime-types
35
+ multi_json (~> 1.0)
36
+ net-scp (~> 1.0.4)
37
+ net-ssh (>= 2.1.3)
38
+ nokogiri (~> 1.5.0)
39
+ ruby-hmac
40
+ formatador (0.2.3)
41
+ haml (3.1.6)
42
+ json (1.7.3)
43
+ kramdown (0.13.7)
44
+ less (2.2.1)
45
+ commonjs (~> 0.2.6)
46
+ markaby (0.7.2)
47
+ builder (>= 2.0.0)
48
+ maruku (0.6.0)
49
+ syntax (>= 1.0.0)
50
+ metaclass (0.0.1)
51
+ mime-types (1.18)
52
+ minitest (3.0.1)
53
+ mocha (0.11.4)
54
+ metaclass (~> 0.0.1)
55
+ multi_json (1.3.6)
56
+ mustache (0.99.4)
57
+ net-scp (1.0.4)
58
+ net-ssh (>= 1.99.1)
59
+ net-ssh (2.5.2)
60
+ nokogiri (1.5.3)
61
+ posix-spawn (0.3.6)
62
+ pygments.rb (0.2.12)
63
+ rubypython (~> 0.5.3)
64
+ rack (1.4.1)
65
+ rainpress (1.0)
66
+ rake (0.9.2.2)
67
+ rdiscount (1.6.8)
68
+ rdoc (3.12)
69
+ json (~> 1.4)
70
+ redcarpet (2.1.1)
71
+ ruby-hmac (0.4.0)
72
+ rubypants (0.2.0)
73
+ rubypython (0.5.3)
74
+ blankslate (>= 2.1.2.3)
75
+ ffi (~> 1.0.7)
76
+ sass (3.1.19)
77
+ slim (1.2.1)
78
+ temple (~> 0.4.0)
79
+ tilt (~> 1.3.3)
80
+ syntax (1.0.0)
81
+ systemu (2.5.1)
82
+ temple (0.4.0)
83
+ tilt (1.3.3)
84
+ typogruby (1.0.15)
85
+ rubypants
86
+ uglifier (1.2.4)
87
+ execjs (>= 0.3.0)
88
+ multi_json (>= 1.0.2)
89
+ w3c_validators (1.2)
90
+ json
91
+ nokogiri
92
+ yard (0.8.2)
93
+ yuicompressor (1.2.0)
94
+
95
+ PLATFORMS
96
+ ruby
97
+
98
+ DEPENDENCIES
99
+ RedCloth
100
+ albino
101
+ bluecloth
102
+ builder
103
+ coderay
104
+ coffee-script
105
+ erubis
106
+ fog
107
+ haml
108
+ kramdown
109
+ less (~> 2.0)
110
+ markaby
111
+ maruku
112
+ mime-types
113
+ minitest
114
+ mocha
115
+ mustache
116
+ nanoc!
117
+ nokogiri
118
+ pygments.rb
119
+ rack
120
+ rainpress
121
+ rake
122
+ rdiscount
123
+ rdoc
124
+ redcarpet
125
+ rubypants
126
+ sass (~> 3.1)
127
+ slim
128
+ systemu
129
+ typogruby
130
+ uglifier
131
+ w3c_validators
132
+ yard
133
+ yuicompressor
data/NEWS.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.4 (2012-06-09)
4
+
5
+ * Improved error output and added crash log
6
+ * Renamed `debug` and `info` commands to `show-data` and `show-plugins`, respectively
7
+ * Added `show-rules` command (aka `explain`)
8
+
9
+ Extensions:
10
+
11
+ * Added `:yield` key for Mustache filter
12
+ * Added Handebars filter
13
+ * Added Pandoc filter
14
+ * Made the deployer use the `default` target if no target is specified
15
+ * Converted HTML/CSS/link validation tasks to commands
16
+ * Made link validator follow relative redirects
17
+
3
18
  ## 3.3.7 (2012-05-28)
4
19
 
5
20
  * Added filename to YAML parser errors
data/lib/nanoc.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Nanoc
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.3.7'
6
+ VERSION = '3.4.0'
7
7
 
8
8
  # @return [String] A string containing information about this nanoc version
9
9
  # and its environment (Ruby engine and version, Rubygems version if any).
@@ -11,7 +11,7 @@ module Nanoc
11
11
  gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" : "without RubyGems"
12
12
  engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
13
13
  res = ''
14
- res << "nanoc #{Nanoc::VERSION} © 2007-2012 Denis Defreyne.\n".make_compatible_with_env
14
+ res << "nanoc #{Nanoc::VERSION} © 2007-2012 Denis Defreyne.\n"
15
15
  res << "Running #{engine} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} #{gem_info}.\n"
16
16
  res
17
17
  end
@@ -237,7 +237,7 @@ module Nanoc
237
237
  basic_path = rule.apply_to(rep, :compiler => self)
238
238
  next if basic_path.nil?
239
239
  if basic_path !~ %r{^/}
240
- raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash.".make_compatible_with_env
240
+ raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash."
241
241
  end
242
242
 
243
243
  # Get raw path by prepending output directory
@@ -35,11 +35,11 @@ module Nanoc
35
35
  #
36
36
  # @see Nanoc::ItemRep#filter
37
37
  #
38
- # @param [Symbol] filter_name The name of the filter to run the item
38
+ # @param [Symbol] name The name of the filter to run the item
39
39
  # representations' content through
40
40
  #
41
- # @param [Hash] filter_args The filter arguments that should be passed to
42
- # the filter's #run method
41
+ # @param [Hash] args The filter arguments that should be passed to the
42
+ # filter's #run method
43
43
  #
44
44
  # @return [void]
45
45
  def filter(name, args={})
@@ -9,24 +9,6 @@ module Nanoc::StringExtensions
9
9
  "/#{self}/".gsub(/^\/+|\/+$/, '/')
10
10
  end
11
11
 
12
- # Replaces Unicode characters with their ASCII decompositions if the
13
- # environment does not support Unicode.
14
- #
15
- # This method is not suited for general usage. If you need similar
16
- # functionality, consider using the Iconv library instead.
17
- #
18
- # @return [String] The decomposed string
19
- def make_compatible_with_env
20
- # Check whether environment supports Unicode
21
- # FIXME this is ugly, and there most likely are better ways to do this
22
- is_unicode_supported = %w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/ }
23
- return self if is_unicode_supported
24
-
25
- # Decompose if necessary
26
- # FIXME this decomposition is not generally usable
27
- self.gsub(/“|”/, '"').gsub(/‘|’/, '\'').gsub('…', '...').gsub('©', '(c)')
28
- end
29
-
30
12
  # Calculates the checksum for this string. Any change to this string will
31
13
  # result in a different checksum.
32
14
  #
@@ -9,6 +9,11 @@ module Nanoc
9
9
  class Generic < ::StandardError
10
10
  end
11
11
 
12
+ # Generic trivial error. Superclass for all nanoc-specific errors that are
13
+ # considered "trivial", i.e. errors that do not require a full crash report.
14
+ class GenericTrivial < Generic
15
+ end
16
+
12
17
  # Error that is raised when a site is loaded that uses a data source with
13
18
  # an unknown identifier.
14
19
  class UnknownDataSource < Generic
@@ -16,7 +21,7 @@ module Nanoc
16
21
  # @param [String] data_source_name The data source name for which no
17
22
  # data source could be found
18
23
  def initialize(data_source_name)
19
- super("The data source specified in the site’s configuration file, “#{data_source_name}”, does not exist.".make_compatible_with_env)
24
+ super("The data source specified in the site’s configuration file, “#{data_source_name}”, does not exist.")
20
25
  end
21
26
 
22
27
  end
@@ -28,7 +33,7 @@ module Nanoc
28
33
  # @param [String] layout_identifier The layout identifier for which no
29
34
  # layout could be found
30
35
  def initialize(layout_identifier)
31
- super("The site does not have a layout with identifier “#{layout_identifier}”.".make_compatible_with_env)
36
+ super("The site does not have a layout with identifier “#{layout_identifier}”.")
32
37
  end
33
38
 
34
39
  end
@@ -40,7 +45,7 @@ module Nanoc
40
45
  # @param [Symbol] filter_name The filter name for which no filter could
41
46
  # be found
42
47
  def initialize(filter_name)
43
- super("The requested filter, “#{filter_name}”, does not exist.".make_compatible_with_env)
48
+ super("The requested filter, “#{filter_name}”, does not exist.")
44
49
  end
45
50
 
46
51
  end
@@ -53,7 +58,7 @@ module Nanoc
53
58
  # @param [String] layout_identifier The identifier of the layout for
54
59
  # which the filter could not be determined
55
60
  def initialize(layout_identifier)
56
- super("The filter to be used for the “#{layout_identifier}” layout could not be determined. Make sure the layout does have a filter.".make_compatible_with_env)
61
+ super("The filter to be used for the “#{layout_identifier}” layout could not be determined. Make sure the layout does have a filter.")
57
62
  end
58
63
 
59
64
  end
@@ -66,7 +71,7 @@ module Nanoc
66
71
  # that mutually depend on each other
67
72
  def initialize(reps)
68
73
  list = reps.map { |r| r.inspect }.join("\n")
69
- super("The site cannot be compiled because the following items mutually depend on each other:\n#{list}.".make_compatible_with_env)
74
+ super("The site cannot be compiled because the following items mutually depend on each other:\n#{list}.")
70
75
  end
71
76
 
72
77
  end
@@ -76,7 +81,7 @@ module Nanoc
76
81
  class NoRulesFileFound < Generic
77
82
 
78
83
  def initialize
79
- super("This site does not have a rules file, which is required for nanoc sites.".make_compatible_with_env)
84
+ super("This site does not have a rules file, which is required for nanoc sites.")
80
85
  end
81
86
 
82
87
  end
@@ -88,7 +93,7 @@ module Nanoc
88
93
  # @param [Nanoc::Item] item The item for which no compilation rule
89
94
  # could be found
90
95
  def initialize(item)
91
- super("No compilation rules were found for the “#{item.identifier}” item.".make_compatible_with_env)
96
+ super("No compilation rules were found for the “#{item.identifier}” item.")
92
97
  end
93
98
 
94
99
  end
@@ -97,10 +102,10 @@ module Nanoc
97
102
  # current item can be found.
98
103
  class NoMatchingRoutingRuleFound < Generic
99
104
 
100
- # @param [Nanoc::Item] item The item for which no routing rule could be
101
- # found
105
+ # @param [Nanoc::ItemRep] rep The item repiresentation for which no
106
+ # routing rule could be found
102
107
  def initialize(rep)
103
- super("No routing rules were found for the “#{rep.item.identifier}” item (rep “#{rep.name}”).".make_compatible_with_env)
108
+ super("No routing rules were found for the “#{rep.item.identifier}” item (rep “#{rep.name}”).")
104
109
  end
105
110
 
106
111
  end
@@ -113,11 +118,11 @@ module Nanoc
113
118
  # compiled
114
119
  attr_reader :rep
115
120
 
116
- # @param [Nanoc::ItemRep] The item representation that cannot yet be
121
+ # @param [Nanoc::ItemRep] rep The item representation that cannot yet be
117
122
  # compiled
118
123
  def initialize(rep)
119
124
  @rep = rep
120
- super("The current item cannot be compiled yet because of an unmet dependency on the “#{rep.item.identifier}” item (rep “#{rep.name}”).".make_compatible_with_env)
125
+ super("The current item cannot be compiled yet because of an unmet dependency on the “#{rep.item.identifier}” item (rep “#{rep.name}”).")
121
126
  end
122
127
 
123
128
  end
@@ -125,10 +130,10 @@ module Nanoc
125
130
  # Error that is raised when a binary item is attempted to be laid out.
126
131
  class CannotLayoutBinaryItem < Generic
127
132
 
128
- # @param [Nanoc::ItemRep] The item representation that was attempted to
129
- # be laid out
133
+ # @param [Nanoc::ItemRep] rep The item representation that was attempted
134
+ # to be laid out
130
135
  def initialize(rep)
131
- super("The “{rep.item.identifier}” item (rep “#{rep.name}”) cannot be laid out because it is a binary item. If you are getting this error for an item that should be textual instead of binary, make sure that its extension is included in the text_extensions array in the site configuration.".make_compatible_with_env)
136
+ super("The “{rep.item.identifier}” item (rep “#{rep.name}”) cannot be laid out because it is a binary item. If you are getting this error for an item that should be textual instead of binary, make sure that its extension is included in the text_extensions array in the site configuration.")
132
137
  end
133
138
 
134
139
  end
@@ -142,7 +147,7 @@ module Nanoc
142
147
  #
143
148
  # @param [Class] filter_class The filter class that was used
144
149
  def initialize(rep, filter_class)
145
- super("The “#{filter_class.inspect}” filter cannot be used to filter the “#{rep.item.identifier}” item (rep “#{rep.name}”), because textual filters cannot be used on binary items.".make_compatible_with_env)
150
+ super("The “#{filter_class.inspect}” filter cannot be used to filter the “#{rep.item.identifier}” item (rep “#{rep.name}”), because textual filters cannot be used on binary items.")
146
151
  end
147
152
 
148
153
  end
@@ -156,7 +161,7 @@ module Nanoc
156
161
  #
157
162
  # @param [Class] filter_class The filter class that was used
158
163
  def initialize(rep, filter_class)
159
- super("The “#{filter_class.inspect}” filter cannot be used to filter the “#{rep.item.identifier}” item (rep “#{rep.name}”), because binary filters cannot be used on textual items. If you are getting this error for an item that should be textual instead of binary, make sure that its extension is included in the text_extensions array in the site configuration.".make_compatible_with_env)
164
+ super("The “#{filter_class.inspect}” filter cannot be used to filter the “#{rep.item.identifier}” item (rep “#{rep.name}”), because binary filters cannot be used on textual items. If you are getting this error for an item that should be textual instead of binary, make sure that its extension is included in the text_extensions array in the site configuration.")
160
165
  end
161
166
 
162
167
  end
@@ -192,7 +197,7 @@ module Nanoc
192
197
  # @param [Symbol] snapshot The name of the snapshot that was attempted to
193
198
  # be made
194
199
  def initialize(rep, snapshot)
195
- super("Attempted to create a snapshot with a duplicate name #{snapshot.inspect} for the item rep “#{rep.inspect}”".make_compatible_with_env)
200
+ super("Attempted to create a snapshot with a duplicate name #{snapshot.inspect} for the item rep “#{rep.inspect}”")
196
201
  end
197
202
 
198
203
  end
@@ -201,7 +206,7 @@ module Nanoc
201
206
  class DataNotYetAvailable < Generic
202
207
 
203
208
  def initialize(type, plural)
204
- super("#{type} #{plural ? 'are' : 'is'} not available yet. You may be missing a Nanoc::Site#load_data call.".make_compatible_with_env)
209
+ super("#{type} #{plural ? 'are' : 'is'} not available yet. You may be missing a Nanoc::Site#load_data call.")
205
210
  end
206
211
 
207
212
  end
@@ -14,7 +14,7 @@ module Nanoc
14
14
 
15
15
  # Sets the identifiers for this plugin.
16
16
  #
17
- # @param [Array<Symbol>] identifier A list of identifiers to assign to
17
+ # @param [Array<Symbol>] identifiers A list of identifiers to assign to
18
18
  # this plugin.
19
19
  #
20
20
  # @return [void]
@@ -115,8 +115,7 @@ module Nanoc
115
115
  #
116
116
  # @api private
117
117
  #
118
- # @param [String, nil] raw_path The raw path to write the compiled rep
119
- # to. If nil, the default raw path will be used.
118
+ # @param [Symbol, nil] snapshot The name of the snapshot to write.
120
119
  #
121
120
  # @return [void]
122
121
  def write(snapshot=:last)
@@ -32,7 +32,7 @@ module Nanoc
32
32
  # that lacks some options, the default value will be taken from
33
33
  # `DEFAULT_CONFIG`.
34
34
  DEFAULT_CONFIG = {
35
- :text_extensions => %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee ),
35
+ :text_extensions => %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms ).sort,
36
36
  :output_dir => 'output',
37
37
  :data_sources => [ {} ],
38
38
  :index_filenames => [ 'index.html' ],
data/lib/nanoc/cli.rb CHANGED
@@ -7,13 +7,16 @@ module Nanoc::CLI
7
7
  module Commands
8
8
  end
9
9
 
10
- autoload 'Logger', 'nanoc/cli/logger'
11
- autoload 'CommandRunner', 'nanoc/cli/command_runner'
12
- autoload 'ErrorHandler', 'nanoc/cli/error_handler'
10
+ autoload 'ANSIStringColorizer', 'nanoc/cli/ansi_string_colorizer'
11
+ autoload 'Logger', 'nanoc/cli/logger'
12
+ autoload 'CommandRunner', 'nanoc/cli/command_runner'
13
+ autoload 'CleaningStream', 'nanoc/cli/cleaning_stream'
14
+ autoload 'StreamCleaners', 'nanoc/cli/stream_cleaners'
15
+ autoload 'ErrorHandler', 'nanoc/cli/error_handler'
13
16
 
14
17
  # Deprecated; use CommandRunner instead
15
18
  # TODO [in nanoc 4.0] remove me
16
- autoload 'Command', 'nanoc/cli/command_runner'
19
+ autoload 'Command', 'nanoc/cli/command_runner'
17
20
 
18
21
  # @return [Boolean] true if debug output is enabled, false if not
19
22
  #
@@ -60,6 +63,9 @@ protected
60
63
  #
61
64
  # @return [void]
62
65
  def self.setup
66
+ # Set up output streams
67
+ self.setup_cleaning_streams
68
+
63
69
  # Reinit
64
70
  @root_command = nil
65
71
 
@@ -134,4 +140,40 @@ protected
134
140
  files
135
141
  end
136
142
 
143
+ # Wraps `$stdout` and `$stderr` in appropriate cleaning streams.
144
+ #
145
+ # @return [void]
146
+ def self.setup_cleaning_streams
147
+ $stdout = Nanoc::CLI::CleaningStream.new($stdout)
148
+ $stderr = Nanoc::CLI::CleaningStream.new($stderr)
149
+
150
+ if !self.enable_utf8?
151
+ $stdout.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
152
+ $stderr.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
153
+ end
154
+
155
+ if !self.enable_ansi_colors?
156
+ $stdout.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
157
+ $stderr.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
158
+ end
159
+ end
160
+
161
+ # @return [Boolean] true if UTF-8 support is present, false if not
162
+ def self.enable_utf8?
163
+ %w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/ }
164
+ end
165
+
166
+ # @return [Boolean] true if color support is present, false if not
167
+ def self.enable_ansi_colors?
168
+ return false if !$stdout.tty?
169
+
170
+ begin
171
+ require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin|mingw/
172
+ rescue LoadError
173
+ return false
174
+ end
175
+
176
+ return true
177
+ end
178
+
137
179
  end