Skip to content

Commit

Permalink
Change Gem name to repl_type_completor
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Nov 28, 2023
1 parent f8d2d40 commit fcafc8f
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 169 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

# Specify your gem's dependencies in repl_completion.gemspec
# Specify your gem's dependencies in repl_type_completor.gemspec
gemspec

gem 'rake', '~> 13.0'
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ReplCompletion
# ReplTypeCompletor

ReplCompletion is a type based completor for REPL.
ReplTypeCompletor is a type based completor for REPL.
It uses RBS type information, performs static type analytics, uses dynamic runtime information from binding.

## Installation
Expand All @@ -19,20 +19,20 @@ If bundler is not being used to manage dependencies, install the gem by executin

Require the library
```ruby
require 'repl_completion'
require 'repl_type_completor'
```

Load RBS with one of these. It will load core library signatures, `./rbs_collection.yaml` and `./sig/**/*.rbs`.
```ruby
ReplCompletion.preload_rbs # Recommended. Preload using thread
ReplCompletion.load_rbs # Could take a seconds in large projects
ReplTypeCompletor.preload_rbs # Recommended. Preload using thread
ReplTypeCompletor.load_rbs # Could take a seconds in large projects
```

Now you can get completion candidates.
```ruby
array = [1, 2, 3]
class String; def upupup; end; end
result = ReplCompletion.analyze('array.map do str = _1.chr; str.up', binding: binding)
result = ReplTypeCompletor.analyze('array.map do str = _1.chr; str.up', binding: binding)
result.completion_candidates #=> ["case", "case!", "to", "upup"]
result.doc_namespace('case') #=> "String#upcase"
```
Expand All @@ -45,16 +45,16 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/repl_completion.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/repl_type_completor.

When something is wrong, these methods will provide some debug information.
```ruby
ReplCompletion.info
ReplCompletion.rbs_load_started?
ReplCompletion.rbs_loaded?
ReplCompletion.rbs_load_error
ReplCompletion.last_completion_error
ReplCompletion.analyze(code_to_complete, binding: binding)
ReplTypeCompletor.info
ReplTypeCompletor.rbs_load_started?
ReplTypeCompletor.rbs_loaded?
ReplTypeCompletor.rbs_load_error
ReplTypeCompletor.last_completion_error
ReplTypeCompletor.analyze(code_to_complete, binding: binding)
```

## License
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/repl_completion/test_*.rb"]
t.test_files = FileList["test/repl_type_completor/test_*.rb"]
end

# To make sure they have been correctly setup for Ruby CI.
desc "Run each repl_completion test file in isolation."
desc "Run each repl_type_completor test file in isolation."
task :test_in_isolation do
failed = false

FileList["test/repl_completion/test_*.rb"].each do |test_file|
FileList["test/repl_type_completor/test_*.rb"].each do |test_file|
ENV["TEST"] = test_file
begin
Rake::Task["test"].execute
Expand Down
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "repl_completion"
require "repl_type_completor"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -11,6 +11,6 @@ require "repl_completion"
# require "pry"
# Pry.start

ReplCompletion.preload_rbs
ReplTypeCompletor.preload_rbs
require "irb"
IRB.start(__FILE__)
10 changes: 5 additions & 5 deletions lib/repl_completion.rb → lib/repl_type_completor.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative 'repl_completion/version'
require_relative 'repl_completion/type_analyzer'
require_relative 'repl_completion/result'
require_relative 'repl_type_completor/version'
require_relative 'repl_type_completor/type_analyzer'
require_relative 'repl_type_completor/result'

module ReplCompletion
module ReplTypeCompletor
class << self
attr_reader :last_completion_error

Expand Down Expand Up @@ -54,7 +54,7 @@ def info
elsif !rbs_loaded?
rbs_info << ' signatures loading'
end
"ReplCompletion: #{VERSION}, #{prism_info}, #{rbs_info}"
"ReplTypeCompletor: #{VERSION}, #{prism_info}, #{rbs_info}"
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ReplCompletion
module ReplTypeCompletor
module Methods
OBJECT_SINGLETON_CLASS_METHOD = Object.instance_method(:singleton_class)
OBJECT_INSTANCE_VARIABLES_METHOD = Object.instance_method(:instance_variables)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ReplCompletion
module ReplTypeCompletor
module RequirePaths
class << self
def require_completions(target_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative 'require_paths'

module ReplCompletion
module ReplTypeCompletor
class Result
HIDDEN_METHODS = %w[Namespace TypeName] # defined by rbs, should be hidden
RESERVED_WORDS = %w[
Expand Down Expand Up @@ -68,7 +68,7 @@ def completion_candidates
end
candidates.select { _1.start_with?(name) }.map { _1[name.size..] }
rescue Exception => e
ReplCompletion.handle_exception(e)
ReplTypeCompletor.handle_exception(e)
[]
ensure
$VERBOSE = verbose
Expand Down Expand Up @@ -102,7 +102,7 @@ def doc_namespace(matched)
else
end
rescue Exception => e
ReplCompletion.handle_exception(e)
ReplTypeCompletor.handle_exception(e)
nil
ensure
$VERBOSE = verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
require 'set'
require_relative 'types'

module ReplCompletion

module ReplTypeCompletor
class RootScope
attr_reader :module_nesting, :self_object

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative 'scope'
require 'prism'

module ReplCompletion
module ReplTypeCompletor
class TypeAnalyzer
class DigTarget
def initialize(parents, receiver, &block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative 'methods'

module ReplCompletion
module ReplTypeCompletor
module Types
OBJECT_TO_TYPE_SAMPLE_SIZE = 50

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ReplCompletion
module ReplTypeCompletor
VERSION = "0.1.0"
end
6 changes: 3 additions & 3 deletions repl_completion.gemspec → repl_type_completor.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "lib/repl_completion/version"
require_relative "lib/repl_type_completor/version"

Gem::Specification.new do |spec|
spec.name = "repl_completion"
spec.version = ReplCompletion::VERSION
spec.name = "repl_type_completor"
spec.version = ReplTypeCompletor::VERSION
spec.authors = ["tompng"]
spec.email = ["[email protected]"]

Expand Down
2 changes: 1 addition & 1 deletion sig/repl_completion.rbs → sig/repl_type_completor.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ReplCompletion
module ReplTypeCompletor
VERSION: String

class Result
Expand Down
26 changes: 0 additions & 26 deletions test/repl_completion/test_require_paths.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'test/unit'
require 'core_assertions'

module TestReplCompletion
module TestReplTypeCompletor
class TestCase < Test::Unit::TestCase
include Test::Unit::CoreAssertions
end
Expand Down
Loading

0 comments on commit fcafc8f

Please sign in to comment.