Class: Inch::SourceParser
- Inherits:
-
Object
- Object
- Inch::SourceParser
- Defined in:
- lib/inch/source_parser.rb
Overview
Parses the source tree (using YARD)
Class Method Summary collapse
-
.run(*args) ⇒ SourceParser
Helper method to run an instance with the given
args
.
Instance Method Summary collapse
-
#all_objects ⇒ Array<CodeObject::Proxy::Base>
Returns all parsed objects as code object proxies.
-
#find_object(path) ⇒ CodeObject::Proxy::Base
(also: #[])
Returns the object with the given
path
. -
#find_objects(path) ⇒ Array<CodeObject::Proxy::Base>
Returns all objects where the
path
starts_with the givenpath
. - #run(paths, excluded = []) ⇒ Object
Class Method Details
.run(*args) ⇒ SourceParser
Helper method to run an instance with the given args
8 9 10 11 12 |
# File 'lib/inch/source_parser.rb', line 8 def self.run(*args) parser = self.new parser.run(*args) parser end |
Instance Method Details
#all_objects ⇒ Array<CodeObject::Proxy::Base>
Returns all parsed objects as code object proxies
18 19 20 21 22 |
# File 'lib/inch/source_parser.rb', line 18 def all_objects @all_objects ||= all_parsed_objects.map do |o| CodeObject::Proxy.for(o) end.sort_by(&:path) end |
#find_object(path) ⇒ CodeObject::Proxy::Base Also known as: []
Returns the object with the given path
33 34 35 |
# File 'lib/inch/source_parser.rb', line 33 def find_object(path) all_objects.detect { |o| o.path == path } end |
#find_objects(path) ⇒ Array<CodeObject::Proxy::Base>
Returns all objects where the path
starts_with the given path
47 48 49 |
# File 'lib/inch/source_parser.rb', line 47 def find_objects(path) all_objects.select { |o| o.path.start_with?(path) } end |
#run(paths, excluded = []) ⇒ Object
51 52 53 54 |
# File 'lib/inch/source_parser.rb', line 51 def run(paths, excluded = []) YARD::Registry.clear YARD.parse(paths, excluded) end |