Module: Indexer::Importer::RubyImportation
- Included in:
- Indexer::Importer
- Defined in:
- lib/indexer/importer/ruby.rb
Overview
Build metadata from a Ruby script.
Instance Method Summary collapse
-
#import(source) ⇒ Object
Ruby script import procedure.
-
#load_ruby(file) ⇒ Object
Load ruby file by simply evaluating it in the context of the Builder instance.
Instance Method Details
#import(source) ⇒ Object
Ruby script import procedure.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/indexer/importer/ruby.rb', line 12 def import(source) if File.file?(source) case File.extname(source) when '.rb' # TODO: Other ruby extensions ? load_ruby(source) true else text = read(source) if text !=~ /\A---/ # not YAML load_ruby(source) true else super(source) if defined?(super) end end else super(source) if defined?(super) end end |
#load_ruby(file) ⇒ Object
Load ruby file by simply evaluating it in the context of the Builder instance.
36 37 38 |
# File 'lib/indexer/importer/ruby.rb', line 36 def load_ruby(file) instance_eval(File.read(file)) end |