mj 0.5.3 → 0.5.4

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: 683483a53bb0ecac42edc0a0f5f51e8cb14a2cd47af192caddfaf5b8317cdfd8
4
- data.tar.gz: eff84fc6a46cb4a000340ba32cadd1ab9edf84bdbb3c8b2d0745fe935ed8c025
3
+ metadata.gz: 1c41690187e0bdc1673d0e3719ab6a01b7059459ec25a957228ac64435b72f6a
4
+ data.tar.gz: 59b806a25685ef0661da12675bc098863c28e6b2b0d5c3ba6ae3bdf524de24b3
5
5
  SHA512:
6
- metadata.gz: c4e1b4dd41ebec30aabbc7ed605a9b0b0407a2803305e41f52c07a3e326b4111b186d07de57aba6d15843aa211f6a4c630fd591dd015c1a1e8d2577aee0a7540
7
- data.tar.gz: 93afecccc6e7ab89277acb49a444936bf37ffa2c54409556beeb107ac67f9d35c1e149ec6a0d026dbb4e844ce4278c69d21cb948ab565436118fae4b7305a4fd
6
+ metadata.gz: 81c3559bc183377f40f99af130be362d1d39d3d68451ecbabff3cb084496bfe51d4cff9111771a9fe3449d2a890ea060ed4ba3847d1cad9d9cb52f3189a4fa79
7
+ data.tar.gz: 9a15946c97689290f26b32a89e06b0405384df0282d97b50766581ace012430c05ddddcf082892997658e100851bddbdb767dd0de58003e8176387aefac655ed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mj (0.5.3)
4
+ mj (0.5.4)
5
5
  thor (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -24,6 +24,10 @@ module Mj
24
24
  other.path == path && other.type == type
25
25
  end
26
26
 
27
+ def inspect
28
+ "#{path}|#{type}"
29
+ end
30
+
27
31
  def to_s(debug: false)
28
32
  parts = [path]
29
33
 
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module AlternativeFile
5
+ module Resolvers
6
+ module Ruby
7
+ class PackwerkResolver < Resolvers::Base
8
+ def initialize
9
+ @rails = RailsResolver.new
10
+ end
11
+
12
+ private
13
+
14
+ def apply_to?(file)
15
+ file.extension == "rb" && file.start_with?(
16
+ "packages",
17
+ "spec",
18
+ "test"
19
+ )
20
+ end
21
+
22
+ def add_candidates(file, candidates) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
23
+ parts = file.split("/")
24
+ prefix = []
25
+ prefix.push(parts.shift)
26
+ prefix.push(parts.shift)
27
+
28
+ file = parts.join("/")
29
+ file = CurrentFile.new(file)
30
+
31
+ @rails.resolve(file).each do |resolved|
32
+ file = [prefix, resolved].flatten.join("/")
33
+ file = file.sub("/spec/public/", "/spec/")
34
+ file = file.sub("/test/public/", "/test/")
35
+ add_candidate(file, resolved.type, to: candidates)
36
+ end
37
+
38
+ add_public(candidates)
39
+ end
40
+
41
+ def add_public(candidates)
42
+ public_candidates = candidates.reject do |file|
43
+ file.type == :spec || file.type == :minitest
44
+ end
45
+
46
+ public_candidates.each do |candidate|
47
+ parts = candidate.path.split("/app/")
48
+ public_candidate = [parts[0], "/app/public/", parts[1]].compact.join
49
+ add_candidate(public_candidate, candidate.type, to: candidates)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -9,6 +9,7 @@ require_relative "resolvers/base"
9
9
  require_relative "resolvers/ruby/rails_resolver"
10
10
  require_relative "resolvers/ruby/rails_controller_resolver"
11
11
  require_relative "resolvers/ruby/view_component_resolver"
12
+ require_relative "resolvers/ruby/packwerk_resolver"
12
13
  require_relative "resolvers/ruby/ruby_file"
13
14
  require_relative "commands/list_command_handler"
14
15
  require_relative "commands/list_command"
@@ -56,6 +57,7 @@ module Mj
56
57
  resolvers.add(Resolvers::Ruby::RailsResolver.new)
57
58
  resolvers.add(Resolvers::Ruby::RailsControllerResolver.new)
58
59
  resolvers.add(Resolvers::Ruby::ViewComponentResolver.new)
60
+ resolvers.add(Resolvers::Ruby::PackwerkResolver.new)
59
61
  end
60
62
  end
61
63
 
data/lib/mj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mj
4
- VERSION = "0.5.3"
4
+ VERSION = "0.5.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-17 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -52,6 +52,7 @@ files:
52
52
  - lib/mj/alternative_file/current_file.rb
53
53
  - lib/mj/alternative_file/resolver.rb
54
54
  - lib/mj/alternative_file/resolvers/base.rb
55
+ - lib/mj/alternative_file/resolvers/ruby/packwerk_resolver.rb
55
56
  - lib/mj/alternative_file/resolvers/ruby/rails_controller_resolver.rb
56
57
  - lib/mj/alternative_file/resolvers/ruby/rails_resolver.rb
57
58
  - lib/mj/alternative_file/resolvers/ruby/ruby_file.rb