mj 0.5.1 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/mj/alternative_file/candidate.rb +4 -0
- data/lib/mj/alternative_file/resolvers/ruby/packwerk_resolver.rb +56 -0
- data/lib/mj/alternative_file/resolvers/ruby/rails_controller_resolver.rb +33 -1
- data/lib/mj/alternative_file/resolvers/ruby/rails_resolver.rb +1 -0
- data/lib/mj/alternative_file/resolvers/ruby/ruby_file.rb +2 -1
- data/lib/mj/alternative_file/thor_command.rb +2 -0
- data/lib/mj/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c41690187e0bdc1673d0e3719ab6a01b7059459ec25a957228ac64435b72f6a
|
4
|
+
data.tar.gz: 59b806a25685ef0661da12675bc098863c28e6b2b0d5c3ba6ae3bdf524de24b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c3559bc183377f40f99af130be362d1d39d3d68451ecbabff3cb084496bfe51d4cff9111771a9fe3449d2a890ea060ed4ba3847d1cad9d9cb52f3189a4fa79
|
7
|
+
data.tar.gz: 9a15946c97689290f26b32a89e06b0405384df0282d97b50766581ace012430c05ddddcf082892997658e100851bddbdb767dd0de58003e8176387aefac655ed
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -4,6 +4,7 @@ module Mj
|
|
4
4
|
module AlternativeFile
|
5
5
|
module Resolvers
|
6
6
|
module Ruby
|
7
|
+
# rubocop:disable Metrics/MethodLength
|
7
8
|
class RailsControllerResolver < Resolvers::Base
|
8
9
|
private
|
9
10
|
|
@@ -13,7 +14,11 @@ module Mj
|
|
13
14
|
"spec/integration",
|
14
15
|
"test/integration",
|
15
16
|
"test/controllers",
|
16
|
-
"spec/controllers"
|
17
|
+
"spec/controllers",
|
18
|
+
"spec/requests",
|
19
|
+
"test/requests",
|
20
|
+
"spec/system",
|
21
|
+
"test/system"
|
17
22
|
)
|
18
23
|
end
|
19
24
|
|
@@ -23,27 +28,53 @@ module Mj
|
|
23
28
|
add_controller_test(file, candidates, "test")
|
24
29
|
add_integration_test(file, candidates, "spec")
|
25
30
|
add_integration_test(file, candidates, "test")
|
31
|
+
add_request_test(file, candidates, "spec")
|
32
|
+
add_request_test(file, candidates, "test")
|
33
|
+
add_system_test(file, candidates, "spec")
|
34
|
+
add_system_test(file, candidates, "test")
|
26
35
|
return
|
27
36
|
end
|
28
37
|
|
29
38
|
resolve_controller(file, candidates)
|
30
39
|
end
|
40
|
+
# rubocop:enable Metrics/MethodLength
|
31
41
|
|
32
42
|
def add_integration_test(file, candidates, type)
|
33
43
|
path = file.without_prefix("app/controllers").without_suffix(".rb").trim_slashes
|
34
44
|
add_candidate("#{type}/integration/#{path}_#{type}.rb", "integration_#{type}", to: candidates)
|
35
45
|
end
|
36
46
|
|
47
|
+
def add_request_test(file, candidates, type)
|
48
|
+
path = file.without_prefix("app/controllers").sub("_controller", "").without_suffix(".rb").trim_slashes
|
49
|
+
add_candidate("#{type}/requests/#{path}_#{type}.rb", "request_#{type}", to: candidates)
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_system_test(file, candidates, type)
|
53
|
+
path = file.without_prefix("app/controllers").sub("_controller", "").without_suffix(".rb").trim_slashes
|
54
|
+
add_candidate("#{type}/system/#{path}_#{type}.rb", "system_#{type}", to: candidates)
|
55
|
+
end
|
56
|
+
|
37
57
|
def add_controller_test(file, candidates, type)
|
38
58
|
path = file.without_prefix("app/controllers").without_suffix(".rb").trim_slashes
|
39
59
|
add_candidate("#{type}/controllers/#{path}_#{type}.rb", "controller_#{type}", to: candidates)
|
40
60
|
end
|
41
61
|
|
62
|
+
# rubocop:disable Metrics/MethodLength
|
42
63
|
def resolve_controller(file, candidates)
|
64
|
+
# requests|system tests don't usually have "request_{type}.rb" suffix
|
65
|
+
if file.start_with?(%r{(test|spec)/(system|request)})
|
66
|
+
file = file.sub("_spec.rb", "_controller_spec.rb")
|
67
|
+
.sub("_test.rb", "_controller_test.rb")
|
68
|
+
end
|
69
|
+
|
43
70
|
controller_path = file.sub("test/integration", "app/controllers")
|
44
71
|
.sub("spec/integration", "app/controllers")
|
45
72
|
.sub("spec/controllers", "app/controllers")
|
46
73
|
.sub("test/controllers", "app/controllers")
|
74
|
+
.sub("test/requests", "app/controllers")
|
75
|
+
.sub("test/system", "app/controllers")
|
76
|
+
.sub("spec/requests", "app/controllers")
|
77
|
+
.sub("spec/system", "app/controllers")
|
47
78
|
.sub("_spec.rb", ".rb")
|
48
79
|
.sub("_test.rb", ".rb")
|
49
80
|
.to_s
|
@@ -51,6 +82,7 @@ module Mj
|
|
51
82
|
add_candidate(controller_path, "controller", to: candidates)
|
52
83
|
end
|
53
84
|
end
|
85
|
+
# rubocop:enable Metrics/MethodLength
|
54
86
|
end
|
55
87
|
end
|
56
88
|
end
|
@@ -19,6 +19,7 @@ module Mj
|
|
19
19
|
|
20
20
|
# lib files
|
21
21
|
add_candidate("lib/#{ruby_file.class_path}.rb", "lib", to: candidates)
|
22
|
+
add_candidate("#{ruby_file.class_path}.rb", "lib", to: candidates)
|
22
23
|
add_candidate("spec/lib/#{ruby_file.class_path}_spec.rb", :spec, to: candidates)
|
23
24
|
add_candidate("test/lib/#{ruby_file.class_path}_test.rb", :minitest, to: candidates)
|
24
25
|
end
|
@@ -7,9 +7,10 @@ module Mj
|
|
7
7
|
class RubyFile < AlternativeFile::CurrentFile
|
8
8
|
def class_path
|
9
9
|
path_without_extension
|
10
|
+
.without_prefix("spec")
|
11
|
+
.without_prefix("test")
|
10
12
|
.without_prefix("app")
|
11
13
|
.without_prefix("lib")
|
12
|
-
.without_prefix("spec")
|
13
14
|
.without_suffix("_spec")
|
14
15
|
.without_suffix("_test")
|
15
16
|
.trim_slashes
|
@@ -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
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.
|
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-
|
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
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
- !ruby/object:Gem::Version
|
86
87
|
version: '0'
|
87
88
|
requirements: []
|
88
|
-
rubygems_version: 3.2.
|
89
|
+
rubygems_version: 3.2.33
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
92
|
summary: My personal CLI
|