mj 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -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/vendored_gems_resolver.rb +56 -0
- data/lib/mj/alternative_file/thor_command.rb +3 -0
- data/lib/mj/version.rb +1 -1
- metadata +5 -4
- data/.project.vim +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbd2ad2b7959ec1add88daadd57eaf56787c7f1e3a0297b676500f644ce2bf5
|
4
|
+
data.tar.gz: 9d3b3cfc72c599c70f76019093526870bafefc2063a08535cc58702b2e199828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb390219762a7f89a6e67936b0b6dfdb447bc970bae132e02989c25491075ce2c0beb6bb6196c03c9fe3b2ac625d7c4c5d7ba744eb0556a851eba4117c7e50f
|
7
|
+
data.tar.gz: af2332590c6cf8f828244e720e16f550c7ced67c7394087f3f9c85fe77fd06ec93c09a5163bcf978c8044d42e6996fbcad325b62f60cc68122c9b6e11a838098
|
data/.rubocop.yml
CHANGED
@@ -27,7 +27,7 @@ Layout/FirstArrayElementIndentation:
|
|
27
27
|
|
28
28
|
Layout/LineLength:
|
29
29
|
Max: 120
|
30
|
-
|
30
|
+
|
31
31
|
Layout/MultilineMethodCallIndentation:
|
32
32
|
EnforcedStyle: indented
|
33
33
|
|
@@ -87,10 +87,12 @@ RSpec/ExpectChange:
|
|
87
87
|
RSpec/MultipleExpectations:
|
88
88
|
Enabled: false
|
89
89
|
|
90
|
+
RSpec/MultipleMemoizedHelpers:
|
91
|
+
Enabled: false
|
92
|
+
|
90
93
|
RSpec/NestedGroups:
|
91
94
|
Max: 4
|
92
95
|
|
93
96
|
# while that is a good rule, AR objects can't be properly instance_double'd
|
94
97
|
RSpec/VerifiedDoubles:
|
95
98
|
Enabled: false
|
96
|
-
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mj (0.
|
4
|
+
mj (0.6.0)
|
5
5
|
thor (~> 1.2.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,12 +9,17 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
awesome_print (1.9.2)
|
12
|
+
coderay (1.1.3)
|
12
13
|
diff-lcs (1.5.0)
|
13
14
|
docile (1.4.0)
|
14
15
|
koine-test_runner (0.4.0)
|
16
|
+
method_source (1.0.0)
|
15
17
|
parallel (1.21.0)
|
16
18
|
parser (3.1.1.0)
|
17
19
|
ast (~> 2.4.1)
|
20
|
+
pry (0.14.2)
|
21
|
+
coderay (~> 1.1)
|
22
|
+
method_source (~> 1.0)
|
18
23
|
rainbow (3.1.1)
|
19
24
|
rake (13.0.6)
|
20
25
|
regexp_parser (2.2.1)
|
@@ -58,7 +63,7 @@ GEM
|
|
58
63
|
simplecov-html (0.12.3)
|
59
64
|
simplecov-lcov (0.8.0)
|
60
65
|
simplecov_json_formatter (0.1.4)
|
61
|
-
thor (1.2.
|
66
|
+
thor (1.2.2)
|
62
67
|
unicode-display_width (2.1.0)
|
63
68
|
|
64
69
|
PLATFORMS
|
@@ -68,6 +73,7 @@ DEPENDENCIES
|
|
68
73
|
awesome_print
|
69
74
|
koine-test_runner
|
70
75
|
mj!
|
76
|
+
pry
|
71
77
|
rake (~> 13.0)
|
72
78
|
rspec (~> 3.0)
|
73
79
|
rubocop (~> 1.21)
|
@@ -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
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mj
|
4
|
+
module AlternativeFile
|
5
|
+
module Resolvers
|
6
|
+
module Ruby
|
7
|
+
class VendoredGemsResolver < Resolvers::Base
|
8
|
+
def initialize
|
9
|
+
@rails = RailsResolver.new
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def apply_to?(file)
|
15
|
+
file.extension == "rb" && find_root(file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_candidates(file, candidates) # rubocop:disable Metrics/MethodLength
|
19
|
+
root = find_root(file)
|
20
|
+
|
21
|
+
@rails.resolve(file).each do |resolved|
|
22
|
+
found = resolved.to_s.sub("#{root}/app/", "")
|
23
|
+
found = found.sub("#{root}/", "")
|
24
|
+
|
25
|
+
unless found.match?("_spec.rb")
|
26
|
+
found = found.sub("spec/", "")
|
27
|
+
end
|
28
|
+
|
29
|
+
unless found.match?("_test.rb")
|
30
|
+
found = found.sub("test/", "")
|
31
|
+
end
|
32
|
+
|
33
|
+
file = [root, found].flatten.join("/")
|
34
|
+
add_candidate(file, resolved.type, to: candidates)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_root(file)
|
39
|
+
root = nil
|
40
|
+
|
41
|
+
parts = file.to_s.split("/")
|
42
|
+
parts.each do |part|
|
43
|
+
root = [root, part].compact.join("/")
|
44
|
+
|
45
|
+
if Dir["#{root}/*.gemspec"].any?
|
46
|
+
return root
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -9,6 +9,8 @@ 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"
|
13
|
+
require_relative "resolvers/ruby/vendored_gems_resolver"
|
12
14
|
require_relative "resolvers/ruby/ruby_file"
|
13
15
|
require_relative "commands/list_command_handler"
|
14
16
|
require_relative "commands/list_command"
|
@@ -56,6 +58,7 @@ module Mj
|
|
56
58
|
resolvers.add(Resolvers::Ruby::RailsResolver.new)
|
57
59
|
resolvers.add(Resolvers::Ruby::RailsControllerResolver.new)
|
58
60
|
resolvers.add(Resolvers::Ruby::ViewComponentResolver.new)
|
61
|
+
resolvers.add(Resolvers::Ruby::PackwerkResolver.new)
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -32,7 +32,6 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- ".project.vim"
|
36
35
|
- ".rspec"
|
37
36
|
- ".rubocop.yml"
|
38
37
|
- ".test_runner.yml"
|
@@ -52,9 +51,11 @@ files:
|
|
52
51
|
- lib/mj/alternative_file/current_file.rb
|
53
52
|
- lib/mj/alternative_file/resolver.rb
|
54
53
|
- lib/mj/alternative_file/resolvers/base.rb
|
54
|
+
- lib/mj/alternative_file/resolvers/ruby/packwerk_resolver.rb
|
55
55
|
- lib/mj/alternative_file/resolvers/ruby/rails_controller_resolver.rb
|
56
56
|
- lib/mj/alternative_file/resolvers/ruby/rails_resolver.rb
|
57
57
|
- lib/mj/alternative_file/resolvers/ruby/ruby_file.rb
|
58
|
+
- lib/mj/alternative_file/resolvers/ruby/vendored_gems_resolver.rb
|
58
59
|
- lib/mj/alternative_file/resolvers/ruby/view_component_resolver.rb
|
59
60
|
- lib/mj/alternative_file/thor_command.rb
|
60
61
|
- lib/mj/cli.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.
|
89
|
+
rubygems_version: 3.4.10
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
92
|
summary: My personal CLI
|
data/.project.vim
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
autocmd FileType ruby nnoremap <buffer> <leader>T <esc>:call RunTestFile()<cr>
|
2
|
-
autocmd FileType ruby nnoremap <buffer> <leader>t <esc>:call RunTestFileFilteredByLine()<cr>
|
3
|
-
autocmd FileType ruby nnoremap <buffer> <leader>at <esc>:call RunAllTests()<cr>
|
4
|
-
function! RubocopFixCs(target)
|
5
|
-
let options=''
|
6
|
-
let cmd = 'bundle exec rubocop'
|
7
|
-
|
8
|
-
if filereadable('./bin/bundle')
|
9
|
-
let cmd = './bin/bundle exec rubocop'
|
10
|
-
endif
|
11
|
-
|
12
|
-
if filereadable('.rubocop.yml')
|
13
|
-
let options = ' --config=.rubocop.yml '
|
14
|
-
endif
|
15
|
-
|
16
|
-
let full_command = cmd . " -A " . options . a:target
|
17
|
-
call ClearEchoAndExecute(full_command)
|
18
|
-
endfunction
|
19
|
-
|
20
|
-
function! RunTestFileFilteredByLine()
|
21
|
-
let command = "bundle exec run_test " . expand('%') . " --line=" . line(".")
|
22
|
-
call ClearEchoAndExecute(command)
|
23
|
-
endfunction
|
24
|
-
|
25
|
-
function! RunTestFile()
|
26
|
-
let command = "bundle exec run_test " . expand('%')
|
27
|
-
call ClearEchoAndExecute(command)
|
28
|
-
endfunction
|
29
|
-
|
30
|
-
function! RunAllTests()
|
31
|
-
let command = "bundle exec run_test " . expand('%') . " --all"
|
32
|
-
call ClearEchoAndExecute(command)
|
33
|
-
endfunction
|