class GouvCalendarCompilator::DataFetcher

This is the Data Fetcher Object for the Gouv Data Compilator gem It manages the fetching of the needed data through the different sources

Public Instance Methods

fetch_national_days_off_data() click to toggle source

Method used to fetch national days off data from governement open data sources

# File lib/gouv_calendar_compilator/data_fetcher.rb, line 16
def fetch_national_days_off_data
  ndo_data_full = []
  ::GouvCalendarCompilator::DAYS_OFF_ZONES_MATCHING.each_key do |zone_name|
    zone_data = {}
    (::GouvCalendarCompilator::YEAR_START..::GouvCalendarCompilator::YEAR_END).each do |year|
      url = ::GouvCalendarCompilator::DAYS_OFF_API_BASE_URL + "#{zone_name}/#{year}.json"
      zone_data.merge!(::JSON.parse(::URI.parse(url).read))
    end
    ndo_data_full.push({ data: zone_data, zones: ::GouvCalendarCompilator::DAYS_OFF_ZONES_MATCHING[zone_name] })
  end
  ndo_data_full
end
fetch_school_holidays_data() click to toggle source

Method used to fetch school holidays data from governement open data sources

# File lib/gouv_calendar_compilator/data_fetcher.rb, line 30
def fetch_school_holidays_data
  ::JSON.parse(::URI.parse(::GouvCalendarCompilator::SCHOOL_HOLIDAYS_DATA_URL).read)
end