ruby-lsp-rails 0.3.15 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8864e641f204eaafb608b703228bd98d5a2234413f48ee1d1232f277b7385144
4
- data.tar.gz: 3db424bb7e32fbd1a1dce231d56b9d98d92e23b0c9ef70f56cbab86b878f9133
3
+ metadata.gz: bab18094b00d6c5e6a61b22061f927fbca1f4b57ce40da04eca22081ab264385
4
+ data.tar.gz: 7a253986008708cb5d5af08b6409039aeba2b54d0d605270f652fba9178a99ac
5
5
  SHA512:
6
- metadata.gz: 3820483222f6b082c3f939e9b797a71e775776fd3e5a3d9422a99ab1c3af992dce883a69781cf4b2a07e8492c87e3054a351df4f22c398fd12cb20c6a4472ff8
7
- data.tar.gz: 72e7715cefc65926b7d8011933e0152f90ee896b6530cea5edec0b41c70be701ae55619ea9c73dbb60e4becaf73df9f48ce122448ab2f6688204eda1d85edfb8
6
+ metadata.gz: b5021b0f2dadbb18464e473f26d9bfee94ed22b02b53eec5c1c44ade37f1ab989c0b80c4169f722ca4e38c498344ccd5e19334324508aac8f6d3c0e21bd6ec35
7
+ data.tar.gz: 26813fab8da91e99d6f708dadc1ef631df0d1791addb608e06a366bfebcac5643c5d0978d0bc0778d76c3d74572a78a0a8b361fba90f373db759b54a81f9a388
data/README.md CHANGED
@@ -1,35 +1,20 @@
1
1
  [![Ruby DX Slack](https://img.shields.io/badge/Slack-Ruby%20DX-success?logo=slack)](https://join.slack.com/t/ruby-dx/shared_invite/zt-2c8zjlir6-uUDJl8oIwcen_FS_aA~b6Q)
2
2
 
3
- # Ruby LSP Rails
3
+ # Rails addon
4
4
 
5
- Ruby LSP Rails is a [Ruby LSP](https://github.com/Shopify/ruby-lsp) addon for extra [Rails editor features](https://shopify.github.io/ruby-lsp-rails/FEATURES_md.html).
5
+ The Rails addon is a [Ruby LSP](https://github.com/Shopify/ruby-lsp) [addon](https://shopify.github.io/ruby-lsp/addons.html) for extra [Rails editor features](https://shopify.github.io/ruby-lsp/rails-addon.html).
6
6
 
7
7
  ## Installation
8
8
 
9
- If you haven't already done so, you'll need to first [set up Ruby LSP](https://github.com/Shopify/ruby-lsp#usage).
9
+ If you haven't already done so, you'll need to first [set up Ruby LSP](https://shopify.github.io/ruby-lsp/#usage).
10
10
 
11
11
  As of v0.3.0, Ruby LSP will automatically include the Ruby LSP Rails addon in its custom bundle when a Rails app is detected.
12
12
  There is no need to add the gem to your bundle.
13
13
 
14
14
  ## Documentation
15
15
 
16
- See the [documentation](https://shopify.github.io/ruby-lsp-rails) for more in-depth details about the
17
- [supported features](https://shopify.github.io/ruby-lsp-rails/FEATURES_md.html).
18
-
19
- ## How Runtime Introspection Works
20
-
21
- LSP tooling is typically based on static analysis, but `ruby-lsp-rails` actually communicates with your Rails app for
22
- some features.
23
-
24
- When Ruby LSP Rails starts, it spawns a `rails runner` instance which runs
25
- [`server.rb`](https://github.com/Shopify/ruby-lsp-rails/blob/main/lib/ruby_lsp/ruby_lsp_rails/server.rb).
26
- The addon communicates with this process over a pipe (i.e. `stdin` and `stdout`) to fetch runtime information about the application.
27
-
28
- When extension is stopped (e.g. by quitting the editor), the server instance is shut down.
29
-
30
- > [!NOTE]
31
- > Prior to v0.3.0, `ruby-lsp-rails` used a different approach which involved mounting a Rack application within the Rails app.
32
- > That approach was brittle and susceptible to the application's configuration, such as routing and middleware.
16
+ See the [documentation](https://shopify.github.io/ruby-lsp/rails-addon.html) for more in-depth details about the
17
+ [supported features](https://shopify.github.io/ruby-lsp/rails-addon.html#features).
33
18
 
34
19
  ## Contributing
35
20
 
data/Rakefile CHANGED
@@ -9,8 +9,6 @@ load "rails/tasks/statistics.rake"
9
9
 
10
10
  require "bundler/gem_tasks"
11
11
  require "rake/testtask"
12
- require "ruby_lsp/check_docs"
13
- require "rdoc/task"
14
12
 
15
13
  Rake::TestTask.new(:test) do |t|
16
14
  t.libs << "test"
@@ -18,17 +16,4 @@ Rake::TestTask.new(:test) do |t|
18
16
  t.test_files = FileList["test/**/*_test.rb"]
19
17
  end
20
18
 
21
- RDoc::Task.new do |rdoc|
22
- rdoc.main = "README.md"
23
- rdoc.rdoc_files.include("*.md", "lib/**/*.rb")
24
- rdoc.rdoc_dir = "docs"
25
- rdoc.markup = "markdown"
26
- rdoc.title = "Ruby LSP Rails"
27
- rdoc.generator = "snapper"
28
- rdoc.options.push("--copy-files", "misc")
29
- rdoc.options.push("--copy-files", "LICENSE.txt")
30
- end
31
-
32
- RubyLsp::CheckDocs.new(FileList["#{__dir__}/lib/ruby_lsp/**/*.rb"], FileList["#{__dir__}/misc/**/*.gif"])
33
-
34
19
  task default: [:"db:setup", :test]
@@ -59,7 +59,7 @@ module RubyLsp
59
59
  file_path,
60
60
  name_arg.location,
61
61
  name_arg.location,
62
- [],
62
+ nil,
63
63
  [RubyIndexer::Entry::Signature.new([])],
64
64
  RubyIndexer::Entry::Visibility::PUBLIC,
65
65
  owner,
@@ -71,7 +71,7 @@ module RubyLsp
71
71
  file_path,
72
72
  name_arg.location,
73
73
  name_arg.location,
74
- [],
74
+ nil,
75
75
  [RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: name.to_sym)])],
76
76
  RubyIndexer::Entry::Visibility::PUBLIC,
77
77
  owner,
@@ -9,12 +9,10 @@ require "json"
9
9
  module RubyLsp
10
10
  module Rails
11
11
  class Server
12
- VOID = Object.new
13
-
14
- def initialize
12
+ def initialize(stdout: $stdout, override_default_output_device: true)
15
13
  # Grab references to the original pipes so that we can change the default output device further down
16
14
  @stdin = $stdin
17
- @stdout = $stdout
15
+ @stdout = stdout
18
16
  @stderr = $stderr
19
17
  @stdin.sync = true
20
18
  @stdout.sync = true
@@ -26,7 +24,7 @@ module RubyLsp
26
24
  # # Set the default output device to be $stderr. This means that using `puts` by itself will default to printing
27
25
  # # to $stderr and only explicit `$stdout.puts` will go to $stdout. This reduces the chance that output coming
28
26
  # # from the Rails app will be accidentally sent to the client
29
- $> = $stderr
27
+ $> = $stderr if override_default_output_device
30
28
 
31
29
  @running = true
32
30
  end
@@ -44,11 +42,7 @@ module RubyLsp
44
42
  json = @stdin.read(headers[/Content-Length: (\d+)/i, 1].to_i)
45
43
 
46
44
  request = JSON.parse(json, symbolize_names: true)
47
- response = execute(request.fetch(:method), request[:params])
48
- next if response == VOID
49
-
50
- json_response = response.to_json
51
- @stdout.write("Content-Length: #{json_response.length}\r\n\r\n#{json_response}")
45
+ execute(request.fetch(:method), request[:params])
52
46
  end
53
47
  end
54
48
 
@@ -56,27 +50,28 @@ module RubyLsp
56
50
  case request
57
51
  when "shutdown"
58
52
  @running = false
59
- VOID
60
53
  when "model"
61
- resolve_database_info_from_model(params.fetch(:name))
54
+ write_response(resolve_database_info_from_model(params.fetch(:name)))
62
55
  when "association_target_location"
63
- resolve_association_target(params)
56
+ write_response(resolve_association_target(params))
64
57
  when "reload"
65
58
  ::Rails.application.reloader.reload!
66
- VOID
67
59
  when "route_location"
68
- route_location(params.fetch(:name))
60
+ write_response(route_location(params.fetch(:name)))
69
61
  when "route_info"
70
- resolve_route_info(params)
71
- else
72
- VOID
62
+ write_response(resolve_route_info(params))
73
63
  end
74
64
  rescue => e
75
- { error: e.full_message(highlight: false) }
65
+ write_response({ error: e.full_message(highlight: false) })
76
66
  end
77
67
 
78
68
  private
79
69
 
70
+ def write_response(response)
71
+ json_response = response.to_json
72
+ @stdout.write("Content-Length: #{json_response.length}\r\n\r\n#{json_response}")
73
+ end
74
+
80
75
  def resolve_route_info(requirements)
81
76
  if requirements[:controller]
82
77
  requirements[:controller] = requirements.fetch(:controller).underscore.delete_suffix("_controller")
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Rails
6
- VERSION = "0.3.15"
6
+ VERSION = "0.3.16"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-16 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lsp
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.17.12
19
+ version: 0.18.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 0.18.0
22
+ version: 0.19.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.17.12
29
+ version: 0.18.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.18.0
32
+ version: 0.19.0
33
33
  description: A Ruby LSP addon that adds extra editor functionality for Rails applications
34
34
  email:
35
35
  - ruby@shopify.com
@@ -65,6 +65,7 @@ metadata:
65
65
  homepage_uri: https://github.com/Shopify/ruby-lsp-rails
66
66
  source_code_uri: https://github.com/Shopify/ruby-lsp-rails
67
67
  changelog_uri: https://github.com/Shopify/ruby-lsp-rails/releases
68
+ documentation_uri: https://shopify.github.io/ruby-lsp/rails-addon.html
68
69
  post_install_message:
69
70
  rdoc_options: []
70
71
  require_paths: