From 9da887cf57527f47146fc441f6d40e655aaadbb6 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 23 Mar 2015 05:15:15 +0000 Subject: [PATCH] json_index.rb: check zlib * lib/rdoc/generator/json_index.rb (generate_gzipped): do nothing unless zlib is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/generator/json_index.rb | 7 ++++++- test/rdoc/test_rdoc_generator_json_index.rb | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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