A Ruby script was created to split a large YAML file named travel.yaml
, which includes a list of country keys and information, into individual files for each country.
data = YAML.load(File.read('./src/constants/travel.yaml'))
data.fetch('countries').each do |key, value|
File.open("./src/constants/countries/#{key}.yaml", 'w') { |file| file.write({ key => value }.to_yaml) }
end
The format of each individual file would resemble:
---
BA:
sources:
domestic:
- Wearing masks and social distancing (a minimum of 2 metres) are [mandatory in
all public places](https://www.oecd.org/south-east-europe/COVID-19-Crisis-in-Bosnia-and-Herzegovina.pdf).
inbound:
- The BiH Council of Ministers has announced that it will allow entry to the citizens
of Croatia, Serbia, and Montenegro as of June 1, 2020. There is [still a ban
to entry for non-resident foreign nationals.](https://ba.usembassy.gov/covid-19-information/)
visa_quarantine:
- Both the Republika Srpska and the Federation have [abolished self-isolation
measures for people entering BiH.](https://ba.usembassy.gov/covid-19-information/).
travel:
domestic: partial
inbound: partial
inbound_allowed:
- HR
- RS
- ME
Prior to splitting travel.yaml
, it was consumed like this:
import TravelDefaults from '@/constants/travel.yaml';
export const Travel = TravelDefaults;
const { countries, checked_on } = Travel;
Now, the goal is to load all the separate YAML files simultaneously and consume them collectively (without individual imports). How can this be achieved in VUE using TypeScript?