File tree Expand file tree Collapse file tree 12 files changed +66
-34
lines changed Expand file tree Collapse file tree 12 files changed +66
-34
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def initialize
1111 @offenses = [ ]
1212 end
1313
14- def run
14+ def run ( scoped_files )
1515 raise NotImplementedError
1616 end
1717
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class RequiredFilesCheck < Check
1212 "assets/index.css"
1313 ] . freeze
1414
15- def run
15+ def run ( scoped_files )
1616 REQUIRED_FILES . each do |filename |
1717 file_paths = Dir . glob ( filename )
1818
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ module Canvas
1919 # <p>My block HTML</p>
2020 #
2121 class ValidBlockSchemasCheck < Check
22- def run
22+ def run ( scoped_files )
2323 custom_types = Canvas ::FetchCustomTypes . call
24- block_files . each do |filename |
24+ block_files ( scoped_files ) . each do |filename |
2525 front_matter = extract_front_matter ( filename )
2626 next unless front_matter
2727
@@ -32,8 +32,13 @@ def run
3232
3333 private
3434
35- def block_files
36- Dir . glob ( "blocks/**/*.{html,liquid}" )
35+ def block_files ( scoped_files )
36+ all_files = Dir . glob ( "blocks/**/*.{html,liquid}" )
37+ if scoped_files . any?
38+ all_files & scoped_files
39+ else
40+ all_files
41+ end
3742 end
3843
3944 def validate_format ( filename , front_matter )
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ module Canvas
55 # This check will validate the JSON objects that represent the
66 # custom types that are defined in the /types directory.
77 class ValidCustomTypesCheck < Check
8- def run
9- custom_type_files . each do |filename |
8+ def run ( scoped_files )
9+ custom_type_files ( scoped_files ) . each do |filename |
1010 schema = extract_json ( filename )
1111 validator = Validator ::CustomType . new ( schema : schema )
1212
@@ -22,8 +22,13 @@ def run
2222
2323 private
2424
25- def custom_type_files
26- Dir . glob ( "types/*.json" )
25+ def custom_type_files ( scoped_files )
26+ all_files = Dir . glob ( "types/*.json" )
27+ if scoped_files . any?
28+ all_files & scoped_files
29+ else
30+ all_files
31+ end
2732 end
2833
2934 def extract_json ( filename )
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ module Canvas
2222 # <p>My footer HTML</p>
2323 #
2424 class ValidFooterSchemaCheck < Check
25- def run
25+ def run ( scoped_files )
26+ return unless scoped_files . include? footer_filename
2627 file = File . read ( footer_filename )
2728 front_matter = extract_front_matter ( file )
2829 validate_format ( front_matter ) &&
Original file line number Diff line number Diff line change 33module Canvas
44 # :documented:
55 class ValidHtmlCheck < Check
6- def run
7- html_files . each do |filename |
6+ def run ( scoped_files )
7+ html_files ( scoped_files ) . each do |filename |
88 file = File . read ( filename )
99 validator = Validator ::Html . new ( file )
1010
@@ -18,8 +18,13 @@ def run
1818 end
1919 end
2020
21- def html_files
22- Dir . glob ( "**/*.{html,liquid}" )
21+ def html_files ( scoped_files )
22+ all_files = Dir . glob ( "**/*.{html,liquid}" )
23+ if scoped_files . any?
24+ all_files & scoped_files
25+ else
26+ all_files
27+ end
2328 end
2429 end
2530end
Original file line number Diff line number Diff line change 33module Canvas
44 # :documented:
55 class ValidJsonCheck < Check
6- def run
7- json_files . each do |filename |
6+ def run ( scoped_files )
7+ json_files ( scoped_files ) . each do |filename |
88 file = File . read ( filename )
99 validator = Validator ::Json . new ( file )
1010
@@ -20,8 +20,13 @@ def run
2020
2121 private
2222
23- def json_files
24- Dir . glob ( "**/*.json" )
23+ def json_files ( scoped_files )
24+ all_files = Dir . glob ( "**/*.json" )
25+ if scoped_files . any?
26+ all_files & scoped_files
27+ else
28+ all_files
29+ end
2530 end
2631 end
2732end
Original file line number Diff line number Diff line change 33module Canvas
44 # :documented:
55 class ValidLiquidCheck < Check
6- def run
6+ def run ( scoped_files )
77 register_tags!
88
9- liquid_files . each do |filename |
9+ liquid_files ( scoped_files ) . each do |filename |
1010 file = File . read ( filename )
1111 validator = Validator ::Liquid . new ( file )
1212
@@ -22,8 +22,13 @@ def run
2222
2323 private
2424
25- def liquid_files
26- Dir . glob ( "**/*.{html,liquid}" )
25+ def liquid_files ( scoped_files )
26+ all_files = Dir . glob ( "**/*.{html,liquid}" )
27+ if scoped_files . any?
28+ all_files & scoped_files
29+ else
30+ all_files
31+ end
2732 end
2833
2934 def register_tag ( name , klass )
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ module Canvas
2222 # <p>My menu HTML</p>
2323 #
2424 class ValidMenuSchemaCheck < Check
25- def run
25+ def run ( scoped_files )
26+ return unless scoped_files . include? menu_filename
2627 file = File . read ( menu_filename )
2728 front_matter = extract_front_matter ( file )
2829 validate_format ( front_matter ) &&
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ module Canvas
66 # This check will find all files ending in .css, .scss or .sass
77 # and run them through the sass validator - {Canvas::Validator::Sass}.
88 class ValidSassCheck < Check
9- def run
10- sass_files . each do |filename |
9+ def run ( scoped_files )
10+ sass_files ( scoped_files ) . each do |filename |
1111 file = File . read ( filename )
1212 validator = Validator ::Sass . new ( file )
1313
@@ -23,8 +23,13 @@ def run
2323
2424 private
2525
26- def sass_files
27- Dir . glob ( "**/*.{css,scss,sass}" )
26+ def sass_files ( scoped_files )
27+ all_files = Dir . glob ( "**/*.{css,scss,sass}" )
28+ if scoped_files . any?
29+ all_files & scoped_files
30+ else
31+ all_files
32+ end
2833 end
2934 end
3035end
You can’t perform that action at this time.
0 commit comments