Sha256: 36608942b3c9dc9bf65355d58cb95b0401f7e995190db7f2d07afadbb897b303

Contents?: true

Size: 933 Bytes

Versions: 11

Compression:

Stored size: 933 Bytes

Contents

module Steep
  class Project
    class SignatureFile
      attr_reader :path
      attr_reader :content
      attr_reader :content_updated_at

      attr_reader :status

      ParseErrorStatus = Struct.new(:error, :timestamp, keyword_init: true)
      DeclarationsStatus = Struct.new(:declarations, :timestamp, keyword_init: true)

      def initialize(path:)
        @path = path
        self.content = ""
      end

      def content=(content)
        @content_updated_at = Time.now
        @content = content
        @status = nil
      end

      def load!
        buffer = RBS::Buffer.new(name: path, content: content)
        decls = RBS::Parser.parse_signature(buffer)
        @status = DeclarationsStatus.new(declarations: decls, timestamp: Time.now)
      rescue RBS::Parser::SyntaxError, RBS::Parser::SemanticsError => exn
        @status = ParseErrorStatus.new(error: exn, timestamp: Time.now)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
steep-0.39.0 lib/steep/project/signature_file.rb
steep-0.38.0 lib/steep/project/signature_file.rb
steep-0.37.0 lib/steep/project/signature_file.rb
steep-0.36.0 lib/steep/project/signature_file.rb
steep-0.35.0 lib/steep/project/signature_file.rb
steep-0.34.0 lib/steep/project/signature_file.rb
steep-0.33.0 lib/steep/project/signature_file.rb
steep-0.32.0 lib/steep/project/signature_file.rb
steep-0.31.1 lib/steep/project/signature_file.rb
steep-0.31.0 lib/steep/project/signature_file.rb
steep-0.30.0 lib/steep/project/signature_file.rb