{"id":16068097,"url":"https://github.com/ged/schedulability","last_synced_at":"2025-04-11T03:50:31.510Z","repository":{"id":65988034,"uuid":"48627440","full_name":"ged/schedulability","owner":"ged","description":"A composable scheduling library for Ruby (git mirror)","archived":false,"fork":false,"pushed_at":"2020-03-04T18:44:19.000Z","size":111,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T01:51:08.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bitbucket.org/ged/schedulability","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ged.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-27T00:08:14.000Z","updated_at":"2021-11-28T23:35:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"f37ea28e-4f45-4f22-acba-a818092a6b04","html_url":"https://github.com/ged/schedulability","commit_stats":{"total_commits":53,"total_committers":4,"mean_commits":13.25,"dds":0.05660377358490565,"last_synced_commit":"22d4aecba586cc331657bbab4f78e0f71f19f8b2"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Fschedulability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Fschedulability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Fschedulability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Fschedulability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ged","download_url":"https://codeload.github.com/ged/schedulability/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339262,"owners_count":21087214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T06:08:32.005Z","updated_at":"2025-04-11T03:50:31.493Z","avatar_url":"https://github.com/ged.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schedulability\n\nhome\n: https://hg.sr.ht/~ged/Schedulability\n\ncode\n: https://hg.sr.ht/~ged/Schedulability\n\ndocs\n: https://deveiate.org/code/schedulability\n\ngithub\n: https://github.com/ged/schedulability\n\n\n## Description\n\nSchedulability is a library for describing scheduled time. You can specify one\nor more periods of time using a simple syntax, then combine them to describe\nmore-complex schedules.\n\n\n## Usage\n\nSchedules are represented with Schedulability::Schedule objects, which are\nempty by default:\n\n    schedule = Schedulability::Schedule.new\n    # =\u003e #\u003cSchedulability::Schedule:0x007ffcf2b982b8 (empty)\u003e\n\nAn empty Schedule has no time restrictions, and will match any time.\n\nTo specify matching times, you'll need to construct a Schedule with one or more\nperiods.\n\n\n### Periods\n\nA schedule is made up of zero or more positive periods, and zero or more\nnegative periods. A time is within the schedule if at least one positive period\nand no negative periods match it.\n\nPeriods are specified as a String that contains a comma-separated list of\nperiod descriptions. The string `\"never\"` can be specified to explicitly create\na schedule which will not match any time.\n\nA period description is of the form\n\n    [!] scale {range [range ...]} [scale {range [range ...]}]\n\nNegative periods begin with a `!`; you may also use `not` or `except` for\nreadability.\n\nScale must be one of nine different scales (or their equivalent codes):\n\n    Scale  | Scale | Valid Range Values\n           | Code  |\n    -------+-------+------------------------------------------------------\n    year   |  yr   | n     where n is a 4-digit integer\n    month  |  mo   | 1-12  or  jan, feb, mar, apr, may, jun, jul,\n           |       |           aug, sep, oct, nov, dec\n    week   |  wk   | 1-6\n    yday   |  yd   | 1-366\n    mday   |  md   | 1-31\n    wday   |  wd   | 1-7   or  sun, mon, tue, wed, thu, fri, sat\n    hour   |  hr   | 0-23  or  12am 1am-11am 12noon 12pm 1pm-11pm\n    minute |  min  | 0-59\n    second |  sec  | 0-59\n\nThe same scale type may be specified multiple times. Additional scales are\nunioned with the ranges defined by previous scales of the same type in the same\nsub-period.\n\nA `range` is specified in the form:\n\n    \u003crange value\u003e\nor\n\n    \u003crange value\u003e-\u003crange value\u003e\n\nFor two-value ranges, the range is defined as the period between the first and\nsecond `range value`s. Scales which are in seconds granularity are exclusive of\ntheir end value, but the rest are inclusive. For example, `hr {9am-5pm}` means\n9:00:00 AM until 4:59:59 PM, but `wd {Wed-Sat}` runs until one second before\nmidnight on Saturday.\n\nIf the first value is larger than the second value (e.g. `min {20-10}`), the\nrange wraps (except when the scale specification is `year`). For example,\n`month {9-2}` is the same as specifying `month {1-2 9-12}` or `month {1-2}\nmonth {9-12}` or even `month {Jan-Feb Sep-Dec}`.\n\nThe range specified by the single-value specification is implicitly between the\n`range value` and its next sequential whole value. For example, `hr {9}` is the\nsame as specifying `hr {9-10}`, `mday {15}` is the same as `mday {15-16}`, etc.\n\nNeither extra whitespace nor case are significant in a period description.\nScales must be specified either in long form (`year`, `month`, `week`, etc.) or\nin code form (`yr`, `mo`, `wk`, etc.). Scale forms may be mixed in a period\nstatement.\n\nValues for week days and months can be abbreviated to three characters\n(`Wednesday` == `Wed`, `September` == `Sep`).\n\n\n#### Period Examples\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ccode\u003ewd {Mon-Fri} hr {9am-4pm}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eMonday through Friday, 9am to 5pm\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003ewd {Mon Wed Fri} hr {9am-4pm}, wd{Tue Thu} hr {9am-2pm}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eMonday through Friday, 9:00:00am to 3:59:59pm on Monday, Wednesday, and\n\tFriday, and 9:00:00am to 1:59:59pm on Tuesday and Thursday\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003ewk {1 3 5} wd {Mon-Fri} hr {9am-5pm}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eMon-Fri 9:00:00am-4:59:59pm, on odd weeks in the month\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003emonth {Jan-Feb Nov-Dec}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eDuring Winter in the northern hemisphere.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003emo {Nov-Feb}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eThe same thing (Winter) as a wrapped range.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003enot mo {Mar-Oct}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eThe same thing (Winter) as a negative range.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003emo {jan feb nov dec}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eNorthern Winter as single months\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003emo {Jan Feb}, mo {Nov Dec}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eAlso Northern Winter.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003emo {Jan Feb} mo {Nov Dec}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eNorthern Winter.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003eminute { 0-29 }\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eThe first half of every hour.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003ehour { 12am - 12pm }\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eDuring the morning.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003esec {0-4 10-14 20-24 30-34 40-44 50-54}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eAlternating 5-second periods every hour.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003ewd {mon wed fri} hr {8am - 5pm}, except day {1}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eEvery Monday, Wednesday, and Friday from 8am until 4:59:59 PM, except on\n\tthe first of the month.\u003c/dd\u003e\n\n\u003cdt\u003e\u003ccode\u003ewd {1 3 5 7} min {0-29}, wd {2 4 6} min {30-59}\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003eEvery first half-hour on alternating week days, and the second half-hour the\n  rest of the week.\u003c/dd\u003e\n\u003c/dl\u003e\n\n\n### Schedule Objects\n\nSchedules are immutable after they're created, but they have mutator methods to\nallow you to compose the schedule you want by combining them, or by using\nmutator methods that return a changed copy of the original:\n\n    weekend = Schedulability::Schedule.parse( \"wd {Sat - Sun}\" )\n    weekdays = Schedulability::Schedule.parse( \"wd {Mon - Fri}\" )\n    work_hours = Schedulability::Schedule.parse( \"hour {9am - 5pm}\" )\n    off_hours = Schedulability::Schedule.parse( \"hour {5pm - 9am}\" )\n\n    ### Boolean operators\n    on_duty = weekdays | work_hours\n    off_duty = weekend + ( weekdays | off_hours )\n    # -or-\n    off_duty = ~on_duty\n\n    ### Exclusivity predicates\n    on_duty.overlaps?( off_duty )\n    # =\u003e false\n    on_duty.exclusive?( off_duty )\n    # =\u003e true\n\n    ### Time predicates\n    Time.now\n    # =\u003e 2015-12-22 12:05:44 -0800\n    on_duty.include?( Time.now )\n    # =\u003e true\n    on_duty.now?\n    # =\u003e true\n    off_duty.now?\n    # =\u003e false\n\n    ### Case equality (=== operator)\n    case Time.now\n    when on_duty\n        send_sms( \"Stuff happened.\" )\n    when off_duty\n        send_email( \"Stuff happened.\" )\n    end\n\n\n## Prerequisites\n\n* Ruby 2.2.0 or better\n\n\n## Installation\n\n    $ gem install schedulability\n\n\n## Contributing\n\nYou can check out the current development source with\n[Mercurial](https://bitbucket.org/ged/schedulability), or if you prefer Git, via\n[its Github mirror](https://github.com/ged/schedulability).\n\nAfter checking out the source, run:\n\n    $ rake newb\n\nThis task will install any missing dependencies, run the tests/specs,\nand generate the API documentation.\n\n\n## Authors\n\n- Michael Granger \u003cged@faeriemud.org\u003e\n- Mahlon E. Smith \u003cmahlon@martini.nu\u003e\n\n\n## License\n\nThis library borrows much of its schedule description syntax and several\nimplementation strategies from the Time::Period Perl module by Patrick Ryan,\nused under the terms of the Perl Artistic License.\n\n\u003e Patrick Ryan \u003cperl@pryan.org\u003e wrote it.\n\u003e Paul Boyd \u003cpboyd@cpan.org\u003e fixed a few bugs.\n\u003e\n\u003e Copyright (c) 1997 Patrick Ryan. All rights reserved. This Perl\n\u003e module uses the conditions given by Perl. This module may only\n\u003e be distributed and or modified under the conditions given by Perl.\n\nThe rest is:\n\nCopyright (c) 2015-2020, Michael Granger and Mahlon E. Smith\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice,\n  this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\n* Neither the name of the author/s, nor the names of the project's\n  contributors may be used to endorse or promote products derived from this\n  software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fged%2Fschedulability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fged%2Fschedulability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fged%2Fschedulability/lists"}