mj 0.6.0 → 0.6.2

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: efbd2ad2b7959ec1add88daadd57eaf56787c7f1e3a0297b676500f644ce2bf5
4
- data.tar.gz: 9d3b3cfc72c599c70f76019093526870bafefc2063a08535cc58702b2e199828
3
+ metadata.gz: 4f73fffd1a785c75120ffed30d970ffbc9d64f525a5a5729c814a785f7c0868e
4
+ data.tar.gz: 8a09ecd20bb4bae4e54f07d30f09c9fa534b4d2c6090d87353c3297cb1bb2210
5
5
  SHA512:
6
- metadata.gz: afb390219762a7f89a6e67936b0b6dfdb447bc970bae132e02989c25491075ce2c0beb6bb6196c03c9fe3b2ac625d7c4c5d7ba744eb0556a851eba4117c7e50f
7
- data.tar.gz: af2332590c6cf8f828244e720e16f550c7ced67c7394087f3f9c85fe77fd06ec93c09a5163bcf978c8044d42e6996fbcad325b62f60cc68122c9b6e11a838098
6
+ metadata.gz: 90f2712ab6a67d83f45ce62f4a4213e0b85404ead8f218263771095ef09121dcaf29732e81a17e459be7d2788bb836f172ec34bb6d90e3e697f49599075378eb
7
+ data.tar.gz: d05317d65dd3fb88eb5379f3e0e4439a2264c5b40d6a2276fec219058668748f852ea4474468fc7a56f527357ea5b8808d15a541bbb9558203ca6602edaec50e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mj (0.6.0)
4
+ mj (0.6.2)
5
5
  thor (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -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
@@ -5,33 +5,17 @@ module Mj
5
5
  module Resolvers
6
6
  module Ruby
7
7
  class VendoredGemsResolver < Resolvers::Base
8
- def initialize
9
- @rails = RailsResolver.new
10
- end
11
-
12
8
  private
13
9
 
14
10
  def apply_to?(file)
15
11
  file.extension == "rb" && find_root(file)
16
12
  end
17
13
 
18
- def add_candidates(file, candidates) # rubocop:disable Metrics/MethodLength
19
- root = find_root(file)
14
+ def add_candidates(file, candidates)
15
+ @rails = RailsResolver.new(root: find_root(file))
20
16
 
21
17
  @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)
18
+ add_candidate(resolved, resolved.type, to: candidates)
35
19
  end
36
20
  end
37
21
 
@@ -59,6 +59,7 @@ module Mj
59
59
  resolvers.add(Resolvers::Ruby::RailsControllerResolver.new)
60
60
  resolvers.add(Resolvers::Ruby::ViewComponentResolver.new)
61
61
  resolvers.add(Resolvers::Ruby::PackwerkResolver.new)
62
+ resolvers.add(Resolvers::Ruby::VendoredGemsResolver.new)
62
63
  end
63
64
  end
64
65
 
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.6.0"
4
+ VERSION = "0.6.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus