Project

crntb

0.0
No commit activity in last 3 years
No release in over 3 years
Simple crontab parser written by ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.16
>= 0
~> 10.0
 Project Readme

Inspired by http://crontab.homecoded.com/

Convert crontab lines to other format.

Install

$ git clone https://github.com/litencatt/crntb
$ cd /path/to/crntb
$ bundle install --path vendor/bundle

Usage

Convert a line.

Hash

.to_h

$ bin/console
[1] pry(main)> Crntb.parse("* * * * * foo.sh").to_h
=> {:minute=>"*", :hour=>"*", :day_of_month=>"*", :month=>"*", :day_of_week=>"*", :command=>"foo.sh"}

JSON

.to_json

[1] pry(main)> Crntb.parse("* * * * * foo.sh").to_json
=> "{\"minute\":\"*\",\"hour\":\"*\",\"day_of_month\":\"*\",\"month\":\"*\",\"day_of_week\":\"*\",\"command\":\"foo.sh\"}"

To Chef cron resource DSL

to_chef

[2] pry(main)> puts Crntb.parse("* * * * * foo.sh").to_chef
cron 'exec_foo.sh' do
  minute  "*"
  hour    "*"
  day     "*"
  month   "*"
  weekday "*"
  command "foo.sh"
end
=> nil

To Whenever DSL

.to_whenever

[3] pry(main)> puts Crntb.parse("* * * * * foo.sh").to_whenever
every '* * * * *' do
  command "foo.sh"
end
=> nil

To English

.to_eng

[2] pry(main)> Crntb.parse("* * * * * foo.sh").to_eng
=> "every minute of every hour of every day, Execute \"foo.sh\""

To Markdown

.to_md

[3] pry(main)> Crntb.parse("* * * * * foo.sh").to_md
=> "## Summary\nevery minute of every hour of every day, Execute \"foo.sh\"\n\n### Command\n```\nfoo.sh\n```\n### Fields\n\n| fields | minute | hour |day_of_month | month | day_of_week |\n| --- | :---: | :---: | :---: | :---: | :---: |\n| value | *  | * | * | * | * |\n"

Summary

every minute of every hour of every day, Execute "foo.sh"

Command

foo.sh

Fields

fields minute hour day_of_month month day_of_week
value * * * * *

Convert crontabs written in a file.

$ bin/console
[1] pry(main)> Crntb.parse_file("./sample.cron").map{|e| pp e.to_json }