class RSpecKickstarter::RDocFactory
Public Class Methods
extract_target_class_or_module(top_level)
click to toggle source
Extracts RDoc::NormalClass/RDoc::NormalModule from RDoc::TopLevel.
# File lib/rspec_kickstarter/rdoc_factory.rb, line 55 def self.extract_target_class_or_module(top_level) c = top_level.classes.first if c.nil? m = top_level.modules.first if m.nil? top_level.is_a?(RDoc::NormalModule) ? top_level : nil else extract_target_class_or_module(m) end else c end end
get_rdoc_class_or_module(file_path)
click to toggle source
Returns RDoc::NormalClass/RDoc::NormalModule instance.
# File lib/rspec_kickstarter/rdoc_factory.rb, line 18 def self.get_rdoc_class_or_module(file_path) top_level = get_ruby_parser(file_path).scan extract_target_class_or_module(top_level) end
get_ruby_parser(file_path)
click to toggle source
Creates new RDoc::Parser::Ruby instance.
# File lib/rspec_kickstarter/rdoc_factory.rb, line 26 def self.get_ruby_parser(file_path) top_level = RDoc::TopLevel.new(file_path) if RUBY_VERSION.to_f < 2.0 # reset is removed since 2.0 RDoc::TopLevel.reset end # RDoc::Stats initialization if defined?(RDoc::Store) # RDoc 4.0.0 requires RDoc::Store internally. store = RDoc::Store.new top_level.store = store stats = RDoc::Stats.new(store, 1) else stats = RDoc::Stats.new(1) end RDoc::Parser::Ruby.new( top_level, file_path, File.read(file_path), RDoc::Options.new, stats ) end