mj 0.6.0 → 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: efbd2ad2b7959ec1add88daadd57eaf56787c7f1e3a0297b676500f644ce2bf5
4
- data.tar.gz: 9d3b3cfc72c599c70f76019093526870bafefc2063a08535cc58702b2e199828
3
+ metadata.gz: 2c06a541585bad692ef35a285e3c64a38a336b90a4360cbd415a2da773cc3372
4
+ data.tar.gz: 58514059df9ea6588bc11f2927a54b66833d82342858da33059e4fde88481d94
5
5
  SHA512:
6
- metadata.gz: afb390219762a7f89a6e67936b0b6dfdb447bc970bae132e02989c25491075ce2c0beb6bb6196c03c9fe3b2ac625d7c4c5d7ba744eb0556a851eba4117c7e50f
7
- data.tar.gz: af2332590c6cf8f828244e720e16f550c7ced67c7394087f3f9c85fe77fd06ec93c09a5163bcf978c8044d42e6996fbcad325b62f60cc68122c9b6e11a838098
6
+ metadata.gz: 027f603fc2bb78de14d6d40516db6db07d644db6cbd1bf4a2f207818c3e913199b10c7a8936e4446122c0efb767b8cac84d26a621cc6398ef77455dfe981bfcf
7
+ data.tar.gz: f3a4def6dee2cddbf1e0b7eb657c9f6103517e80da6cda4ca2a54f5476488b2ff8263ec86036fe95f5427927d5ffd6d445966ef59a0e14465e2fd2b07df73554
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.1)
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
 
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.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus