Class: RSpecKickstarter::RDocFactory
- Inherits:
-
Object
- Object
- RSpecKickstarter::RDocFactory
- Defined in:
- lib/rspec_kickstarter/rdoc_factory.rb
Class Method Summary collapse
-
.extract_target_class_or_module(top_level) ⇒ Object
Extracts RDoc::NormalClass/RDoc::NormalModule from RDoc::TopLevel.
-
.get_rdoc_class_or_module(file_path) ⇒ Object
Returns RDoc::NormalClass/RDoc::NormalModule instance.
-
.get_ruby_parser(file_path) ⇒ Object
Creates new RDoc::Parser::Ruby instance.
Class Method Details
.extract_target_class_or_module(top_level) ⇒ Object
Extracts RDoc::NormalClass/RDoc::NormalModule from RDoc::TopLevel.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rspec_kickstarter/rdoc_factory.rb', line 56 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) ⇒ Object
Returns RDoc::NormalClass/RDoc::NormalModule instance.
19 20 21 22 |
# File 'lib/rspec_kickstarter/rdoc_factory.rb', line 19 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) ⇒ Object
Creates new RDoc::Parser::Ruby instance.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rspec_kickstarter/rdoc_factory.rb', line 27 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 |