Project

day_offs

0.0
The project is in a healthy, maintained state
Add day offs sources for different countries in a standardized manner
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.6
 Project Readme

DayOffs

Coverage Status
Add day offs sources for different countries in a standardized manner

DayOffs is a plugin system that allows you to easy create and register various sources about days off and use them in a standardized manner


Add own sources

When you subclass DayOffs::Sources::Base, you get helpful methods defined and all you need to do is to override the call method

module DayOffs::Sources
  class MySource < Base
    with_countries :RU, :BY # define supported countries
    with_years 2023, 2024 # define supported years
    with_name :super_source # define source name
    
    def call
      [
        DayOffs::DayOff.new(country, Date.civil(year))
      ] # you can access to target instance variables
    end
  end
  
  class MyAnotherSource < Base
    with_countries :BY
    with_years 2023, 2024
    with_name :another_source
    
    def call
      [
        DayOffs::DayOff.new(country, Date.civil(year))
      ]
    end
  end
end

Sources should return an array of objects DayOffs::DayOff it`s simple struct Struct.new(:country, :date)

A template was created for faster creation of sources. You can see an example of the created source.

Configuration

Add this line to your application's Gemfile:

gem 'day_offs'

Add source:

DayOffs.configure do |c|
  c.use_sources :super_source
end

Usage

DayOffs::RU.fetch(2023)
DayOffs::BY.fetch(2023, :another_source)