@@ -12,15 +12,26 @@ BaseRspecPath = Pathname.new(Dir.pwd)
12
12
ReposPath = BaseRspecPath . join ( 'repos' )
13
13
MAX_PROJECT_NAME_LENGTH = Projects . map ( &:length ) . max
14
14
15
+ def filter_projects_by_string ( string , projects = Projects )
16
+ selection = string . split ( " " )
17
+ projects . select { |project | selection . include? ( project . downcase ) }
18
+ end
19
+
20
+ def select_projects ( options = { } )
21
+ projects =
22
+ if only_string = ENV [ 'ONLY' ]
23
+ filter_projects_by_string ( only_string )
24
+ else
25
+ options . fetch ( :only , Projects ) . flatten - Array ( options [ :except ] )
26
+ end
27
+
28
+ projects -= filter_projects_by_string ( ENV [ 'EXCEPT' ] ) if ENV [ 'EXCEPT' ]
29
+
30
+ projects
31
+ end
32
+
15
33
def run_command ( command , opts = { } )
16
- projects = if opts [ :except ]
17
- Projects - [ opts [ :except ] ] . flatten
18
- elsif opts [ :only ]
19
- [ opts [ :only ] ] . flatten
20
- else
21
- Projects
22
- end
23
- projects . each do |dir |
34
+ select_projects ( opts ) . each do |dir |
24
35
next if [ opts [ :except ] ] . flatten . compact . include? ( dir )
25
36
path = ReposPath . join ( dir )
26
37
FileUtils . cd ( path ) do
@@ -43,10 +54,7 @@ def announce(project)
43
54
end
44
55
45
56
def each_project ( options = { } )
46
- projects = options . fetch ( :only , Projects )
47
- projects -= Array ( options [ :except ] )
48
-
49
- projects . each do |project |
57
+ select_projects ( options ) . each do |project |
50
58
Dir . chdir ( "repos/#{ project } " ) do
51
59
if options [ :silent ]
52
60
yield project
@@ -408,10 +416,23 @@ namespace :common_plaintext_files do
408
416
file . basename . to_s =~ /ISSUE_TEMPLATE/
409
417
end
410
418
419
+ COMMON_PLAINTEXT_EXCLUSIONS =
420
+ {
421
+ 'rspec' =>
422
+ %w[ BUILD_DETAIL.md.erb CONTRIBUTING.md.erb DEVELOPMENT.md.erb ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md ] ,
423
+ 'rspec-rails' => %w[ ISSUE_TEMPLATE.md.erb REPORT_TEMPLATE.md ]
424
+ }
425
+
411
426
def common_plaintext_files_with_comments ( project_name )
412
427
plaintext_root = BaseRspecPath . join ( 'common_plaintext_files' )
428
+
429
+ excluded_files =
430
+ COMMON_PLAINTEXT_EXCLUSIONS . fetch ( project_name , [ ] ) . map do |filename |
431
+ File . expand_path ( filename , plaintext_root ) . to_s
432
+ end
433
+
413
434
file_names = Pathname . glob ( plaintext_root . join ( '{.[!.],*}*' , '{*,.*}' ) ) . select do |f |
414
- f . file?
435
+ f . file? && ! excluded_files . include? ( f . to_s )
415
436
end
416
437
417
438
file_names . map do |file |
0 commit comments