mirror of
https://github.com/public-apis/public-apis.git
synced 2025-06-02 10:51:53 +02:00
use regex to check number of padding spaces
This commit is contained in:
parent
10bc3049c1
commit
3a79096bdb
2 changed files with 7 additions and 3 deletions
3
build/test.rb
Normal file
3
build/test.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
s = " lol "
|
||||
puts s[/\A +/].size
|
||||
puts s[/ +\z/].size
|
|
@ -39,16 +39,17 @@ File.foreach(filename).with_index do | line, line_num |
|
|||
|
||||
values = line.split("|")
|
||||
|
||||
################### GLOBAL ###################
|
||||
values.each.with_index do |val, val_index|
|
||||
msg = ""
|
||||
case val_index
|
||||
when INDEX_TITLE..INDEX_LINK
|
||||
if val[0] != " " || val[val.length-1] != " "
|
||||
add_error(line_num, val_index, "pad before and after string with spaces")
|
||||
# every line segment should start and end with exactly 1 space
|
||||
if val[/\A */].size != 1 || val[/ *\z/].size != 1
|
||||
add_error(line_num, val_index, "string should start and end with exactly 1 space")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
################# DESCRIPTION ################
|
||||
# First character should be capitalized
|
||||
desc_val = values[INDEX_DESCRIPTION].lstrip.chop
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue