Class: Steep::Project::FileLoader
- Inherits:
-
Object
- Object
- Steep::Project::FileLoader
- Defined in:
- lib/steep/project/file_loader.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #each_path_in_patterns(patterns, ext) ⇒ Object
-
#initialize(project:) ⇒ FileLoader
constructor
A new instance of FileLoader.
- #load_signatures ⇒ Object
- #load_sources(command_line_patterns) ⇒ Object
Constructor Details
#initialize(project:) ⇒ FileLoader
Returns a new instance of FileLoader.
6 7 8 |
# File 'lib/steep/project/file_loader.rb', line 6 def initialize(project:) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
4 5 6 |
# File 'lib/steep/project/file_loader.rb', line 4 def project @project end |
Instance Method Details
#each_path_in_patterns(patterns, ext) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/steep/project/file_loader.rb', line 10 def each_path_in_patterns(patterns, ext) patterns.each do |path| absolute_path = project.base_dir + path if absolute_path.file? yield project.relative_path(absolute_path) else files = if absolute_path.directory? Pathname.glob("#{absolute_path}/**/*#{ext}") else Pathname.glob(absolute_path) end files.each do |source_path| yield project.relative_path(source_path) end end end end |
#load_signatures ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/steep/project/file_loader.rb', line 47 def load_signatures() project.targets.each do |target| Steep.logger.tagged "target=#{target.name}" do each_path_in_patterns target.signature_patterns, ".rbs" do |path| if target.possible_signature_file?(path) unless target.signature_file?(path) Steep.logger.info { "Adding signature file: #{path}" } target.add_signature path, project.absolute_path(path).read end end end end end end |
#load_sources(command_line_patterns) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/steep/project/file_loader.rb', line 30 def load_sources(command_line_patterns) project.targets.each do |target| Steep.logger.tagged "target=#{target.name}" do target_patterns = command_line_patterns.empty? ? target.source_patterns : command_line_patterns each_path_in_patterns target_patterns, ".rb" do |path| if target.possible_source_file?(path) unless target.source_file?(path) Steep.logger.info { "Adding source file: #{path}" } target.add_source path, project.absolute_path(path).read end end end end end end |