Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow excluding regions #6278

Merged
merged 6 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions entries/b/bankera.com.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"documentation": "https://bankera.com/faq/how-to-enable-second-factor-authentication/",
"keywords": [
"banking"
],
"regions": [
"-us"
]
}
}
3 changes: 3 additions & 0 deletions entries/h/hsbc.com.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"documentation": "https://www.hsbc.co.uk/help/security-centre/secure-key/secure-key-help/",
"keywords": [
"banking"
],
"regions": [
"-ar"
]
}
}
4 changes: 4 additions & 0 deletions entries/v/vanguard.com.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"notes": "Hardware based 2FA requires SMS / Phone call 2FA as a backup.",
"keywords": [
"investing"
],
"regions": [
"-gb",
"-au"
]
}
}
9 changes: 8 additions & 1 deletion scripts/regions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
FileUtils.cp_r(git_dir, "#{tmp_dir}/") unless File.exist?("#{tmp_dir}/.git")

# Region loop
# rubocop:disable Metrics/BlockLength
regions.each do |region|
dest_dir = "#{tmp_dir}/#{region['id']}"
unless File.exist?(dest_dir)
Expand All @@ -27,7 +28,12 @@

# Website loop
websites.each do |name, website|
next unless website['regions'].nil? || website['regions'].include?(region['id']) || region['id'].eql?('int')
unless website['regions'].nil?
site_regions = website['regions'].reject { |r| r.start_with?('-') }
site_excluded_regions = website['regions'].select { |r| r.start_with?('-') }
end
next unless website['regions'].nil? || site_regions.include?(region['id']) || region['id'].eql?('int')
next if !site_excluded_regions.nil? && site_excluded_regions.include?(region['id'])

all[name] = website
website['keywords'].each do |kw|
Expand All @@ -48,3 +54,4 @@
puts `bundle exec jekyll build -s #{dest_dir} --config _config.yml -d #{out_dir} --baseurl #{region['id']}`
puts "#{region['id']} built."
end
# rubocop:enable Metrics/BlockLength
1 change: 1 addition & 0 deletions tests/region-codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
website = JSON.parse(File.read(file)).values[0]
next if website['regions'].nil?

website['regions'].map! { |region_code| region_code.tr('-', '') }
website['regions'].each do |region|
next if @codes.include?(region.to_s)

Expand Down
2 changes: 1 addition & 1 deletion tests/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"minItems": 1,
"items": {
"type": "string",
"pattern": "^[a-z]{2}$"
"pattern": "^-?[a-z]{2}$"
}
},
"additional-domains": {
Expand Down