diff --git a/spec/filters.yaml b/spec/filters.yaml new file mode 100644 index 00000000000..46a668730b3 --- /dev/null +++ b/spec/filters.yaml @@ -0,0 +1,84 @@ +# These ISSNs are ignored when checking for duplicate ISSNs +ISSN: +- 1662-453X +- 1663-9812 +- 1664-042X +- 1664-0640 +- 1664-1078 +- 1664-2295 +- 1664-2392 +- 1664-302X +- 1664-3224 +- 1664-462X +- 1664-8021 +- 2234-943X +- 0036-8075 +- 1095-9203 +- 1359-4184 +- 1476-5578 +- 1097-6256 +- 1047-7594 +- 1546-1726 +- 2108-6419 +- 0035-2969 +- 1958-5691 +- 0943-8610 +- 2194-508X +- 0223-5099 +- 0322-8916 +- 1805-6555 +- 1899-0665 +- 0305-1048 +- 1362-4962 +- 0042-7306 +- 1783-1830 +- 1438-5627 +- 0353-6483 +- 1855-8399 + +# These titles are ignored when checking for duplicate titles +TITLES: [] +# - example title 1 +# - example title 2 + +# These styles are ignored when checking for valid citation-formats +CITATION_FORMAT: +- bibtex +- blank +- national-archives-of-australia + +# These styles are ignored when checking for unused macros +UNUSED_MACROS: +- apa-annotated-bibliography +- apa-cv +- apa-numeric-superscript +- apa-numeric-superscript-brackets +- apa-with-abstract +- chicago-annotated-bibliography +- chicago-author-date +- chicago-author-date-16th-edition +- chicago-library-list +- chicago-note-bibliography-16th-edition +- chicago-note-bibliography-with-ibid +- chicago-note-bibliography +- taylor-and-francis-chicago-author-date +- turabian-author-date + +# These files and directories are ignored when checking for extra files +EXTRA_FILES: +- CONTRIBUTING.md +- Gemfile +- Gemfile.lock +- README.md +- dependent +- Rakefile +- renamed-styles.json +- REQUESTING.md +- STYLE_DEVELOPMENT.md +- STYLE_REQUIREMENTS.md +- QUALITY_CONTROL.md + +# These directories and their contents are ignored when checking for extra files +EXTRA_FILES_DIRECTORY: +- spec +- vendor diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 81f376abd07..2130dc20ced 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,59 +5,12 @@ ISSN = Hash.new { |h,k| h[k] = [] } TITLES = Hash.new { |h,k| h[k] = [] } - -# These ISSNs are ignored when checking for duplicate ISSNs -ISSN_FILTER = %w{ - 1662-453X 1663-9812 1664-042X 1664-0640 1664-1078 1664-2295 - 1664-2392 1664-302X 1664-3224 1664-462X 1664-8021 2234-943X - 0036-8075 1095-9203 1359-4184 1476-5578 1097-6256 1047-7594 - 1546-1726 2108-6419 0035-2969 1958-5691 0943-8610 2194-508X - 0223-5099 0322-8916 1805-6555 1899-0665 0305-1048 1362-4962 - 0042-7306 1783-1830 1438-5627 0353-6483 1855-8399 0001-4966 - 1520-8524 -} - -# These titles are ignored when checking for duplicate titles -TITLES_FILTER = [ - # 'example title 1', - # 'example title 2' -] - -# These styles are ignored when checking for valid citation-formats -CITATION_FORMAT_FILTER = %w{ - bibtex blank national-archives-of-australia -} - -# These styles are ignored when checking for unused macros -UNUSED_MACROS_FILTER = %w{ - apa-annotated-bibliography - apa-cv - apa-numeric-superscript - apa-numeric-superscript-brackets - apa-with-abstract - chicago-annotated-bibliography chicago-author-date chicago-author-date-16th-edition - chicago-library-list chicago-note-bibliography-16th-edition - chicago-note-bibliography-with-ibid - chicago-note-bibliography taylor-and-francis-chicago-author-date - turabian-author-date -} - -# These files and directories are ignored when checking for extra files -EXTRA_FILES_FILTER = [ - 'CONTRIBUTING.md', 'Gemfile', 'Gemfile.lock', 'README.md', - 'dependent', 'Rakefile', 'renamed-styles.json', 'REQUESTING.md', 'STYLE_DEVELOPMENT.md', - 'STYLE_REQUIREMENTS.md', 'QUALITY_CONTROL.md' -] - -# These directories and their contents are ignored when checking for extra files -EXTRA_FILES_DIRECTORY_FILTER = [ - 'spec', 'vendor' -] +FILTER = YAML.load_file(File.join(File.dirname(__FILE__), 'filters.yaml')) EXTRA_FILES = Dir[File.join(STYLE_ROOT, '**', '*')].reject do |file| basedir = file.sub(STYLE_ROOT + "/","").partition("/")[0] name = File.basename(file) - File.extname(file) == '.csl' || EXTRA_FILES_FILTER.any? { |f| f === name } || EXTRA_FILES_DIRECTORY_FILTER.any? { |d| d === basedir} + File.extname(file) == '.csl' || FILTER['EXTRA_FILES'].any? { |f| f === name } || FILTER['EXTRA_FILES_DIRECTORY'].any? { |d| d === basedir} end # License URL and text @@ -79,19 +32,19 @@ def load_style(path) begin if style.info.has_issn? [style.info.issn].flatten(1).each do |issn| - ISSN[issn.to_s] << basename unless ISSN_FILTER.include?(issn.to_s) + ISSN[issn.to_s] << basename unless FILTER['ISSN'].include?(issn.to_s) end end if style.info.has_eissn? [style.info.eissn].flatten(1).each do |issn| - ISSN[issn.to_s] << basename unless ISSN_FILTER.include?(issn.to_s) + ISSN[issn.to_s] << basename unless FILTER['ISSN'].include?(issn.to_s) end end if style.has_title? title = style.title.to_s.downcase - TITLES[title] << basename unless TITLES_FILTER.include?(title) + TITLES[title] << basename unless FILTER['TITLES'].include?(title) end rescue warn "Failed to extract ISSN of style #{basename}" diff --git a/spec/styles_spec.rb b/spec/styles_spec.rb index ec03699b3d1..82406e0b1ee 100644 --- a/spec/styles_spec.rb +++ b/spec/styles_spec.rb @@ -35,7 +35,7 @@ end end - unless CITATION_FORMAT_FILTER.include?(basename) + unless FILTER['CITATION_FORMAT'].include?(basename) it 'must define a citation-format ()' do expect(style.citation_format).not_to be_nil @@ -58,7 +58,7 @@ end end - unless UNUSED_MACROS_FILTER.include?(basename) + unless FILTER['UNUSED_MACROS'].include?(basename) it "may not have any unused macros" do available_macros = style.macros.keys.sort