learn_linter 1.6.9 → 1.7.0
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 +4 -4
- data/lib/learn_linter/learn_error.rb +1 -1
- data/lib/learn_linter/readme_linter.rb +30 -12
- data/lib/learn_linter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2591ce2673e8253953b70b5cd03c115b0dec2e46
|
4
|
+
data.tar.gz: 9400f8228d373ef061e55b786093fee3dbd9ef68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c4c8b2d1becb8a718a96fe9ae38e1de50220590a13d0c7c6d402ab79e5f2663ab8f62f52970a50ff31f5dc896f1d22f25526c258447655ea6b24ad30a154f90
|
7
|
+
data.tar.gz: 4200cdfb63629d2eac2ea8fef9c1c10fe87b3f7a052f9bd8688afe973791ce65c86dfadc63b3154e260898277d2d902be35b0a98d5625bb77677f5ca1bdea6be
|
@@ -20,7 +20,7 @@ class LearnError < StandardError
|
|
20
20
|
|
21
21
|
@valid_yaml = {message: "invalid yaml", color: :red}
|
22
22
|
@valid_license = {message: "invalid or missing license content", color: :yellow}
|
23
|
-
@valid_readme = {message: "
|
23
|
+
@valid_readme = {message: "", color: :red}
|
24
24
|
@valid_contributing = {message: "invalid or missing contributing content", color: :yellow}
|
25
25
|
|
26
26
|
@present_learn = {message: "missing .learn file", color: :red}
|
@@ -1,11 +1,13 @@
|
|
1
|
+
require 'english'
|
2
|
+
|
1
3
|
class ReadmeLinter
|
2
4
|
|
3
5
|
def self.parse_file(file, learn_error)
|
4
|
-
|
5
|
-
|
6
|
-
validate_snippets(
|
6
|
+
if has_code_snippets?(file)
|
7
|
+
lines = collect_lines(file)
|
8
|
+
validate_snippets(lines, learn_error)
|
7
9
|
else
|
8
|
-
|
10
|
+
green_light(learn_error)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -15,19 +17,35 @@ class ReadmeLinter
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.has_code_snippets?(file)
|
18
|
-
|
20
|
+
file_content = File.open(file).read
|
21
|
+
file_content.match(/``/)
|
19
22
|
end
|
20
23
|
|
21
|
-
def self.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def self.collect_lines(file)
|
25
|
+
lines = {}
|
26
|
+
File.foreach(file) do |line_content|
|
27
|
+
lines["#{$INPUT_LINE_NUMBER}"] = line_content
|
28
|
+
end
|
29
|
+
lines
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.validate_snippets(lines, learn_error)
|
33
|
+
lines.each do |line_num, line_content|
|
34
|
+
if line_content.match(/``/)
|
35
|
+
if !(line_content.match(/^```(ruby|bash|swift|html|erb|js|javascript|objc|java|sql)?$/))
|
36
|
+
learn_error.valid_readme[:message] << "INVALID CODE SNIPPET - line #{line_num}: #{line_content}\n"
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
40
|
+
total_errors?(learn_error)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.total_errors?(learn_error)
|
44
|
+
if !learn_error.valid_readme[:message].include?("INVALID CODE SNIPPET")
|
45
|
+
green_light(learn_error)
|
46
|
+
end
|
31
47
|
end
|
32
48
|
end
|
49
|
+
|
50
|
+
|
33
51
|
|
data/lib/learn_linter/version.rb
CHANGED