Skip to content

Commit

Permalink
move filters to inert file to pacify Sheldon (#5268)
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Feb 15, 2021
1 parent e5f3315 commit 5b8d09c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 54 deletions.
84 changes: 84 additions & 0 deletions spec/filters.yaml
Original file line number Diff line number Diff line change
@@ -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
57 changes: 5 additions & 52 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions spec/styles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end
end

unless CITATION_FORMAT_FILTER.include?(basename)
unless FILTER['CITATION_FORMAT'].include?(basename)

it 'must define a citation-format (<category citation-format="..."/>)' do
expect(style.citation_format).not_to be_nil
Expand All @@ -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

Expand Down

0 comments on commit 5b8d09c

Please sign in to comment.