mj 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c06a541585bad692ef35a285e3c64a38a336b90a4360cbd415a2da773cc3372
|
4
|
+
data.tar.gz: 58514059df9ea6588bc11f2927a54b66833d82342858da33059e4fde88481d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 027f603fc2bb78de14d6d40516db6db07d644db6cbd1bf4a2f207818c3e913199b10c7a8936e4446122c0efb767b8cac84d26a621cc6398ef77455dfe981bfcf
|
7
|
+
data.tar.gz: f3a4def6dee2cddbf1e0b7eb657c9f6103517e80da6cda4ca2a54f5476488b2ff8263ec86036fe95f5427927d5ffd6d445966ef59a0e14465e2fd2b07df73554
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
17
|
-
add_candidate("
|
18
|
-
add_candidate("
|
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)
|
19
|
-
|
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
|
-
|
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