ruby-lsp-shoulda-context 0.4.1 → 0.4.2

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: ef2bd21652b42fa017e458daa37597860937f8672d23f2deebf021a2530d5b34
4
- data.tar.gz: 7cecc4559f69900a160f7649532b9d38696f70a0b29bc9ccc89edd3917d4a459
3
+ metadata.gz: 567715719f531b65148d1045d77587e2541367cff87d1725f637d89a3044d850
4
+ data.tar.gz: 6961db9e727610bb2290389de35892142e5f9d3c8828fa02f077d7de6f48176e
5
5
  SHA512:
6
- metadata.gz: 3fdd797ef37150b665104c90861fd78f1ddc525face38977876acd3edc50d7b5f4f345846b7f6df810d472d56538a307fc1928d3d96b8facda64c8df7cddbddc
7
- data.tar.gz: 5486b8f7f137177809cfa9424dfc08909c82320835df82f01b5b23e97732dbad03a5d789c4f72c1e80cca600f9bee6cdd71df68e57cd74122873cc6d10d49bbb
6
+ metadata.gz: 44194a81d42a9bdfa82ad4afca221d2449ad06bb9521b23cea37a8c832baa1ed11fe8ec7f46998b85f15644852c5d55b325a3c291f20d3535fc3692300bee581
7
+ data.tar.gz: 78b0f20fa728fadab0bb716dea23c6e91d0788f67c34f1b43bd72b45c2c1ed2b1b68820f47fdaf716b93e227ddd02f2c47635f365259246d12f24a2a07587700
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.2.2
data/Readme.md CHANGED
@@ -19,6 +19,12 @@ If bundler is not being used to manage dependencies, install the gem by executin
19
19
 
20
20
  Just enjoy the magic of LSP with shoulda context tests!.
21
21
 
22
+ The extension can be enabled or disabled passing the `RUBY_LSP_SHOULDA_CONTEXT=[true|false]` enviroment variable. This enviroment variable is loaded automatially from in a `.env` file with priority
23
+
24
+ `.env > .env.development > .env.development.local`
25
+
26
+ If not set it defaults to `true`
27
+
22
28
  ## Development
23
29
 
24
30
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -9,13 +9,13 @@ require_relative "code_lens"
9
9
 
10
10
  module RubyLsp
11
11
  module ShouldaContext
12
- # frozen_string_literal: true
13
-
14
12
  class Addon < ::RubyLsp::Addon
15
13
  extend T::Sig
16
14
 
17
- sig { override.params(message_queue: Thread::Queue).void }
18
- def activate(message_queue)
15
+ sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
16
+ def activate(global_state, message_queue)
17
+ @message_queue = message_queue
18
+ @global_state = global_state
19
19
  Dotenv.load(".env.development.local", ".env.development")
20
20
  end
21
21
 
@@ -27,17 +27,8 @@ module RubyLsp
27
27
  "Ruby LSP My Gem"
28
28
  end
29
29
 
30
- # Creates a new CodeLens listener. This method is invoked on every CodeLens request
31
- sig do
32
- override.params(
33
- uri: URI::Generic,
34
- emitter: Prism::Dispatcher,
35
- ).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
36
- end
37
- def create_code_lens_listener(uri, emitter)
38
- return unless uri.to_standardized_path&.end_with?("_test.rb") || uri.to_standardized_path&.end_with?("_spec.rb")
39
-
40
- CodeLens.new(uri, emitter)
30
+ def create_code_lens_listener(response_builder, uri, dispatcher)
31
+ CodeLens.new(response_builder, uri, dispatcher, @global_state)
41
32
  end
42
33
  end
43
34
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module ShouldaContext
6
- class CodeLens < ::RubyLsp::Listener
6
+ class CodeLens
7
7
  extend T::Sig
8
8
  extend T::Generic
9
9
 
@@ -27,11 +27,19 @@ module RubyLsp
27
27
  sig { override.returns(ResponseType) }
28
28
  attr_reader :_response
29
29
 
30
- sig { params(uri: URI::Generic, dispatcher: Prism::Dispatcher).void }
31
- def initialize(uri, dispatcher)
30
+ sig do
31
+ params(
32
+ response_builder: RubyLsp::ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
33
+ uri: URI::Generic,
34
+ dispatcher: Prism::Dispatcher,
35
+ global_state: RubyLsp::GlobalState,
36
+ ).void
37
+ end
38
+ def initialize(response_builder, uri, dispatcher, global_state)
39
+ @response_builder = response_builder
40
+ @global_state = global_state
32
41
  return if ENV["RUBY_LSP_SHOULDA_CONTEXT"] == "false"
33
42
 
34
- @_response = T.let([], ResponseType)
35
43
  # Listener is only initialized if uri.to_standardized_path is valid
36
44
  @path = T.let(T.must(uri.to_standardized_path), String)
37
45
  @class_name = T.let("", String)
@@ -41,8 +49,6 @@ module RubyLsp
41
49
  dispatcher.register(self, :on_call_node_enter, :on_call_node_leave, :on_class_node_enter, :on_class_node_leave)
42
50
 
43
51
  @base_command = BASE_COMMAND
44
-
45
- super(dispatcher)
46
52
  end
47
53
 
48
54
  sig { params(node: Prism::CallNode).void }
@@ -148,7 +154,7 @@ module RubyLsp
148
154
 
149
155
  sig { params(node: Prism::Node, name: String, kind: Symbol).void }
150
156
  def add_test_code_lens(node, name:, kind:)
151
- return unless DependencyDetector.instance.dependencies.include?(REQUIRED_LIBRARY)
157
+ return unless are_required_libraries_installed?
152
158
 
153
159
  if kind == :class
154
160
  pattern = "#{@class_name}Test"
@@ -173,7 +179,7 @@ module RubyLsp
173
179
  },
174
180
  ]
175
181
 
176
- @_response << create_code_lens(
182
+ @response_builder << create_code_lens(
177
183
  node,
178
184
  title: "Run",
179
185
  command_name: "rubyLsp.runTest",
@@ -181,7 +187,7 @@ module RubyLsp
181
187
  data: { type: "test", **grouping_data },
182
188
  )
183
189
 
184
- @_response << create_code_lens(
190
+ @response_builder << create_code_lens(
185
191
  node,
186
192
  title: "Run In Terminal",
187
193
  command_name: "rubyLsp.runTestInTerminal",
@@ -189,7 +195,7 @@ module RubyLsp
189
195
  data: { type: "test_in_terminal", **grouping_data },
190
196
  )
191
197
 
192
- @_response << create_code_lens(
198
+ @response_builder << create_code_lens(
193
199
  node,
194
200
  title: "Debug",
195
201
  command_name: "rubyLsp.debugTest",
@@ -197,6 +203,10 @@ module RubyLsp
197
203
  data: { type: "debug", **grouping_data },
198
204
  )
199
205
  end
206
+
207
+ def are_required_libraries_installed?
208
+ Bundler.locked_gems.dependencies.keys.include?(REQUIRED_LIBRARY)
209
+ end
200
210
  end
201
211
  end
202
212
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module ShouldaContext
6
- VERSION = "0.4.1"
6
+ VERSION = "0.4.2"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-shoulda-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domingo Edwards
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lsp
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.0
20
- - - "<"
19
+ version: 0.16.6
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.14.0
22
+ version: 0.16.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.13.0
30
- - - "<"
29
+ version: 0.16.6
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.14.0
32
+ version: 0.16.0
33
33
  description: An addon for the Ruby LSP that enables shoulda-context testing
34
34
  email:
35
35
  - domingo.edwards@uc.cl
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.5.6
75
+ rubygems_version: 3.4.10
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Ruby LSP shoulda-context