Skip to content

Commit

Permalink
Merge pull request #1619 from ruby/cli_test_no_bundler
Browse files Browse the repository at this point in the history
Stop using `bundle` command
  • Loading branch information
soutaro authored Nov 21, 2023
2 parents 3d6c825 + 367f381 commit bd79c0b
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 74 deletions.
3 changes: 1 addition & 2 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ target :lib do
"lib/rbs/test.rb"
)

library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint'
signature 'stdlib/yaml/0'
library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml'
signature "stdlib/strscan/0/"
signature "stdlib/optparse/0/"
signature "stdlib/rdoc/0/"
Expand Down
9 changes: 5 additions & 4 deletions lib/rbs/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ def build_methods(path)
builder.build_instance(@type_name).methods
rescue => e
RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
{}
{} #: Hash[Symbol, Definition::Method]
end
singleton_methods = begin
builder.build_singleton(@type_name).methods
rescue => e
RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
{}
{} #: Hash[Symbol, Definition::Method]
end

constant_children = begin
constant_resolver = RBS::Resolver::ConstantResolver.new(builder: builder)
constant_resolver.children(@type_name)
rescue => e
RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
{}
{} #: Hash[Symbol, Constant]
end

[ instance_methods, singleton_methods, constant_children ]
Expand Down Expand Up @@ -101,7 +101,8 @@ def definition_method_to_s(key, kind, definition_method)
prefix = kind == :instance ? "" : "self."

if definition_method.alias_of
"alias #{prefix}#{key} #{prefix}#{definition_method.alias_of.defs.first.member.name}"
first_def = definition_method.alias_of.defs.first #: Definition::Method::TypeDef
"alias #{prefix}#{key} #{prefix}#{first_def.member.name}"
else
"def #{prefix}#{key}: #{definition_method.method_types.join(" | ")}"
end
Expand Down
4 changes: 3 additions & 1 deletion lib/rbs/prototype/runtime/value_object_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def build_decl
# def self.members: () -> [ :foo, :bar ]
# def members: () -> [ :foo, :bar ]
def build_s_members
[:singleton, :instance].map do |kind|
(
[:singleton, :instance] #: Array[AST::Members::MethodDefinition::kind]
).map do |kind|
AST::Members::MethodDefinition.new(
name: :members,
overloads: [
Expand Down
5 changes: 4 additions & 1 deletion sig/diff.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ module RBS
def each_diff: () { (String before, String after) -> void } -> void

private def each_diff_by: (Symbol kind, Hash[::Symbol, Definition::Method] before_methods, Hash[::Symbol, Definition::Method] after_methods) { (String before, String after) -> void } -> void
private def build_methods: (Array[String] path) -> [ Hash[::Symbol, Definition::Method], Hash[::Symbol, Definition::Method] ]
private def build_methods: (Array[String] path) -> [ Hash[::Symbol, Definition::Method], Hash[::Symbol, Definition::Method] , Hash[Symbol, Constant]]
private def build_env: (Array[String] path) -> Environment
private def build_builder: (Environment env) -> DefinitionBuilder
private def definition_method_to_s: (Symbol key, Symbol kind, Definition::Method definition_method) -> String?
private def each_diff_methods: (Symbol kind, Hash[Symbol, Definition::Method], Hash[Symbol, Definition::Method]) { (String before, String after) -> void } -> void
private def each_diff_constants: (Hash[Symbol, Constant] before_constants, Hash[Symbol, Constant] after_constants) { (String before, String after) -> void } -> void
private def constant_to_s: (Constant?) -> String
end
end
22 changes: 19 additions & 3 deletions sig/prototype/runtime.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ module RBS
module Prototype
class Runtime
module Reflection
self.@object_class: UnboundMethod
def self.object_class: (Module value) -> Class

self.@constants_of: UnboundMethod
def self.constants_of: (Module mod, ?bool inherit) -> Array[Symbol]
end

module Helpers
@module_name_method: UnboundMethod
@untyped: Types::Bases::Any

private

def const_name: (Module const) -> String?
Expand All @@ -19,12 +24,15 @@ module RBS

def to_type_name: (String name, ?full_name: bool) -> TypeName

def untyped: () -> untyped
def untyped: () -> Types::Bases::Any
end

class ValueObjectBase
include Helpers

# @target_class stores the singleton object of `Data` or `Struct` subclass
@target_class: untyped

def build_decl: () -> AST::Declarations::Class

private
Expand All @@ -33,6 +41,10 @@ module RBS

def build_s_members: () -> Array[AST::Members::MethodDefinition]

def build_super_class: () -> AST::Declarations::Class::Super

def add_decl_members: (AST::Declarations::Class) -> void

def initialize: (Class target_class) -> void
end

Expand Down Expand Up @@ -77,9 +89,9 @@ module RBS

def skip_mixin?: (type_name: TypeName, module_name: TypeName, mixin_class: mixin_class) -> bool

def skip_singleton_method?: (module_name: TypeName, name: Symbol) -> bool
def skip_singleton_method?: (module_name: TypeName, method: UnboundMethod, accessibility: Definition::accessibility) -> bool

def skip_instance_method?: (module_name: TypeName, name: Symbol) -> bool
def skip_instance_method?: (module_name: TypeName, method: UnboundMethod, accessibility: Definition::accessibility) -> bool

def skip_constant?: (module_name: String, name: Symbol) -> bool

Expand Down Expand Up @@ -147,6 +159,8 @@ module RBS

def generate_module: (Module mod) -> void

def generate_mixin: (Module mod, AST::Declarations::Class | AST::Declarations::Module, TypeName, TypeName) -> void

# Generate/find outer module declarations
# This is broken down into another method to comply with `DRY`
# This generates/finds declarations in nested form & returns the last array of declarations
Expand All @@ -158,6 +172,8 @@ module RBS

def block_from_ast_of: (UnboundMethod method) -> Types::Block?

def block_from_body: (RubyVM::AbstractSyntaxTree::Node) -> Types::Block?

def can_alias?: (Module, UnboundMethod) -> bool

def type_params: (Module) -> Array[AST::TypeParam]
Expand Down
4 changes: 2 additions & 2 deletions steep/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "https://rubygems.org"

gem "rbs", "~> 3.2.2"
gem "steep", "~> 1.6.0"
gem "rbs"
gem "steep"
8 changes: 5 additions & 3 deletions steep/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
abbrev (0.1.1)
activesupport (7.1.1)
base64
bigdecimal
Expand Down Expand Up @@ -39,7 +40,8 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rbs (3.2.2)
rbs (3.3.0)
abbrev
ruby2_keywords (0.0.5)
securerandom (0.3.0)
steep (1.6.0)
Expand Down Expand Up @@ -68,8 +70,8 @@ PLATFORMS
ruby

DEPENDENCIES
rbs (~> 3.2.2)
steep (~> 1.6.0)
rbs
steep

BUNDLED WITH
2.4.18
Loading

0 comments on commit bd79c0b

Please sign in to comment.