Class: DoubleDoc::ImportHandler
- Inherits:
-
Object
- Object
- DoubleDoc::ImportHandler
- Defined in:
- lib/double_doc/import_handler.rb
Instance Attribute Summary collapse
-
#load_paths ⇒ Object
readonly
Returns the value of attribute load_paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root, options = {}) ⇒ ImportHandler
constructor
A new instance of ImportHandler.
- #resolve_imports(source) ⇒ Object
Constructor Details
#initialize(root, options = {}) ⇒ ImportHandler
Returns a new instance of ImportHandler.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/double_doc/import_handler.rb', line 9 def initialize(root, = {}) @root = Pathname.new(root) @load_paths = [@root] if [:gemfile] begin @load_paths.concat(load_paths_from_gemfile(Bundler.root)) rescue => e puts "Could not load paths from Gemfile; please make sure you've run bundle install with the correct gemset." raise e end end @docs = {} end |
Instance Attribute Details
#load_paths ⇒ Object (readonly)
Returns the value of attribute load_paths.
7 8 9 |
# File 'lib/double_doc/import_handler.rb', line 7 def load_paths @load_paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/double_doc/import_handler.rb', line 7 def root @root end |
Instance Method Details
#resolve_imports(source) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/double_doc/import_handler.rb', line 25 def resolve_imports(source) case source when String resolve_imports_from_lines(source.split("\n")) when File resolve_imports_from_lines(source.readlines) when Array resolve_imports_from_lines(source) else raise "can't extract docs from #{source}" end end |