Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/dynamic-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: update-security

on:
push:
paths:
- SECURITY.md
branches:
- main
workflow_dispatch:

jobs:
update-security:
permissions:
contents: write
pull-requests: write
pages: write
uses: thoughtbot/templates/.github/workflows/dynamic-security.yaml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignore:
- 'lib/generators/michel/view/templates/view_migration.rb':
- Layout/InitialIndentation
- Layout/TrailingEmptyLines
- Layout/TrailingWhitespace
134 changes: 4 additions & 130 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,132 +1,6 @@
# Contributor Covenant Code of Conduct
# Code of conduct

## Our Pledge
By participating in this project, you agree to abide by the
[thoughtbot code of conduct][1].

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
[1]: https://thoughtbot.com/open-source-code-of-conduct
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing

We love contributions from everyone.
By participating in this project,
you agree to abide by the thoughtbot [code of conduct].

[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct

We expect everyone to follow the code of conduct
anywhere in thoughtbot's project codebases,
issue trackers, chatrooms, and mailing lists.

## Contributing Code

$(INSTALL_DEPENDENCIES)

Fork the repo.

Make sure the tests pass:

$(TEST_RUNNER)

Make your change, with new passing tests. Follow the [style guide][style].

[style]: https://github.com/thoughtbot/guides/tree/master/style

Mention how your changes affect the project to other developers and users in the
`NEWS.md` file.

Push to your fork. Write a [good commit message][commit]. Submit a pull request.

[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

Others will give constructive feedback.
This is a time for discussion and improvements,
and making the necessary changes will be required before we can
merge the contribution.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ gem "pg", "~> 1.1"
gem "bundler-audit", ">= 0.7.0", require: false
gem "database_cleaner"
gem "ammeter"
gem "debug"
gem "scenic"
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ GEM
database_cleaner-core (~> 2.0)
database_cleaner-core (2.0.1)
date (3.5.1)
debug (1.11.1)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.6.2)
drb (2.2.3)
erb (6.0.1)
Expand Down Expand Up @@ -310,10 +313,12 @@ DEPENDENCIES
ammeter
bundler-audit (>= 0.7.0)
database_cleaner
debug
michel!
pg (~> 1.1)
rails (~> 8.0.2, >= 8.0.2.1)
rake (~> 13.0)
scenic
standardrb

BUNDLED WITH
Expand Down
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
The MIT License

Copyright (c) thoughtbot, inc.
Copyright (c) Sally Hall and thoughtbot, inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
51 changes: 51 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# News

All notable changes to this project will be documented in this file.

The format is loosely based on [Keep a Changelog] and this project adheres to
[Semantic Versioning].

[Keep a Changelog]: http://keepachangelog.com/
[Semantic Versioning]: http://semver.org/

## [Unreleased]

### Added

- This is for new features.

### Changed

- This is for changes in existing functionality.

### Deprecated

- This is for once-stable features removed in upcoming releases.

### Removed

- This is for deprecated features removed in this release.

### Fixed

- This is for any bug fixes.

### Security

- This is to invite users to upgrade in case of vulnerabilities.

[Unreleased]: https://github.com/thoughtbot/michel/compare/v0.2.0...HEAD

## [0.0.2] - 2016-02-01

### Added

- This version to show how each version title is linked (`## [0.0.2]`).

[0.2.0]: https://github.com/thoughtbot/michel/compare/v0.1.0...v0.2.0

## 0.0.1 - 2016-01-01

### Added

- This `NEWS.md` file.
77 changes: 57 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,76 @@
# Michel

TODO: Delete this and the text below, and describe your gem
Find available time slots quickly with a materialized view.

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/michel`. To experiment with that code, run `bin/console` for an interactive prompt.
## Usage

## Installation
### Install Michel
In order to run the migrations, you must also install Scenic. Add to your gemfile:

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
```
gem "michel"
gem "scenic"
```

Install the gem and add to the application's Gemfile by executing:
Run `bundle install`, then `rails generate michel:install`

```bash
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
```
### Configure
Configure the class names in `config/initializers/michel.rb`

If bundler is not being used to manage dependencies, install the gem by executing:
Michel expects three classes to exist in the application:
* Resource Class
* The resource that is occupied by a booking, ex: Physician, Room, Instructor.
* This resource is assumed to be available for only one booking at a time. A resource has many bookings and many availabilities.

```bash
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
```
* Booking Class
* The event that is scheduled for a resource, ex: Appointment.
* The resource is unavailable for the duration of the booking.
* It is required to have the following attributes:
* `start_time` - a DateTime indicating the start time of the booking.
* `duration` - an integer representing the number of minutes the booking lasts.
* a reference to the id of the resource class
* The booking class is also used to block off unavailable times. It is recommended that you have a booking type to distinguish between appointments and other events.
* Availability Class
* The weekly schedule during which a resource is available for a booking
* It is required to have the following attributes:
* `timezone` - a string representing the time zone in which the availability is configured, ex: 'UTC'
* `weekday` - an integer representing the weekday, starting with Monday = 1
* `start_time` - a string representing the beginning time of the availability in the configured timezone in 24-hour format, ex: '09:00'
* `end_time` - a string representing the end time of the availability in the configured timezone in 24-hour format, ex: '017:00'
* a reference to the id of the resource class
* There should be one availability record for each continuous block of available time during a week. For example, if a resource is available from 9-5, M-Th, with a 1 hour break from 12-1, that is represented by eight availabilities: one for each day from 9-12 and another for each day from 1-5.

## Usage

TODO: Write usage instructions here
### Run the generator
To generate the database view and necessary supporting code, run `rails generate michel:view`. This will:

1. Generate a migration to add an index to the booking class table on the resource id and start_time.
2. Generate a Scenic model for available time slots.
3. Generate a sql file with the view to back the scenic model.
4. Insert associations between the existing classes and the generated `AvailableTimeSlot` class.

## Development
Once the generator is finished, run `rails db:migrate` to run the generated migrations.

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
### Start Scheduling.
To find available time slots, search for matching `AvailableTimeSlots`. Each slot has a `start_time` and an `end_time` and belongs to an `availability` and a `resource`.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
To refresh the materialized view, run `AvailableTimeSlot.refresh`. The view should be refreshed when a booking is created, updated, or deleted, or when availability changes.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/michel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/michel/blob/main/CODE_OF_CONDUCT.md).
See the [CONTRIBUTING] document.
Thank you, [contributors]!

[CONTRIBUTING]: CONTRIBUTING.md
[contributors]: https://github.com/thoughtbot/michel/graphs/contributors

## License

Michel is Copyright (c) thoughtbot, inc.
It is free software, and may be redistributed
under the terms specified in the [LICENSE] file.

## Code of Conduct
[LICENSE]: /LICENSE

Everyone interacting in the Michel project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/michel/blob/main/CODE_OF_CONDUCT.md).
<!-- START /templates/footer.md -->
<!-- END /templates/footer.md -->
Loading