Sha256: f6eb7d552dc6fa4b5e3f41591d79d8d10e338ea0e97e4e0b1bcea403d5709405

Contents?: true

Size: 1.52 KB

Versions: 13

Compression:

Stored size: 1.52 KB

Contents

module Orthoses
  # Call `rbs prototype rb` and add to store
  #     use Orthoses::RBSPrototypeRB,
  #       paths: Dir.glob("lib/**/*.rb"),
  #       method_definition_filter: ->(member) { false },
  #       alias_filter: ->(member) { false }
  class RBSPrototypeRB
    def initialize(
      loader,
      paths:,
      method_definition_filter: nil,
      alias_filter: nil,
      constant_filter: nil,
      mixin_filter: nil,
      attribute_filter: nil
    )
      @loader = loader
      @paths = paths
      @method_definition_filter = method_definition_filter
      @alias_filter = alias_filter
      @constant_filter = constant_filter
      @mixin_filter = mixin_filter
      @attribute_filter = attribute_filter
    end

    def call
      @loader.call.tap do |store|
        parser = RBS::Prototype::RB.new
        @paths.each do |path|
          begin
            Orthoses.logger.debug("parse #{path} by RBS::Prototype::RB")
            parser.parse File.read(path.to_s)
          rescue => err
            Orthoses.logger.error("Parse error #{err.inspect} by RBS::Prototype::RB #{path}")
          end
        end
        env = Orthoses::Content::Environment.new(
          method_definition_filter: @method_definition_filter,
          alias_filter: @alias_filter,
          constant_filter: @constant_filter,
          mixin_filter: @mixin_filter,
          attribute_filter: @attribute_filter,
        )
        parser.decls.each do |decl|
          env << decl
        end
        env.write_to(store: store)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
orthoses-1.19.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.18.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.17.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.16.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.15.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.14.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.13.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.12.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.11.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.10.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.9.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.8.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.7.0 lib/orthoses/rbs_prototype_rb.rb