diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index 9d6f0d4356..5318b4cc57 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -1,5 +1,8 @@ require 'json' -require 'zlib' +begin + require 'zlib' +rescue LoadError +end ## # The JsonIndex generator is designed to complement an HTML generator and @@ -157,6 +160,8 @@ class RDoc::Generator::JsonIndex # Compress the search_index.js file using gzip def generate_gzipped + return unless defined?(Zlib) + debug_msg "Compressing generated JSON index" out_dir = @base_dir + @options.op_dir diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 06a5ddcd4a..9283fd9b76 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -137,7 +137,11 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase end def test_generate_gzipped - require 'zlib' + begin + require 'zlib' + rescue LoadError + skip "no zlib" + end @g.generate @g.generate_gzipped