@@ -10,6 +10,8 @@ rescue LoadError => e
10
10
exit -1
11
11
end
12
12
13
+ require 'pathname'
14
+
13
15
HOST = 'www.ruby-lang.org'
14
16
LANGUAGES = %w[ bg de en es fr id it ja ko pl pt ru tr vi zh_cn zh_tw ]
15
17
CONFIG = "_config.yml"
@@ -122,27 +124,33 @@ namespace :check do
122
124
date ? date . getutc . strftime ( '%Y/%m/%d' ) : nil
123
125
end
124
126
127
+ def glob ( pattern )
128
+ Pathname . glob ( pattern ) . reject { |path | path . expand_path . to_s =~ %r{\A #{ Regexp . escape ( Bundler . bundle_path . to_s ) } /} } . map ( &:to_s )
129
+ end
130
+
125
131
desc "Check for missing author variables in news posts"
126
132
task :author do
127
133
print "Checking for missing author variables in news posts..."
128
134
129
- md_files = Dir [ "**/_posts/*.md" ]
135
+ md_files = glob ( "**/_posts/*.md" )
130
136
131
137
author_missing = md_files . select { |fn | !author_variable_defined? ( fn ) }
132
138
if author_missing . empty?
133
139
puts " ok"
134
140
else
135
141
puts "\n No author variable defined in:"
136
142
puts author_missing . map { |s | " #{ s } \n " } . join
143
+
144
+ raise
137
145
end
138
146
end
139
147
140
148
desc "Check for missing lang variables in markdown files"
141
149
task :lang do
142
150
print "Checking for missing lang variables in markdown files..."
143
151
144
- md_files = Dir [ "**/*.md" ]
145
- skip_patterns = [ /README.md/ , %r{[^/]*/examples/} ]
152
+ md_files = glob ( "**/*.md" )
153
+ skip_patterns = [ /README.md/ , %r{[^/]*/examples/} , %r{ \A _includes/} ]
146
154
147
155
skip_patterns . each do |pattern |
148
156
md_files . delete_if { |fn | fn =~ pattern }
@@ -154,14 +162,16 @@ namespace :check do
154
162
else
155
163
puts "\n No lang variable defined in:"
156
164
puts lang_missing . map { |s | " #{ s } \n " } . join
165
+
166
+ raise
157
167
end
158
168
end
159
169
160
170
desc "Check publication dates (UTC) for consistency with filename"
161
171
task :pubdates do
162
172
print "Checking for date mismatch in posts (filename / YAML front matter)..."
163
173
164
- posts = Dir [ "**/_posts/*.md" ]
174
+ posts = glob ( "**/_posts/*.md" )
165
175
166
176
date_mismatch = [ ]
167
177
posts . each do |post |
@@ -176,6 +186,8 @@ namespace :check do
176
186
else
177
187
puts "\n Date mismatch in:"
178
188
puts date_mismatch . map { |s | " #{ s } \n " } . join
189
+
190
+ raise
179
191
end
180
192
end
181
193
@@ -213,6 +225,8 @@ namespace :check do
213
225
else
214
226
puts "New Broken Link: #{ origin } -> #{ dest } "
215
227
end
228
+
229
+ raise
216
230
end
217
231
end
218
232
end
234
248
235
249
desc "Run some tests (lang, author, pubdates)"
236
250
task :check => [ 'check:lang' , 'check:author' , 'check:pubdates' ]
251
+ task :ci => [ :test , :build ]
0 commit comments