mj 0.5.4 → 0.6.1

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: 1c41690187e0bdc1673d0e3719ab6a01b7059459ec25a957228ac64435b72f6a
4
- data.tar.gz: 59b806a25685ef0661da12675bc098863c28e6b2b0d5c3ba6ae3bdf524de24b3
3
+ metadata.gz: 2c06a541585bad692ef35a285e3c64a38a336b90a4360cbd415a2da773cc3372
4
+ data.tar.gz: 58514059df9ea6588bc11f2927a54b66833d82342858da33059e4fde88481d94
5
5
  SHA512:
6
- metadata.gz: 81c3559bc183377f40f99af130be362d1d39d3d68451ecbabff3cb084496bfe51d4cff9111771a9fe3449d2a890ea060ed4ba3847d1cad9d9cb52f3189a4fa79
7
- data.tar.gz: 9a15946c97689290f26b32a89e06b0405384df0282d97b50766581ace012430c05ddddcf082892997658e100851bddbdb767dd0de58003e8176387aefac655ed
6
+ metadata.gz: 027f603fc2bb78de14d6d40516db6db07d644db6cbd1bf4a2f207818c3e913199b10c7a8936e4446122c0efb767b8cac84d26a621cc6398ef77455dfe981bfcf
7
+ data.tar.gz: f3a4def6dee2cddbf1e0b7eb657c9f6103517e80da6cda4ca2a54f5476488b2ff8263ec86036fe95f5427927d5ffd6d445966ef59a0e14465e2fd2b07df73554
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
@@ -7,6 +7,7 @@ gemspec
7
7
 
8
8
  gem "awesome_print"
9
9
  gem "koine-test_runner"
10
+ gem "pry", require: true
10
11
  gem "rake", "~> 13.0"
11
12
  gem "rspec", "~> 3.0"
12
13
  gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mj (0.5.4)
4
+ mj (0.6.1)
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.1)
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)
@@ -5,23 +5,34 @@ module Mj
5
5
  module Resolvers
6
6
  module Ruby
7
7
  class RailsResolver < Resolvers::Base
8
+ attr_reader :root
9
+
10
+ def initialize(root: nil)
11
+ if root
12
+ root = "#{root.chomp("/")}/"
13
+ end
14
+
15
+ @root = root
16
+ end
17
+
8
18
  private
9
19
 
10
20
  def apply_to?(file)
11
21
  file.extension == "rb"
12
22
  end
13
23
 
14
- def add_candidates(file, candidates)
15
- ruby_file = Ruby::RubyFile.new(file)
16
- add_candidate("app/#{ruby_file.class_path}.rb", :model, to: candidates)
17
- add_candidate("spec/#{ruby_file.class_path}_spec.rb", :spec, to: candidates)
18
- add_candidate("test/#{ruby_file.class_path}_test.rb", :minitest, to: candidates)
24
+ def add_candidates(file, candidates) # rubocop:disable Metrics/AbcSize
25
+ ruby_file = Ruby::RubyFile.new(file).without_prefix(root)
26
+
27
+ add_candidate("#{root}app/#{ruby_file.class_path}.rb", :model, to: candidates)
28
+ add_candidate("#{root}spec/#{ruby_file.class_path}_spec.rb", :spec, to: candidates)
29
+ add_candidate("#{root}test/#{ruby_file.class_path}_test.rb", :minitest, to: candidates)
19
30
 
20
31
  # lib files
21
- add_candidate("lib/#{ruby_file.class_path}.rb", "lib", to: candidates)
22
- add_candidate("#{ruby_file.class_path}.rb", "lib", to: candidates)
23
- add_candidate("spec/lib/#{ruby_file.class_path}_spec.rb", :spec, to: candidates)
24
- add_candidate("test/lib/#{ruby_file.class_path}_test.rb", :minitest, to: candidates)
32
+ add_candidate("#{root}lib/#{ruby_file.class_path}.rb", "lib", to: candidates)
33
+ add_candidate("#{root}#{ruby_file.class_path}.rb", "lib", to: candidates)
34
+ add_candidate("#{root}spec/lib/#{ruby_file.class_path}_spec.rb", :spec, to: candidates)
35
+ add_candidate("#{root}test/lib/#{ruby_file.class_path}_test.rb", :minitest, to: candidates)
25
36
  end
26
37
  end
27
38
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module AlternativeFile
5
+ module Resolvers
6
+ module Ruby
7
+ class VendoredGemsResolver < Resolvers::Base
8
+ private
9
+
10
+ def apply_to?(file)
11
+ file.extension == "rb" && find_root(file)
12
+ end
13
+
14
+ def add_candidates(file, candidates)
15
+ @rails = RailsResolver.new(root: find_root(file))
16
+
17
+ @rails.resolve(file).each do |resolved|
18
+ add_candidate(resolved, resolved.type, to: candidates)
19
+ end
20
+ end
21
+
22
+ def find_root(file)
23
+ root = nil
24
+
25
+ parts = file.to_s.split("/")
26
+ parts.each do |part|
27
+ root = [root, part].compact.join("/")
28
+
29
+ if Dir["#{root}/*.gemspec"].any?
30
+ return root
31
+ end
32
+ end
33
+
34
+ nil
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -10,6 +10,7 @@ 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
12
  require_relative "resolvers/ruby/packwerk_resolver"
13
+ require_relative "resolvers/ruby/vendored_gems_resolver"
13
14
  require_relative "resolvers/ruby/ruby_file"
14
15
  require_relative "commands/list_command_handler"
15
16
  require_relative "commands/list_command"
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.4"
4
+ VERSION = "0.6.1"
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.4
4
+ version: 0.6.1
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-09-06 00:00:00.000000000 Z
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"
@@ -56,6 +55,7 @@ files:
56
55
  - lib/mj/alternative_file/resolvers/ruby/rails_controller_resolver.rb
57
56
  - lib/mj/alternative_file/resolvers/ruby/rails_resolver.rb
58
57
  - lib/mj/alternative_file/resolvers/ruby/ruby_file.rb
58
+ - lib/mj/alternative_file/resolvers/ruby/vendored_gems_resolver.rb
59
59
  - lib/mj/alternative_file/resolvers/ruby/view_component_resolver.rb
60
60
  - lib/mj/alternative_file/thor_command.rb
61
61
  - lib/mj/cli.rb
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.2.33
89
+ rubygems_version: 3.4.10
90
90
  signing_key:
91
91
  specification_version: 4
92
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