
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
By Magnetis
Spok is a tool for dealing with workdays and restdays in an easy way. It also provides functionalities for working with periods of dates.
Add this line to your application's Gemfile:
gem 'spok'
And then execute:
$ bundle
Or install it yourself as:
$ gem install spok
NOTE: All methods available on Spok::Workday
now are available on Spok
interface, Spok::Workday
still works but we have plans to make Spok:: Workday
a private resource, you should update your code to rely on Spok
interface.
You can use the Spok to check if a date is either a rest day or a workday:
require 'spok'
Spok.restday?(Date.new(2012, 12, 24))
# => false
Spok.workday?(Date.new(2012, 12, 24))
# => true
Spok also supports different calendars for checking if a date is a workday or a restday.
require 'spok'
Spok.workday?(Date.new(2012, 12, 24), calendar: :bovespa)
# => false
If calendar
is not informed, it will default to the :brazil
calendar.
The available calendars are defined with .yml
files here.
Objects from the Spok
class can be used to work with periods of dates. You can
initialize a new object passing the start and end date for your period to the
new
method:
require 'spok'
period = Spok.new(Date.new(2018, 9, 14), Date.new(2018, 10, 14))
another_period = Spok.new(Date.today, Date.today + 10.days)
You can also use the Spok.parse
method to initialize a new object using a string:
require 'spok'
parsed_period = Spok.parse('20180901-20180903')
With the object, you can check for all the workdays in that period of dates:
require 'spok'
period = Spok.new(Date.new(2018, 10, 10), Date.new(2018, 10, 14))
period.workdays
# => [Wed, 10 Oct 2018, Thu, 11 Oct 2018]
Spok.default_calendar = :bovespa
If you need to add your own restday calendar, call Spok.add_calendar
on your
application boot:
Spok.add_calendar(:custom_calendar, './config/calendars/custom.yml')
The complete documentation in the RDoc format is available here:
https://www.rubydoc.info/gems/spok
Please read our Contributing guide for more information.
This project is licensed under the terms of the Apache 2. Copyright 2014-2018 Magnetis http://www.magnetis.com.br See the LICENSE file for license rights and limitations (Apache 2).
FAQs
Unknown package
We found that spok demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.