File tree Expand file tree Collapse file tree 9 files changed +64
-4
lines changed Expand file tree Collapse file tree 9 files changed +64
-4
lines changed Original file line number Diff line number Diff line change 70
70
continue-on-error : true
71
71
run : ruby -r "./ci/last_reachable_checker.rb" -e "::CI::LastReachableChecker.new.process"
72
72
73
+ duplicate_links_checker :
74
+ runs-on : ubuntu-latest
75
+ steps :
76
+ - uses : actions/checkout@v2
77
+ - name : Set up Ruby
78
+ uses : ruby/setup-ruby@v1
79
+ with :
80
+ ruby-version : ${{ env.RUBY_VERSION }}
81
+ - name : Run duplicate links checker
82
+ run : ruby -r "./ci/duplicate_links_checker.rb" -e "::CI::DuplicateLinksChecker.new.process"
83
+
73
84
rubocop :
74
85
runs-on : ubuntu-latest
75
86
steps :
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class CIJob
10
10
private_constant :PROCESS_NO_IMPL_ERROR
11
11
12
12
# Main entry of job class that runs your check.
13
+ # @return {Void}
13
14
def run
14
15
puts ( "#{ self . class . name } started..." )
15
16
@@ -19,6 +20,8 @@ def run
19
20
end
20
21
21
22
# Use this method in your realization when task completed with error.
23
+ # @param {String} details
24
+ # @return {Void}
22
25
def end_with_error ( details )
23
26
details . call
24
27
@@ -29,6 +32,7 @@ def end_with_error(details)
29
32
30
33
# Job realization.
31
34
# You should override this method in your realization.
35
+ # @return {Void}
32
36
def process
33
37
raise ( ::PROCESS_NO_IMPL_ERROR )
34
38
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './ci_job'
4
+
5
+ module CI
6
+ # CI job that checks last link in README reachable status.
7
+ class DuplicateLinksChecker < CIJob
8
+ # Process LastReachableChecker
9
+ # @return {Void}
10
+ def process
11
+ check
12
+ end
13
+
14
+ private
15
+
16
+ # @return {Void}
17
+ def check
18
+ links = [ ]
19
+
20
+ regex = %r{https://[^\s ()<>]+(?:\( [\w \d ]+\) |([^[:punct:]\s ]|/))}
21
+
22
+ ::File . readlines ( 'README.md' ) . each do |line |
23
+ link = line . match ( regex )
24
+
25
+ next unless link
26
+
27
+ links << link [ 0 ]
28
+ end
29
+
30
+ return if links . size == links . uniq . size
31
+
32
+ error = "DuplicateLinksChecker ends with an error from. You have #{ links . size - links . uniq . size } duplicates."
33
+ end_with_error ( -> { puts ( error ) } )
34
+ end
35
+ end
36
+ end
Original file line number Diff line number Diff line change @@ -8,20 +8,21 @@ module CI
8
8
# CI job that checks last link in README reachable status.
9
9
class LastReachableChecker < CIJob
10
10
# Process LastReachableChecker
11
+ # @return {Void}
11
12
def process
12
13
check
13
14
end
14
15
15
16
private
16
17
18
+ # @return {Void}
17
19
def check
18
20
readme = ::File . readlines ( 'README.md' )
19
21
last_solution = readme . last
20
22
21
- uri = ::URI . extract ( last_solution )
22
- parsed_uri = uri . first [ 0 , uri . first . length - 1 ]
23
+ regex = %r{https://[^\s ()<>]+(?:\( [\w \d ]+\) |([^[:punct:]\s ]|/))}
23
24
24
- url = ::URI . parse ( parsed_uri )
25
+ url = ::URI . parse ( last_solution . match ( regex ) [ 0 ] )
25
26
req = ::Net ::HTTP . new ( url . host , url . port )
26
27
req . use_ssl = true if url . scheme == 'https'
27
28
res = req . request_head ( url . path )
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ module CI
6
6
# CI job that checks links in solutions.
7
7
class LinksChecker < ::CI ::CIJob
8
8
# Process LinksChecker.
9
+ # @return {Void}
9
10
def process
10
11
check ( 'easy' )
11
12
end
12
13
13
14
private
14
15
15
16
# @param {String} difficulty
17
+ # @return {Void}
16
18
def check ( difficulty )
17
19
path = "./lib/#{ difficulty } "
18
20
solutions = ::Dir . entries ( path ) . reject { |file_name | file_name . start_with? ( '.' ) }
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ module CI
6
6
# CI job that checks links in README.
7
7
class ReadmeChecker < ::CI ::CIJob
8
8
# Process ReadmeChecker.
9
+ # @return {Void}
9
10
def process
10
11
check ( 'easy' )
11
12
end
12
13
13
14
private
14
15
15
16
# @param {String} difficulty
17
+ # @return {Void}
16
18
def check ( difficulty )
17
19
path = "./lib/#{ difficulty } "
18
20
solutions = ::Dir . entries ( path ) . reject { |file_name | file_name . start_with? ( '.' ) }
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ module CI
6
6
# CI job that checks tests for solutions.
7
7
class TestsChecker < ::CI ::CIJob
8
8
# Process TestsChecker.
9
+ # @return {Void}
9
10
def process
10
11
check ( 'easy' )
11
12
end
12
13
13
14
private
14
15
15
16
# @param {String} difficulty
17
+ # @return {Void}
16
18
def check ( difficulty )
17
19
path = "./lib/#{ difficulty } "
18
20
solutions = ::Dir . entries ( path ) . reject { |file_name | file_name . start_with? ( '.' ) }
Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ module CI
9
9
# CI job that checks project version.
10
10
class VersionChecker < ::CI ::CIJob
11
11
# Process VersionChecker.
12
+ # @return {Void}
12
13
def process
13
14
check
14
15
end
15
16
16
17
private
17
18
19
+ # @return {Void}
18
20
def check
19
21
local_spec = ::Gem ::Specification . load ( 'leetcode-ruby.gemspec' )
20
22
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ require 'English'
5
5
::Gem ::Specification . new do |s |
6
6
s . required_ruby_version = '>= 3.0'
7
7
s . name = 'leetcode-ruby'
8
- s . version = '6.4.2'
8
+ s . version = '6.4.2.1 '
9
9
s . license = 'MIT'
10
10
s . files = ::Dir [ 'lib/**/*.rb' ] + %w[ README.md ]
11
11
s . executable = 'leetcode-ruby'
You can’t perform that action at this time.
0 commit comments