Class: Rubyzen::Project
- Inherits:
-
Object
- Object
- Rubyzen::Project
- Defined in:
- lib/rubyzen/project.rb
Overview
Main entry point for analyzing a Ruby project. Parses all .rb files in the given paths and provides access to files, classes, and modules.
Instance Method Summary collapse
-
#classes ⇒ Collections::ClassesCollection
Returns all classes found across all parsed files.
-
#files ⇒ Collections::FileCollection
Returns all parsed files as a filterable collection.
-
#initialize(paths = nil) ⇒ Project
constructor
A new instance of Project.
-
#modules ⇒ Collections::ModulesCollection
Returns all modules found across all parsed files.
Constructor Details
#initialize(paths = nil) ⇒ Project
Returns a new instance of Project.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyzen/project.rb', line 16 def initialize(paths = nil) paths ||= Rubyzen.configuration.project_paths @root_paths = Array(paths).map { |p| File.(p) } @root_paths.each do |path| unless File.exist?(path) raise Rubyzen::Error, "Path does not exist: #{path}" end end @file_paths = @root_paths.flat_map do |path| if File.directory?(path) Dir[File.join(path, '**', '*.rb')] else [path] end end.uniq @parser = Rubyzen::Parsers::ASTParser.instance end |
Instance Method Details
#classes ⇒ Collections::ClassesCollection
Returns all classes found across all parsed files.
48 49 50 51 |
# File 'lib/rubyzen/project.rb', line 48 def classes all_classes = file_declarations.flat_map(&:classes) Collections::ClassesCollection.new(all_classes) end |
#files ⇒ Collections::FileCollection
Returns all parsed files as a filterable collection.
40 41 42 43 |
# File 'lib/rubyzen/project.rb', line 40 def files all_files = file_declarations Collections::FileCollection.new(all_files) end |
#modules ⇒ Collections::ModulesCollection
Returns all modules found across all parsed files.
56 57 58 59 |
# File 'lib/rubyzen/project.rb', line 56 def modules all_modules = file_declarations.flat_map(&:modules) Collections::ModulesCollection.new(all_modules) end |