nine_to_five 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +3 -0
- data/lib/nine_to_five/railtie.rb +7 -0
- data/lib/nine_to_five/version.rb +3 -0
- data/lib/nine_to_five.rb +31 -0
- data/lib/tasks/nine_to_five_tasks.rake +4 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5c33398be3994060e1f418d9967decc9684f75f616b0f94c821ed6a9c0da7b4f
|
4
|
+
data.tar.gz: 6c8785d5ff963dad8ec25310c81668beaff3e7133358ce706fb04db6cd454e9c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 371a4d3aad1c95a38e7837006eb5f320e15ad8fed8a62dbad28aa27911b9ed45cd8b82808e8e713451468f9d3e86d72977f04e9b8e451e6ab196c32f85b71863
|
7
|
+
data.tar.gz: 6bd4c2860b19e6c02df36bbb11889d5ef0eef0cc2f159bc12390ffb0e9872f1810e6811c4f34de1f43eb7010c0ac08e4c1c6782a16dd667ffc4f9660853bfa80
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2022 Chris Oliver
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# NineToFive
|
2
|
+
|
3
|
+
Rails plugin to enforce business hours.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
To customize the response for outside of business hours, add the following to an intializer.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
NineToFive.start_hour = 9
|
11
|
+
NineToFive.end_hour = 17
|
12
|
+
NineToFive.response = "Please come back during business hours."
|
13
|
+
```
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem "nine_to_five"
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
```bash
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
```bash
|
29
|
+
$ gem install nine_to_five
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
Contribution directions go here.
|
34
|
+
|
35
|
+
## License
|
36
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/nine_to_five.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "nine_to_five/version"
|
2
|
+
require "nine_to_five/railtie"
|
3
|
+
|
4
|
+
module NineToFive
|
5
|
+
mattr_accessor :start_hour
|
6
|
+
@@start_hour = 9
|
7
|
+
|
8
|
+
mattr_accessor :end_hour
|
9
|
+
@@end_hour = 17
|
10
|
+
|
11
|
+
mattr_accessor :response
|
12
|
+
@@response = "Please come back during business hours."
|
13
|
+
|
14
|
+
class Middleware
|
15
|
+
def initialize(app)
|
16
|
+
@app = app
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
current_time = Time.current
|
21
|
+
start_time = current_time.change(hour: NineToFive.start_hour)
|
22
|
+
end_time = current_time.change(hour: NineToFive.end_hour)
|
23
|
+
|
24
|
+
if current_time.between? start_time, end_time
|
25
|
+
@app.call(env)
|
26
|
+
else
|
27
|
+
[403, {"Content-Type" => "text/html"}, [NineToFive.response]]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nine_to_five
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Oliver
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.4
|
27
|
+
description: Restricts your Rails app to only provide requests during business hours
|
28
|
+
using a Rack middleware
|
29
|
+
email:
|
30
|
+
- excid3@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/nine_to_five.rb
|
39
|
+
- lib/nine_to_five/railtie.rb
|
40
|
+
- lib/nine_to_five/version.rb
|
41
|
+
- lib/tasks/nine_to_five_tasks.rake
|
42
|
+
homepage: https://github.com/excid3/nine_to_five
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/excid3/nine_to_five
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.3.7
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Rails plugin to enforce business hours.
|
66
|
+
test_files: []
|