Skip to content

Commit 5b8d09c

Browse files
authored
move filters to inert file to pacify Sheldon (#5268)
1 parent e5f3315 commit 5b8d09c

File tree

3 files changed

+91
-54
lines changed

3 files changed

+91
-54
lines changed

spec/filters.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# These ISSNs are ignored when checking for duplicate ISSNs
2+
ISSN:
3+
- 1662-453X
4+
- 1663-9812
5+
- 1664-042X
6+
- 1664-0640
7+
- 1664-1078
8+
- 1664-2295
9+
- 1664-2392
10+
- 1664-302X
11+
- 1664-3224
12+
- 1664-462X
13+
- 1664-8021
14+
- 2234-943X
15+
- 0036-8075
16+
- 1095-9203
17+
- 1359-4184
18+
- 1476-5578
19+
- 1097-6256
20+
- 1047-7594
21+
- 1546-1726
22+
- 2108-6419
23+
- 0035-2969
24+
- 1958-5691
25+
- 0943-8610
26+
- 2194-508X
27+
- 0223-5099
28+
- 0322-8916
29+
- 1805-6555
30+
- 1899-0665
31+
- 0305-1048
32+
- 1362-4962
33+
- 0042-7306
34+
- 1783-1830
35+
- 1438-5627
36+
- 0353-6483
37+
- 1855-8399
38+
39+
# These titles are ignored when checking for duplicate titles
40+
TITLES: []
41+
# - example title 1
42+
# - example title 2
43+
44+
# These styles are ignored when checking for valid citation-formats
45+
CITATION_FORMAT:
46+
- bibtex
47+
- blank
48+
- national-archives-of-australia
49+
50+
# These styles are ignored when checking for unused macros
51+
UNUSED_MACROS:
52+
- apa-annotated-bibliography
53+
- apa-cv
54+
- apa-numeric-superscript
55+
- apa-numeric-superscript-brackets
56+
- apa-with-abstract
57+
- chicago-annotated-bibliography
58+
- chicago-author-date
59+
- chicago-author-date-16th-edition
60+
- chicago-library-list
61+
- chicago-note-bibliography-16th-edition
62+
- chicago-note-bibliography-with-ibid
63+
- chicago-note-bibliography
64+
- taylor-and-francis-chicago-author-date
65+
- turabian-author-date
66+
67+
# These files and directories are ignored when checking for extra files
68+
EXTRA_FILES:
69+
- CONTRIBUTING.md
70+
- Gemfile
71+
- Gemfile.lock
72+
- README.md
73+
- dependent
74+
- Rakefile
75+
- renamed-styles.json
76+
- REQUESTING.md
77+
- STYLE_DEVELOPMENT.md
78+
- STYLE_REQUIREMENTS.md
79+
- QUALITY_CONTROL.md
80+
81+
# These directories and their contents are ignored when checking for extra files
82+
EXTRA_FILES_DIRECTORY:
83+
- spec
84+
- vendor

spec/spec_helper.rb

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,12 @@
55

66
ISSN = Hash.new { |h,k| h[k] = [] }
77
TITLES = Hash.new { |h,k| h[k] = [] }
8-
9-
# These ISSNs are ignored when checking for duplicate ISSNs
10-
ISSN_FILTER = %w{
11-
1662-453X 1663-9812 1664-042X 1664-0640 1664-1078 1664-2295
12-
1664-2392 1664-302X 1664-3224 1664-462X 1664-8021 2234-943X
13-
0036-8075 1095-9203 1359-4184 1476-5578 1097-6256 1047-7594
14-
1546-1726 2108-6419 0035-2969 1958-5691 0943-8610 2194-508X
15-
0223-5099 0322-8916 1805-6555 1899-0665 0305-1048 1362-4962
16-
0042-7306 1783-1830 1438-5627 0353-6483 1855-8399 0001-4966
17-
1520-8524
18-
}
19-
20-
# These titles are ignored when checking for duplicate titles
21-
TITLES_FILTER = [
22-
# 'example title 1',
23-
# 'example title 2'
24-
]
25-
26-
# These styles are ignored when checking for valid citation-formats
27-
CITATION_FORMAT_FILTER = %w{
28-
bibtex blank national-archives-of-australia
29-
}
30-
31-
# These styles are ignored when checking for unused macros
32-
UNUSED_MACROS_FILTER = %w{
33-
apa-annotated-bibliography
34-
apa-cv
35-
apa-numeric-superscript
36-
apa-numeric-superscript-brackets
37-
apa-with-abstract
38-
chicago-annotated-bibliography chicago-author-date chicago-author-date-16th-edition
39-
chicago-library-list chicago-note-bibliography-16th-edition
40-
chicago-note-bibliography-with-ibid
41-
chicago-note-bibliography taylor-and-francis-chicago-author-date
42-
turabian-author-date
43-
}
44-
45-
# These files and directories are ignored when checking for extra files
46-
EXTRA_FILES_FILTER = [
47-
'CONTRIBUTING.md', 'Gemfile', 'Gemfile.lock', 'README.md',
48-
'dependent', 'Rakefile', 'renamed-styles.json', 'REQUESTING.md', 'STYLE_DEVELOPMENT.md',
49-
'STYLE_REQUIREMENTS.md', 'QUALITY_CONTROL.md'
50-
]
51-
52-
# These directories and their contents are ignored when checking for extra files
53-
EXTRA_FILES_DIRECTORY_FILTER = [
54-
'spec', 'vendor'
55-
]
8+
FILTER = YAML.load_file(File.join(File.dirname(__FILE__), 'filters.yaml'))
569

5710
EXTRA_FILES = Dir[File.join(STYLE_ROOT, '**', '*')].reject do |file|
5811
basedir = file.sub(STYLE_ROOT + "/","").partition("/")[0]
5912
name = File.basename(file)
60-
File.extname(file) == '.csl' || EXTRA_FILES_FILTER.any? { |f| f === name } || EXTRA_FILES_DIRECTORY_FILTER.any? { |d| d === basedir}
13+
File.extname(file) == '.csl' || FILTER['EXTRA_FILES'].any? { |f| f === name } || FILTER['EXTRA_FILES_DIRECTORY'].any? { |d| d === basedir}
6114
end
6215

6316
# License URL and text
@@ -79,19 +32,19 @@ def load_style(path)
7932
begin
8033
if style.info.has_issn?
8134
[style.info.issn].flatten(1).each do |issn|
82-
ISSN[issn.to_s] << basename unless ISSN_FILTER.include?(issn.to_s)
35+
ISSN[issn.to_s] << basename unless FILTER['ISSN'].include?(issn.to_s)
8336
end
8437
end
8538

8639
if style.info.has_eissn?
8740
[style.info.eissn].flatten(1).each do |issn|
88-
ISSN[issn.to_s] << basename unless ISSN_FILTER.include?(issn.to_s)
41+
ISSN[issn.to_s] << basename unless FILTER['ISSN'].include?(issn.to_s)
8942
end
9043
end
9144

9245
if style.has_title?
9346
title = style.title.to_s.downcase
94-
TITLES[title] << basename unless TITLES_FILTER.include?(title)
47+
TITLES[title] << basename unless FILTER['TITLES'].include?(title)
9548
end
9649
rescue
9750
warn "Failed to extract ISSN of style #{basename}"

spec/styles_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
end
3636
end
3737

38-
unless CITATION_FORMAT_FILTER.include?(basename)
38+
unless FILTER['CITATION_FORMAT'].include?(basename)
3939

4040
it 'must define a citation-format (<category citation-format="..."/>)' do
4141
expect(style.citation_format).not_to be_nil
@@ -58,7 +58,7 @@
5858
end
5959
end
6060

61-
unless UNUSED_MACROS_FILTER.include?(basename)
61+
unless FILTER['UNUSED_MACROS'].include?(basename)
6262
it "may not have any unused macros" do
6363
available_macros = style.macros.keys.sort
6464

0 commit comments

Comments
 (0)