Sha256: f6d988afe5fbf6cdf0545faa6b39a3353a94d3ed3f3f279a3bb620c328a30dee

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Yoda
  module Store
    module Actions
      class ReadProjectFiles
        # @return [Registry]
        attr_reader :registry

        # @return [String]
        attr_reader :root_path

        # @param project [Project]
        # @return [ReadProjectFiles]
        def self.for_project(project)
          new(project.registry, project.root_path)
        end

        def initialize(registry, root_path)
          @registry = registry
          @root_path = root_path
        end

        def run
          files = project_files
          progress = Instrument::Progress.new(files.length) do |index:, length:|
            Instrument.instance.initialization_progress(phase: :load_project_files, message: "Loading current project files (#{index} / #{length})", index: index, length: length)
          end

          files.each do |file|
            ReadFile.run(registry, file)
            progress.increment
          end
        end

        private

        # @return [Array<String>]
        def project_files
          Dir.chdir(root_path) { Dir.glob(["{lib,app}/**/*.rb", "ext/**/*.c", ".yoda/*.rb"]).map { |name| File.expand_path(name, root_path) } }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yoda-language-server-0.9.0 lib/yoda/store/actions/read_project_files.rb
yoda-language-server-0.8.0 lib/yoda/store/actions/read_project_files.rb