Sha256: ddcfe5462a400635d6c6347d43a7d65cb897ba6e02b25166a9903096e5bc05c7

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

module Orthoses
  # Call `rbs prototype rb` and add to store
  #     use Orthoses::RBSPrototypeRB,
  #       paths: Dir.glob("lib/**/*.rb")
  class RBSPrototypeRB
    def initialize(loader, paths:, constant_filter: nil, mixin_filter: nil, attribute_filter: nil)
      @loader = loader
      @paths = paths
      @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(
          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

14 entries across 14 versions & 1 rubygems

Version Path
orthoses-1.6.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.5.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.4.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.3.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.2.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.1.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-1.0.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.11.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.10.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.9.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.8.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.7.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.6.0 lib/orthoses/rbs_prototype_rb.rb
orthoses-0.5.0 lib/orthoses/rbs_prototype_rb.rb