dotfiled 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dotfiled/alternative_file/finder.rb +27 -2
- data/lib/dotfiled/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72453b5dfcdb50ef78f14b550138c4cc141246501f60c685a8621d61c5e045bf
|
4
|
+
data.tar.gz: 8f85ef93a747cea06a9a8a696f1f5f08f9a762d393ecb8b9e902f9381fa99f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dac86b81a6fd4959b2423a070e0e8bea5f3d36d4960c6b3acb2d5b2e51ba06942e9e8a2bc347f634940295a2ef41c52b9bf082309ca7436fc5bb0ebd1025766
|
7
|
+
data.tar.gz: 4fca5fc5a1b15329ff83e7a9227f6b080a3b3b1f7164748bf68799ea76a155c3a4588db53b72fea5fd2265519b2c1d03105e9544cf0174c344e7bbe07042a1f0
|
@@ -19,6 +19,7 @@ module Dotfiled
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
+
# rubocop:disable Metrics/CyclomaticComplexity:
|
22
23
|
def find_ruby_test_file_for(file, prefix: File.new)
|
23
24
|
if file.match?(/^packages/)
|
24
25
|
return find_packaged_test_file_for(file)
|
@@ -34,8 +35,19 @@ module Dotfiled
|
|
34
35
|
rspec_folder = prefix.join("spec")
|
35
36
|
rspec = rspec_folder.join(file).sub(/(lib|app)/, "").sub(".rb", "_spec.rb")
|
36
37
|
|
38
|
+
candidates = [rspec, minitest]
|
39
|
+
|
40
|
+
if file.match?("controllers/")
|
41
|
+
candidate = file
|
42
|
+
.sub("app/controllers", "spec/requests")
|
43
|
+
.sub("controller.rb", "request_spec.rb")
|
44
|
+
|
45
|
+
candidates << candidate
|
46
|
+
candidates << candidate.sub(%r{^spec/}, "test/").sub("spec.rb", "test.rb")
|
47
|
+
end
|
48
|
+
|
37
49
|
if minitest_folder.exist? && rspec_folder.exist?
|
38
|
-
return best_candidate(
|
50
|
+
return best_candidate(candidates)
|
39
51
|
end
|
40
52
|
|
41
53
|
if minitest_folder.exist?
|
@@ -44,6 +56,7 @@ module Dotfiled
|
|
44
56
|
|
45
57
|
rspec
|
46
58
|
end
|
59
|
+
# rubocop:enable Metrics/CyclomaticComplexity:
|
47
60
|
|
48
61
|
def find_packaged_test_file_for(file)
|
49
62
|
parts = file.split
|
@@ -63,11 +76,15 @@ module Dotfiled
|
|
63
76
|
return find_packaged_file_for_test(file)
|
64
77
|
end
|
65
78
|
|
79
|
+
if file.match?(/request_spec.rb$/)
|
80
|
+
return find_controller_file_for_test(file)
|
81
|
+
end
|
82
|
+
|
66
83
|
file = file
|
67
84
|
.sub(/_(test|spec).rb$/, ".rb")
|
68
85
|
.sub(%r{^(test|tests|spec|specs)/}, "")
|
69
86
|
|
70
|
-
possible_folders = ["lib", "app/models", "app", "private", "public"]
|
87
|
+
possible_folders = ["lib", "app/models", "app/controllers", "app", "private", "public"]
|
71
88
|
candidates = possible_folders.map { |folder| prefix.join(folder).join(file) }
|
72
89
|
best_candidate(candidates)
|
73
90
|
end
|
@@ -81,6 +98,14 @@ module Dotfiled
|
|
81
98
|
find_alternative_for_ruby_test_file(file, prefix: prefix)
|
82
99
|
end
|
83
100
|
|
101
|
+
def find_controller_file_for_test(file)
|
102
|
+
file = file.split("requests/").last
|
103
|
+
file = File.new(file)
|
104
|
+
file = file.gsub("request_spec", "controller")
|
105
|
+
|
106
|
+
find_alternative_for_ruby_test_file(file)
|
107
|
+
end
|
108
|
+
|
84
109
|
def best_candidate(candidates)
|
85
110
|
candidates.find(&:exist?) || candidates.first
|
86
111
|
end
|
data/lib/dotfiled/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotfiled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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: 2021-
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Helpers for your dotfiles
|
14
14
|
email:
|