ruby-lsp-shoulda-context 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef2bd21652b42fa017e458daa37597860937f8672d23f2deebf021a2530d5b34
4
- data.tar.gz: 7cecc4559f69900a160f7649532b9d38696f70a0b29bc9ccc89edd3917d4a459
3
+ metadata.gz: 707fc43599111261ba56d4ebaee196e3564af183ef2d4ef17def9950690f87a7
4
+ data.tar.gz: e73bb4abaaa173b3330c43778d5f50170283482b39012115c49cdaf4e7fb0d0e
5
5
  SHA512:
6
- metadata.gz: 3fdd797ef37150b665104c90861fd78f1ddc525face38977876acd3edc50d7b5f4f345846b7f6df810d472d56538a307fc1928d3d96b8facda64c8df7cddbddc
7
- data.tar.gz: 5486b8f7f137177809cfa9424dfc08909c82320835df82f01b5b23e97732dbad03a5d789c4f72c1e80cca600f9bee6cdd71df68e57cd74122873cc6d10d49bbb
6
+ metadata.gz: a753433c5fa49613c9e8b4448b0024fce918585d24409fec7b0a549b9f14904cdd1c9fa24142fd7ca398c4fcbc615f662f63a8aa70cf49706cb1574a93973905
7
+ data.tar.gz: 01c139a9464613fae85b0b1d9852449ff3a59643cb0002d86490625f4a444942b5497ad6edd46f082fb754daafef04a25a43e31c4d3159b2450c0b4d5bad97d8
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## [Unreleased]
2
+ ## [0.4.3] - 2024-05-27
3
+ - Add `dotenv` as a runtime dependency to the gemspec
2
4
  ## [0.4.0] - 2024-02-10
3
5
  - Added support to ruby on rails
4
6
  - Fixed Class Run on terminal whith wrong pattern
data/Readme.md CHANGED
@@ -9,7 +9,7 @@ This gem provides support for [shoulda-context](https://github.com/thoughtbot/sh
9
9
 
10
10
  Add the gem to the application's Gemfile `:development` group:
11
11
 
12
- gem 'ruby-lsp-shoulda-context', '~> 0.4.0', require: false
12
+ gem 'ruby-lsp-shoulda-context', '~> 0.4.2', require: false
13
13
 
14
14
  If bundler is not being used to manage dependencies, install the gem by executing:
15
15
 
@@ -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.3"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,35 +1,55 @@
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.3
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-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ruby-lsp
14
+ name: dotenv
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: '3.0'
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.14.0
22
+ version: 3.0.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
27
30
  - - ">="
28
31
  - !ruby/object:Gem::Version
29
- version: 0.13.0
30
- - - "<"
32
+ version: 3.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: ruby-lsp
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.16.6
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.16.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.16.6
50
+ - - ">="
31
51
  - !ruby/object:Gem::Version
32
- version: 0.14.0
52
+ version: 0.16.0
33
53
  description: An addon for the Ruby LSP that enables shoulda-context testing
34
54
  email:
35
55
  - domingo.edwards@uc.cl
@@ -72,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
92
  - !ruby/object:Gem::Version
73
93
  version: '0'
74
94
  requirements: []
75
- rubygems_version: 3.5.6
95
+ rubygems_version: 3.4.10
76
96
  signing_key:
77
97
  specification_version: 4
78
98
  summary: Ruby LSP shoulda-context