Blob Blame Raw
From 0082a57f47aafb4ba3def4754602bdc0750ead6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
Date: Fri, 24 Nov 2017 16:40:07 +0100
Subject: [PATCH 08/20] Make ruby_parser_swig Ruby2.5-aware

---
 bindings/ruby/rdoc_parser_swig.rb | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/bindings/ruby/rdoc_parser_swig.rb b/bindings/ruby/rdoc_parser_swig.rb
index 6f72f791..0c5bd415 100644
--- a/bindings/ruby/rdoc_parser_swig.rb
+++ b/bindings/ruby/rdoc_parser_swig.rb
@@ -364,11 +364,17 @@ class RDoc::Parser::SWIG < RDoc::Parser
 
       #meth_obj.params = params
       meth_obj.start_collecting_tokens
-      tk = RDoc::RubyToken::Token.new nil, 1, 1
-      tk.set_text body
+      begin
+        RDoc::const_get "RubyToken"
+        tk = RDoc::RubyToken::Token.new nil, 1, 1
+        tk.set_text body
+        meth_obj.offset  = offset
+      rescue NameError
+        # rdoc 2.5
+        tk = { :line_no => 1, :char_no => 1, :text => body }
+      end
       meth_obj.add_token tk
       meth_obj.comment = strip_stars comment
-      meth_obj.offset  = offset
       meth_obj.line    = file_content[0, offset].count("\n") + 1
 
       body
@@ -381,11 +387,17 @@ class RDoc::Parser::SWIG < RDoc::Parser
       find_modifiers comment, meth_obj
 
       meth_obj.start_collecting_tokens
-      tk = RDoc::RubyToken::Token.new nil, 1, 1
-      tk.set_text body
+      begin
+        RDoc::const_get "RubyToken"
+        tk = RDoc::RubyToken::Token.new nil, 1, 1
+        tk.set_text body
+        meth_obj.offset  = offset
+      rescue NameError
+        # rdoc 2.5
+        tk = { :line_no => 1, :char_no => 1, :text => body }
+      end
       meth_obj.add_token tk
       meth_obj.comment = strip_stars(comment) + meth_obj.comment.to_s
-      meth_obj.offset  = offset
       meth_obj.line    = file_content[0, offset].count("\n") + 1
 
       body
-- 
2.15.1