gouv-calendar-compilator 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Gouvernement Calendar Data Compilator
2
+
3
+ This library fetches data from the governement sources and APIs for national days off and school holidays, and compile it into a JSON file.
4
+
5
+ # Library usage
6
+
7
+ Add the gem to your Gemfile or \*.gemspec file:
8
+
9
+ gem 'gouv-calendar-compilator'
10
+
11
+ Then use it:
12
+
13
+ require 'gouv-calendar-compilator'
14
+
15
+ Wherever you wanna use the data, create a new GouvCalendarCompilator::DataCompilator object and call the `compile` method like so:
16
+ ```
17
+ data_compilator = GouvCalendarCompilator::DataCompilator.new
18
+ data_compilator.compile
19
+ ```
20
+
21
+ The compile method will return a ruby Array of Hashes where each Hash represents a period of time containing the data formatted like so:
22
+ ```
23
+ [
24
+ {
25
+ start: "2021-10-10",
26
+ end: "2021-10-11",
27
+ coefficient: 0
28
+ },
29
+ ...
30
+ ]
31
+ ```
32
+
33
+ **start** is a string containing the beginning date of the period of time (should always be the same than the previous period of time **end** field)
34
+ **end** is a string containing the date of the day after the end of the period of time
35
+ **coefficient** is an integer (possible values 0, 1, 2) representing the type of period it is, correspnding to:
36
+
37
+ 0 = Working Day
38
+ 1 = School Holidays
39
+ 2 = Holiday
40
+
41
+ # Contributing
42
+
43
+ Thanks to think of contributing.
44
+
45
+ We are open to contributions. Please feal free to create an issue covering what you wanted to do and
46
+ to create a PR directed to the develop branch for it to be accepted.
47
+
48
+ We do not have clear development roadmap, because we will contribute to this project on the need for
49
+ us. This won't prevent to have time answering to your needs, and welcome test cases or other bug reports.
50
+
51
+ Please:
52
+
53
+ - respect each others (take example to existing [code of conducts like the one of Atom for example](https://github.com/atom/atom/blob/master/CODE_OF_CONDUCT.md)).
54
+ - do not use issues or PR comments for anything else than the purpose of this project.
55
+
56
+ We will use censorship when a comment is deemed (by us - project managers) as inappropriate (Trolling,
57
+ insults or any other non-productive discussions which does not deserve to be stored).
@@ -0,0 +1,8 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ require 'gouv_calendar_compilator'
@@ -0,0 +1,74 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ require 'open-uri'
9
+ require 'json'
10
+
11
+ module GouvCalendarCompilator
12
+ # This is the Data Compilator Object for the Gouv Data Compilator gem
13
+ # It manages the compilation of different data sources and compile them into
14
+ # a new, properly formatted one
15
+ class DataCompilator
16
+ # Initializer for Data Compiler class.
17
+ def initialize
18
+ @sh_data_compiler = ::GouvCalendarCompilator::France::SchoolHolidaysDataCompilator.new
19
+ @ndo_data_compiler = ::GouvCalendarCompilator::France::NationalDaysOffDataCompilator.new
20
+ end
21
+
22
+ # This is the method you want to call to compile the sources into a proper dataset.
23
+ # It returns a ruby Array of Hashes
24
+ def compile
25
+ sh_calendar_data = @sh_data_compiler.compile
26
+ ndo_and_sh_data = self.class.sort_calendar_data(@ndo_data_compiler.compile(sh_calendar_data))
27
+ self.class.fill_operating_days(ndo_and_sh_data)
28
+ end
29
+
30
+ # Sorts calendar data by date
31
+ def self.sort_calendar_data(calendar)
32
+ calendar.each_key do |zone_name|
33
+ calendar[zone_name].sort_by! { |rec| ::Date.parse(rec[:start]) }
34
+ end
35
+ calendar
36
+ end
37
+
38
+ # Fill in the gaps in school holidays + national days off calendar with operatiog periods
39
+ def self.fill_operating_days(calendar)
40
+ calendar = sort_calendar_data(calendar)
41
+ calendar.each_key do |zone|
42
+ new_entries = []
43
+ calendar[zone].each_with_index do |vacation_period, index|
44
+ current_end_date = ::Date.parse(vacation_period[:end])
45
+ if calendar[zone][index + 1].nil?
46
+ if (current_end_date...::GouvCalendarCompilator::DATETIME_END).count > 1
47
+ new_entries.push(
48
+ {
49
+ start: current_end_date.to_date.to_s,
50
+ end: (::GouvCalendarCompilator::DATETIME_END + 1).to_date.to_s,
51
+ coefficient: ::GouvCalendarCompilator::OPERATING_DAY
52
+ }
53
+ )
54
+ end
55
+ else
56
+ next_start_date = ::Date.parse(calendar[zone][index + 1][:start])
57
+
58
+ if (current_end_date...next_start_date).count >= 1
59
+ new_entries.push(
60
+ {
61
+ start: current_end_date.to_date.to_s,
62
+ end: next_start_date.to_date.to_s,
63
+ coefficient: ::GouvCalendarCompilator::OPERATING_DAY
64
+ }
65
+ )
66
+ end
67
+ end
68
+ end
69
+ calendar[zone] += new_entries
70
+ end
71
+ calendar
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,111 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ module GouvCalendarCompilator
9
+ module France
10
+ # Data compiler class for national days off
11
+ class NationalDaysOffDataCompilator
12
+ # Initializer for France National Days off Compiler class.
13
+ def initialize
14
+ @data_fetcher = ::GouvCalendarCompilator::DataFetcher.new
15
+ end
16
+
17
+ # This is the method you want to call to compile the sources into a proper dataset.
18
+ # It returns a ruby Array of Hashes
19
+ #
20
+ # @param calendar Array<Hash> : previously formatted has of School holidays
21
+ def compile(calendar)
22
+ @data_fetcher.fetch_national_days_off_data.each do |zone_specific_ndo_data|
23
+ calendar = ndo_parse_data_region(
24
+ zone_specific_ndo_data[:data],
25
+ zone_specific_ndo_data[:zones],
26
+ ::GouvCalendarCompilator::DataCompilator.sort_calendar_data(calendar)
27
+ )
28
+ end
29
+
30
+ calendar
31
+ end
32
+
33
+ private
34
+
35
+ # NATIONAL DAYS OFF DEDICATED FUNCTIONS
36
+ def ndo_parse_data_region(ndo_dataset, targeted_zones, existing_calendar)
37
+ ndo_dataset.each_key do |day_off|
38
+ existing_calendar = ndo_insert_day_off_date_in_calendar(
39
+ ::Date.parse(day_off),
40
+ targeted_zones,
41
+ existing_calendar
42
+ )
43
+ end
44
+ existing_calendar
45
+ end
46
+
47
+ # Splits the periods of time when a national day off falls into a school holiday period
48
+ def ndo_split_holidays_period_insert_day_off(holidays_period, day_off_date)
49
+ [
50
+ {
51
+ start: holidays_period[:start],
52
+ end: day_off_date.to_s,
53
+ coefficient: ::GouvCalendarCompilator::SCHOOL_HOLIDAYS
54
+ },
55
+ {
56
+ start: day_off_date.to_s,
57
+ end: (day_off_date + 1).to_s,
58
+ coefficient: ::GouvCalendarCompilator::NATIONAL_DAY_OFF
59
+ },
60
+ {
61
+ start: (day_off_date + 1).to_s,
62
+ end: (::Date.parse(holidays_period[:end]) + 1).to_s,
63
+ coefficient: ::GouvCalendarCompilator::SCHOOL_HOLIDAYS
64
+ }
65
+ ]
66
+ end
67
+
68
+ # checks if the given date already exists in the generated calendar for the given zones
69
+ def ndo_insert_day_off_date_in_calendar(day_off_date, zones, calendar)
70
+ zones.each do |zone_name|
71
+ included_in_vacation = false
72
+ calendar[zone_name].each_with_index do |vacation_period, index|
73
+ start_date = ::Date.parse(vacation_period[:start])
74
+ end_date = ::Date.parse(vacation_period[:end])
75
+ date_range = (start_date...end_date)
76
+ unless date_range.include?(day_off_date) &&
77
+ vacation_period[:coefficient] != ::GouvCalendarCompilator::NATIONAL_DAY_OFF
78
+
79
+ next
80
+ end
81
+
82
+ included_in_vacation = true
83
+ splitted_vacation = ndo_split_holidays_period_insert_day_off(calendar[zone_name][index], day_off_date)
84
+
85
+ # replacing current holiday with the first part of the splitted one
86
+ # except if day off is first day of holiday (then deleting the first part of the splitted vacation)
87
+ if calendar[zone_name][index][:start] == day_off_date.to_s
88
+ calendar[zone_name].delete(calendar[zone_name][index])
89
+ else
90
+ calendar[zone_name][index] = splitted_vacation[0]
91
+ end
92
+ # inserting national day off
93
+ calendar[zone_name] << splitted_vacation[1]
94
+ # inserting other part of the splitted vacation
95
+ calendar[zone_name] << splitted_vacation[2]
96
+ end
97
+
98
+ # if day off not in the middle of a vacation period, simply insert it inside the dataset
99
+ next if included_in_vacation
100
+
101
+ calendar[zone_name] << {
102
+ start: day_off_date.to_s,
103
+ end: (day_off_date + 1).to_s,
104
+ coefficient: ::GouvCalendarCompilator::NATIONAL_DAY_OFF
105
+ }
106
+ end
107
+ calendar
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,143 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ module GouvCalendarCompilator
9
+ module France
10
+ # Manages the compilation of different school holidays data sources and compile them into
11
+ # a new, properly formatted one
12
+ class SchoolHolidaysDataCompilator
13
+ # Initializer for School Holidays data compiler
14
+ def initialize
15
+ @data_fetcher = ::GouvCalendarCompilator::DataFetcher.new
16
+ end
17
+
18
+ # This is the method you want to call to compile the school holidays into a proper dataset.
19
+ # It returns a ruby Array of Hashes
20
+ def compile
21
+ school_holidays_data_full = @data_fetcher.fetch_school_holidays_data
22
+ school_holidays_data_trimmed = sh_trim_not_necessary_data(school_holidays_data_full)
23
+ zones = sh_define_possible_zones(school_holidays_data_trimmed)
24
+ sh_format_zones_data(school_holidays_data_trimmed, zones, school_holidays_data_full)
25
+ end
26
+
27
+ private
28
+
29
+ # Calculates an approximate end date based on same vacations, for same region of the world, from an other year
30
+ def calculate_approximate_end_date(trimmed_dataset, raw_dataset, vacation_index)
31
+ vacation_type = trimmed_dataset[vacation_index]['fields']['description']
32
+ vacation_location = trimmed_dataset[vacation_index]['fields']['location']
33
+
34
+ filtered_data =
35
+ raw_dataset.select do |record|
36
+ record['fields']['description'] == vacation_type && record['fields']['location'] == vacation_location
37
+ end
38
+ date_range = nil
39
+
40
+ filtered_data.each do |vacation|
41
+ next unless vacation['fields']['end_date']
42
+
43
+ start_date = ::Date.parse(vacation['fields']['start_date'])
44
+ end_date = ::Date.parse(vacation['fields']['end_date'])
45
+ date_range = (start_date...end_date)
46
+ break
47
+ end
48
+
49
+ approximate_end_date = ::Date.parse(trimmed_dataset[vacation_index]['fields']['start_date']) + date_range.count
50
+ approximate_end_date.to_date.to_s
51
+ end
52
+
53
+ # Calculates an approximate start date based on same vacations, for same region of the world, from an other year
54
+ def calculate_approximate_start_date(trimmed_dataset, raw_dataset, vacation_index)
55
+ vacation_type = trimmed_dataset[vacation_index]['fields']['description']
56
+ vacation_location = trimmed_dataset[vacation_index]['fields']['location']
57
+
58
+ filtered_data =
59
+ raw_dataset.select do |record|
60
+ record['fields']['description'] == vacation_type && record['fields']['location'] == vacation_location
61
+ end
62
+ date_range = nil
63
+
64
+ filtered_data.each do |vacation|
65
+ next unless vacation['fields']['start_date'] && vacation['fields']['description'] == vacation_type
66
+
67
+ start_date = ::Date.parse(vacation['fields']['start_date'])
68
+ end_date = ::Date.parse(vacation['fields']['end_date'])
69
+ date_range = (start_date...end_date)
70
+ break
71
+ end
72
+
73
+ approximate_start_date = ::Date.parse(trimmed_dataset[vacation_index]['fields']['end_date']) - date_range.count
74
+ approximate_start_date.to_date.to_s
75
+ end
76
+
77
+ # Trims dataset to desired time era
78
+ def sh_trim_not_necessary_data(raw_sh_dataset)
79
+ date_range = ::GouvCalendarCompilator::DATETIME_START...::GouvCalendarCompilator::DATETIME_END
80
+ filtered_data =
81
+ raw_sh_dataset.select do |record|
82
+ date_range.include?(::Date.parse(record['fields']['start_date'])) &&
83
+ (record['fields']['end_date'] ? date_range.include?(::Date.parse(record['fields']['end_date'])) : true)
84
+ end
85
+ filtered_data.uniq do |record|
86
+ [
87
+ record['fields']['start_date'],
88
+ record['fields']['description'],
89
+ record['fields']['zones']
90
+ ].join(':')
91
+ end
92
+ end
93
+
94
+ # Returns an array of strings corresponding to each of the existing zones in the school holidays dataset
95
+ def sh_define_possible_zones(school_holidays)
96
+ zones = []
97
+ school_holidays.each do |record|
98
+ zones << record['fields']['zones']
99
+ end
100
+ zones.uniq
101
+ end
102
+
103
+ # Returns the formatted school holidays data for all zones
104
+ def sh_format_zones_data(school_holidays, zones, sh_data_full)
105
+ formatted_zones_data = {}
106
+ zones.each do |zone_name|
107
+ zone_specific_holidays_data = school_holidays.select { |record| record['fields']['zones'] == zone_name }
108
+ zone_specific_holidays_data_full = sh_data_full.select { |record| record['fields']['zones'] == zone_name }
109
+ records_contianer = []
110
+ zone_specific_holidays_data.each_with_index do |holiday_record, index|
111
+ holiday_start_date = (if holiday_record['fields']['start_date'].nil?
112
+ calculate_approximate_start_date(
113
+ zone_specific_holidays_data,
114
+ zone_specific_holidays_data_full,
115
+ index
116
+ )
117
+ else
118
+ ::Date.parse(holiday_record['fields']['start_date']).to_s
119
+ end)
120
+ holiday_end_date = (if holiday_record['fields']['end_date'].nil?
121
+ calculate_approximate_end_date(
122
+ zone_specific_holidays_data,
123
+ zone_specific_holidays_data_full,
124
+ index
125
+ )
126
+ else
127
+ (::Date.parse(holiday_record['fields']['end_date']) + 1).to_s
128
+ end)
129
+ records_contianer.push(
130
+ {
131
+ start: holiday_start_date,
132
+ end: holiday_end_date,
133
+ coefficient: ::GouvCalendarCompilator::SCHOOL_HOLIDAYS
134
+ }
135
+ )
136
+ end
137
+ formatted_zones_data[zone_name] = records_contianer
138
+ end
139
+ formatted_zones_data
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,34 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ require 'open-uri'
9
+ require 'json'
10
+
11
+ module GouvCalendarCompilator
12
+ # This is the Data Fetcher Object for the Gouv Data Compilator gem
13
+ # It manages the fetching of the needed data through the different sources
14
+ class DataFetcher
15
+ # Method used to fetch national days off data from governement open data sources
16
+ def fetch_national_days_off_data
17
+ ndo_data_full = []
18
+ ::GouvCalendarCompilator::DAYS_OFF_ZONES_MATCHING.each_key do |zone_name|
19
+ zone_data = {}
20
+ (::GouvCalendarCompilator::YEAR_START..::GouvCalendarCompilator::YEAR_END).each do |year|
21
+ url = ::GouvCalendarCompilator::DAYS_OFF_API_BASE_URL + "#{zone_name}/#{year}.json"
22
+ zone_data.merge!(::JSON.parse(::URI.parse(url).read))
23
+ end
24
+ ndo_data_full.push({ data: zone_data, zones: ::GouvCalendarCompilator::DAYS_OFF_ZONES_MATCHING[zone_name] })
25
+ end
26
+ ndo_data_full
27
+ end
28
+
29
+ # Method used to fetch school holidays data from governement open data sources
30
+ def fetch_school_holidays_data
31
+ ::JSON.parse(::URI.parse(::GouvCalendarCompilator::SCHOOL_HOLIDAYS_DATA_URL).read)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Copyright (C) 2021 - Octopus Lab SAS
5
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
6
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
7
+ #++
8
+ module GouvCalendarCompilator
9
+ module ZoneDepartmentMatching
10
+ FRANCE = {
11
+ '01': 'Zone A',
12
+ '02': 'Zone B',
13
+ '03': 'Zone A',
14
+ '04': 'Zone B',
15
+ '05': 'Zone B',
16
+ '06': 'Zone B',
17
+ '07': 'Zone A',
18
+ '08': 'Zone B',
19
+ '09': 'Zone C',
20
+ '10': 'Zone B',
21
+ '11': 'Zone C',
22
+ '12': 'Zone C',
23
+ '13': 'Zone B',
24
+ '14': 'Zone B',
25
+ '15': 'Zone A',
26
+ '16': 'Zone A',
27
+ '17': 'Zone A',
28
+ '18': 'Zone B',
29
+ '19': 'Zone A',
30
+ '21': 'Zone A',
31
+ '22': 'Zone B',
32
+ '23': 'Zone A',
33
+ '24': 'Zone A',
34
+ '25': 'Zone A',
35
+ '26': 'Zone A',
36
+ '27': 'Zone B',
37
+ '28': 'Zone B',
38
+ '29': 'Zone B',
39
+ '2a': 'Corse',
40
+ '2b': 'Corse',
41
+ '30': 'Zone C',
42
+ '31': 'Zone C',
43
+ '32': 'Zone C',
44
+ '33': 'Zone A',
45
+ '34': 'Zone C',
46
+ '35': 'Zone B',
47
+ '36': 'Zone B',
48
+ '37': 'Zone B',
49
+ '38': 'Zone A',
50
+ '39': 'Zone A',
51
+ '40': 'Zone A',
52
+ '41': 'Zone B',
53
+ '42': 'Zone A',
54
+ '43': 'Zone A',
55
+ '44': 'Zone B',
56
+ '45': 'Zone B',
57
+ '46': 'Zone C',
58
+ '47': 'Zone A',
59
+ '48': 'Zone C',
60
+ '49': 'Zone B',
61
+ '50': 'Zone B',
62
+ '51': 'Zone B',
63
+ '52': 'Zone B',
64
+ '53': 'Zone B',
65
+ '54': 'Zone B',
66
+ '55': 'Zone B',
67
+ '56': 'Zone B',
68
+ '57': 'Zone B',
69
+ '58': 'Zone A',
70
+ '59': 'Zone B',
71
+ '60': 'Zone B',
72
+ '61': 'Zone B',
73
+ '62': 'Zone B',
74
+ '63': 'Zone A',
75
+ '64': 'Zone A',
76
+ '65': 'Zone C',
77
+ '66': 'Zone C',
78
+ '67': 'Zone B',
79
+ '68': 'Zone B',
80
+ '69': 'Zone A',
81
+ '70': 'Zone A',
82
+ '71': 'Zone A',
83
+ '72': 'Zone B',
84
+ '73': 'Zone A',
85
+ '74': 'Zone A',
86
+ '75': 'Zone C',
87
+ '76': 'Zone B',
88
+ '77': 'Zone C',
89
+ '78': 'Zone C',
90
+ '79': 'Zone A',
91
+ '80': 'Zone B',
92
+ '81': 'Zone C',
93
+ '82': 'Zone C',
94
+ '83': 'Zone B',
95
+ '84': 'Zone B',
96
+ '85': 'Zone B',
97
+ '86': 'Zone A',
98
+ '87': 'Zone A',
99
+ '88': 'Zone B',
100
+ '89': 'Zone A',
101
+ '90': 'Zone A',
102
+ '91': 'Zone C',
103
+ '92': 'Zone C',
104
+ '93': 'Zone C',
105
+ '94': 'Zone C',
106
+ '95': 'Zone C',
107
+ '971': 'Guadeloupe',
108
+ '972': 'Martinique',
109
+ '973': 'Guyane',
110
+ '974': 'Réunion',
111
+ '975': 'Saint Pierre et Miquelon',
112
+ '976': 'Mayotte',
113
+ '977': 'Saint-Barthélemy',
114
+ '978': 'Saint-Martin',
115
+ '986': 'Wallis et Futuna',
116
+ '987': 'Polynésie',
117
+ '988': 'Nouvelle Calédonie',
118
+ '984': 'Terres australes et antarctiques françaises',
119
+ '989': 'Clipperton'
120
+ }.freeze
121
+ public_constant :FRANCE
122
+ end
123
+ end
@@ -0,0 +1,62 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ # The GouvCalendarCompilator Module
9
+ # Compiles School Holidays Data and National Days Off data from Government sources into a new dataset
10
+ # and returns it as an Array of Hashes
11
+ module GouvCalendarCompilator
12
+ YEAR_START = 2020
13
+ public_constant :YEAR_START
14
+ YEAR_END = (::Date.today.year + 1)
15
+ public_constant :YEAR_END
16
+ SCHOOL_HOLIDAYS_DATA_URL = 'https://www.data.gouv.fr/fr/datasets/r/000ae493-9fa8-4088-9f53-76d375204036'
17
+ public_constant :SCHOOL_HOLIDAYS_DATA_URL
18
+ DAYS_OFF_API_BASE_URL = 'https://calendrier.api.gouv.fr/jours-feries/'
19
+ public_constant :DAYS_OFF_API_BASE_URL
20
+
21
+ DAYS_OFF_ZONES_MATCHING = {
22
+ guadeloupe: ['Guadeloupe'],
23
+ guyane: ['Guyane'],
24
+ 'la-reunion': ['Réunion'],
25
+ martinique: ['Martinique'],
26
+ mayotte: ['Mayotte'],
27
+ metropole: ['Zone A', 'Zone B', 'Zone C', 'Corse'],
28
+ 'nouvelle-caledonie': ['Nouvelle Calédonie'],
29
+ 'polynesie-francaise': ['Polynésie'],
30
+ 'saint-pierre-et-miquelon': ['Saint Pierre et Miquelon'],
31
+ 'wallis-et-futuna': ['Wallis et Futuna']
32
+ }.freeze
33
+
34
+ public_constant :DAYS_OFF_ZONES_MATCHING
35
+
36
+ OPERATING_DAY = 0
37
+ public_constant :OPERATING_DAY
38
+ SCHOOL_HOLIDAYS = 1
39
+ public_constant :SCHOOL_HOLIDAYS
40
+ NATIONAL_DAY_OFF = 2
41
+ public_constant :NATIONAL_DAY_OFF
42
+ WEEK_END = 3
43
+ public_constant :WEEK_END
44
+
45
+ DATETIME_START = ::Date.parse("#{::GouvCalendarCompilator::YEAR_START}-01-01T00:00:00").freeze
46
+ public_constant :DATETIME_START
47
+ DATETIME_END = ::Date.parse("#{::GouvCalendarCompilator::YEAR_END}-12-31T23:59:59").freeze
48
+ public_constant :DATETIME_END
49
+ ONE_SECOND = (1.0 / (60 * 24 * 24))
50
+ public_constant :ONE_SECOND
51
+ # Base error class for all of the errors raised by this library.
52
+ class Error < StandardError; end
53
+
54
+ # Error related to bad argument given to a method.
55
+ class ArgumentError < Error; end
56
+ end
57
+
58
+ require 'gouv_calendar_compilator/data_compilator'
59
+ require 'gouv_calendar_compilator/data_fetcher'
60
+ require 'gouv_calendar_compilator/data_compilators/france/school_holidays_data_compilator'
61
+ require 'gouv_calendar_compilator/data_compilators/france/national_days_off_data_compilator'
62
+ require 'gouv_calendar_compilator/zone_department_matching/france'
data/lib/version.rb ADDED
@@ -0,0 +1,11 @@
1
+ #--
2
+ # Copyright (C) 2021 - Octopus Lab SAS
3
+ # All rights are described by the GPLv3 license present in the file /LICENSE available in the
4
+ # original repository of this file or [here](https://www.gnu.org/licenses/gpl-3.0.fr.html).
5
+ #++
6
+ # frozen_string_literal: true
7
+
8
+ module GouvCalendarCompilator
9
+ VERSION = '0.0.2'
10
+ public_constant :VERSION
11
+ end