Sha256: 8fdb8a1e2ef909ec2a1e5abcbb3960f10bed3e292ede31a71b6bac433f8b1da9

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 KB

Contents

module Steep
  class Project
    class FileLoader
      attr_reader :project

      def initialize(project:)
        @project = project
      end

      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.sort.each do |source_path|
              yield project.relative_path(source_path)
            end
          end
        end
      end

      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

      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
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
steep-0.29.0 lib/steep/project/file_loader.rb
steep-0.28.0 lib/steep/project/file_loader.rb
steep-0.27.0 lib/steep/project/file_loader.rb
steep-0.25.0 lib/steep/project/file_loader.rb
steep-0.24.0 lib/steep/project/file_loader.rb
steep-0.23.0 lib/steep/project/file_loader.rb
steep-0.22.0 lib/steep/project/file_loader.rb
steep-0.21.0 lib/steep/project/file_loader.rb
steep-0.20.0 lib/steep/project/file_loader.rb
steep-0.19.0 lib/steep/project/file_loader.rb
steep-0.18.0 lib/steep/project/file_loader.rb