workpattern 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +8 -20
- data/.travis.yml +18 -12
- data/{CHANGELOG → CHANGELOG.md} +19 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +21 -0
- data/README.md +2 -27
- data/Rakefile +0 -0
- data/lib/workpattern.rb +5 -73
- data/lib/workpattern/clock.rb +0 -0
- data/lib/workpattern/constants.rb +72 -0
- data/lib/workpattern/day.rb +245 -0
- data/lib/workpattern/version.rb +1 -1
- data/lib/workpattern/week.rb +119 -296
- data/lib/workpattern/week_pattern.rb +144 -0
- data/lib/workpattern/workpattern.rb +73 -125
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- data/workpattern.gemspec +32 -20
- metadata +21 -33
- data/lib/workpattern/utility/base.rb +0 -27
- data/test/test_clock.rb +0 -29
- data/test/test_helper.rb +0 -2
- data/test/test_week.rb +0 -532
- data/test/test_workpattern.rb +0 -307
- data/test/test_workpattern_module.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32e6c1903732854fa9a9ae45a5c02ebb408391ce931e2b8b20b9c7f3f349bae0
|
4
|
+
data.tar.gz: 1a99b95b71dda679fe674a7ff83595cac0922afb39b1012cc0239aafbf57c486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c19219fa8b5f49ecb48e8072bc92143f688f4e2ed3edf32a11415e3d7e3b886e29d222818309ca2df570f95be68ed4d9c341d01fc43548b8302faa6a1a30052
|
7
|
+
data.tar.gz: 0247b415ada6052c16041a4ed18f3cbe28bc6af1d2dae3bc11f625fd50a77ca912ef52df46b98a3bb44858e6e50ec1a34799096821806de939e79e8c36765b4d
|
data/.gitignore
CHANGED
@@ -1,20 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
\#*
|
19
|
-
.#*
|
20
|
-
*.swp
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc/
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
data/.travis.yml
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
- 1.9.3
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
9
|
+
- 2.6
|
10
|
+
- ruby-head
|
11
|
+
- jruby-19mode
|
12
|
+
- jruby-head
|
13
|
+
deploy:
|
14
|
+
provider: rubygems
|
15
|
+
api_key:
|
16
|
+
secure: IXKBqbRf+2aDOpH+g0LpTtIzyagDqjHy6Bo/UYtLqR42CHZUnzre8AvCTvobB+BlHF9W+Igdaf3tzzY+A+XrTf38Iut+zsFI6KnkP7pN8pSMfcpuxZrLi0vd24QAHlHLCHIwsl4WfHj/swIRQGtlhvAV5mcTLW2rhE9/M6pGvRo=
|
17
|
+
gem: workpattern
|
18
|
+
on:
|
19
|
+
tags: true
|
20
|
+
repo: callenb/workpattern
|
data/{CHANGELOG → CHANGELOG.md}
RENAMED
@@ -1,3 +1,22 @@
|
|
1
|
+
## Workpattern v0.6.0 ( 25 Feb, 2021) ##
|
2
|
+
|
3
|
+
I stopped keeping this Changelog file update back when v0.5.0 was realeased on 19 Oct 2016 and now it is 10Feb 2021 and I'm playing catch-up.
|
4
|
+
I have created the following set of bullet point changes by going through my commit messages, the quality of which varies greatly.
|
5
|
+
A lot of the effort has been on making the code easier to read as it was a real mess.
|
6
|
+
Here is a chronological take on what I have been doing.
|
7
|
+
|
8
|
+
* removed test warnings by surrounding ambiguous negatives with parenthesis
|
9
|
+
* I think a bug was fixed by changing #wee_total and #total to just an attr_writer
|
10
|
+
* removed some duplicated code
|
11
|
+
* replaced a number of literals with constants which I put in their own file
|
12
|
+
* made a lot of the code easier to read, such as extracting to a method with a sensible name or renaming existing ones
|
13
|
+
* Workpattern is now tested on Ruby 1.9.3, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, ruby-head, jruby-19mode & jruby-head
|
14
|
+
* Created a Day class to remove the complexity from Week so Week deals with weeks and Day with a day
|
15
|
+
* My Clock class was replaced by Time or Date objects in all tests. Clock only used for internal stuff now.
|
16
|
+
* Switched to sorted_set rubygem after the SortedSet class was removed from Ruby in v3.x.
|
17
|
+
* Workpattern now works with ruby 3.0.1dev
|
18
|
+
* added Contributor Covenant Code of Conduct
|
19
|
+
|
1
20
|
## Workpattern v0.5.0 ( Oct 19, 2016) ##
|
2
21
|
|
3
22
|
* Workpattern now handles Timezones. It changes the date into UTC, does the calculation and then changes it back * Barrie Callender
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
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, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
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.
|
33
|
+
|
34
|
+
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.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
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 e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at barrie@callenb.org. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**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.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**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.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**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.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**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.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
workpattern (0.6.0)
|
5
|
+
sorted_set
|
6
|
+
tzinfo
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
concurrent-ruby (1.1.8)
|
12
|
+
minitest (5.14.4)
|
13
|
+
rake (13.0.3)
|
14
|
+
rbtree (0.4.4)
|
15
|
+
set (1.0.1)
|
16
|
+
sorted_set (1.0.3)
|
17
|
+
rbtree
|
18
|
+
set (~> 1.0)
|
19
|
+
tzinfo (2.0.4)
|
20
|
+
concurrent-ruby (~> 1.0)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
x86_64-linux
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
minitest (~> 5.0)
|
27
|
+
rake (~> 13.0)
|
28
|
+
workpattern!
|
29
|
+
|
30
|
+
BUNDLED WITH
|
31
|
+
2.2.9
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Barrie Callender
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Please use [Github Issues] to report bugs. If you have a question about the lib
|
|
9
9
|
|
10
10
|
## Getting Started
|
11
11
|
|
12
|
-
Workpattern is a library with no monkey-patching and
|
12
|
+
Workpattern is a library with no monkey-patching and was tested using [Travis](https://travis-ci.org) against the following Ruby versions `1.9.3`, `2.1`, `2.2`, `2.3`, `2.4`, `2.5`, `2.6`, `ruby-head (3.1.0dev)`, `jruby-19mode (9.2.9.0 (2.5.7)` and `jruby-head (9.3.0.0-SNAPSHOT (2.6.5)`.
|
13
13
|
|
14
14
|
You can install it using:
|
15
15
|
```sh
|
@@ -91,29 +91,4 @@ Workpattern.delete "My Workpattern"
|
|
91
91
|
|
92
92
|
# Delete all Workpatterns
|
93
93
|
Workpattern.clear
|
94
|
-
```
|
95
|
-
|
96
|
-
## License
|
97
|
-
|
98
|
-
(The MIT License)
|
99
|
-
|
100
|
-
Copyright (c) 2012 - 2016
|
101
|
-
|
102
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
103
|
-
a copy of this software and associated documentation files (the
|
104
|
-
'Software'), to deal in the Software without restriction, including
|
105
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
106
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
107
|
-
permit persons to whom the Software is furnished to do so, subject to
|
108
|
-
the following conditions:
|
109
|
-
|
110
|
-
The above copyright notice and this permission notice shall be
|
111
|
-
included in all copies or substantial portions of the Software.
|
112
|
-
|
113
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
114
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
115
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
116
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
117
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
118
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
119
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
94
|
+
```
|
data/Rakefile
CHANGED
File without changes
|
data/lib/workpattern.rb
CHANGED
@@ -7,12 +7,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__)) unless
|
|
7
7
|
$LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
|
+
require 'sorted_set' if RUBY_VERSION >= "2.4"
|
10
11
|
require 'date'
|
11
|
-
require 'workpattern/utility/base.rb'
|
12
12
|
require 'workpattern/clock'
|
13
|
-
|
13
|
+
require 'workpattern/constants'
|
14
|
+
require 'workpattern/day'
|
14
15
|
require 'workpattern/week'
|
15
16
|
require 'workpattern/workpattern'
|
17
|
+
require 'workpattern/week_pattern'
|
16
18
|
|
17
19
|
#
|
18
20
|
# workpattern.rb - date calculation library that takes into account patterns of
|
@@ -24,67 +26,7 @@ require 'workpattern/workpattern'
|
|
24
26
|
# Documentation: Barrie Callender <barrie@callenb.org>
|
25
27
|
#
|
26
28
|
module Workpattern
|
27
|
-
# Represents a full working hour
|
28
|
-
# @since 0.2.0
|
29
|
-
WORKING_HOUR = 2**60 - 1
|
30
29
|
|
31
|
-
# Represents a full resting hour
|
32
|
-
# @since 0.2.0
|
33
|
-
RESTING_HOUR = 0
|
34
|
-
|
35
|
-
# The default workpattern name
|
36
|
-
# @since 0.2.0
|
37
|
-
DEFAULT_WORKPATTERN_NAME = 'default'.freeze
|
38
|
-
|
39
|
-
# The default base year
|
40
|
-
# @since 0.2.0
|
41
|
-
DEFAULT_BASE_YEAR = 2000
|
42
|
-
|
43
|
-
# The default span in years
|
44
|
-
# @since 0.2.0
|
45
|
-
DEFAULT_SPAN = 100
|
46
|
-
|
47
|
-
# Minute in terms of seconds
|
48
|
-
#
|
49
|
-
MINUTE = 60
|
50
|
-
|
51
|
-
# Hour interms od seconds
|
52
|
-
#
|
53
|
-
HOUR = MINUTE * 60
|
54
|
-
|
55
|
-
# Day in terms of seconds
|
56
|
-
#
|
57
|
-
DAY = HOUR * 24
|
58
|
-
|
59
|
-
# Earliest or first time in the day
|
60
|
-
# @since 0.0.1
|
61
|
-
FIRST_TIME_IN_DAY = Clock.new(0, 0)
|
62
|
-
|
63
|
-
# Latest or last time in the day
|
64
|
-
# @since 0.0.1
|
65
|
-
LAST_TIME_IN_DAY = Clock.new(23, 59)
|
66
|
-
|
67
|
-
# Specifies a working pattern
|
68
|
-
# @since 0.0.1
|
69
|
-
WORK = 1
|
70
|
-
|
71
|
-
# Specifies a resting pattern
|
72
|
-
# @since 0.0.1
|
73
|
-
REST = 0
|
74
|
-
|
75
|
-
# Represents the days of the week to be used in applying working
|
76
|
-
# and resting patterns.
|
77
|
-
# Values exist for each day of the week as well as for the weekend
|
78
|
-
# (Saturday and Sunday),
|
79
|
-
# the week (Monday to Friday) and all days in the week.
|
80
|
-
#
|
81
|
-
# @since 0.0.1
|
82
|
-
daynames = { sun: [0], mon: [1], tue: [2], wed: [3],
|
83
|
-
thu: [4], fri: [5], sat: [6],
|
84
|
-
weekday: [1, 2, 3, 4, 5],
|
85
|
-
weekend: [0, 6],
|
86
|
-
all: [0, 1, 2, 3, 4, 5, 6] }
|
87
|
-
DAYNAMES = daynames.freeze
|
88
30
|
# Covenience method to obtain a new <tt>Workpattern</tt>
|
89
31
|
#
|
90
32
|
# A negative <tt>span</tt> counts back from the <tt>base</tt> year
|
@@ -94,7 +36,6 @@ module Workpattern
|
|
94
36
|
# @param [Integer] number of years ending on 31st December.
|
95
37
|
# @return [Workpattern]
|
96
38
|
# @raise [NameError] creating a Workpattern with a name that already exists
|
97
|
-
# @since 0.2.0
|
98
39
|
#
|
99
40
|
def self.new(name = DEFAULT_WORKPATTERN_NAME,
|
100
41
|
base = DEFAULT_BASE_YEAR,
|
@@ -107,8 +48,6 @@ module Workpattern
|
|
107
48
|
#
|
108
49
|
# @return [Array] all <tt>Workpattern</tt> objects
|
109
50
|
#
|
110
|
-
# @since 0.2.0
|
111
|
-
#
|
112
51
|
def self.to_a
|
113
52
|
Workpattern.to_a
|
114
53
|
end
|
@@ -118,8 +57,6 @@ module Workpattern
|
|
118
57
|
# @param [String] name The name of the Workpattern to retrieve.
|
119
58
|
# @return [Workpattern]
|
120
59
|
#
|
121
|
-
# @since 0.2.0
|
122
|
-
#
|
123
60
|
def self.get(name)
|
124
61
|
Workpattern.get(name)
|
125
62
|
end
|
@@ -128,16 +65,12 @@ module Workpattern
|
|
128
65
|
#
|
129
66
|
# @param [String] name The name of the Workpattern to be deleted.
|
130
67
|
#
|
131
|
-
# @since 0.2.0
|
132
|
-
#
|
133
68
|
def self.delete(name)
|
134
69
|
Workpattern.delete(name)
|
135
70
|
end
|
136
71
|
|
137
72
|
# Convenience method to delete all Workpatterns.
|
138
73
|
#
|
139
|
-
# @since 0.2.0
|
140
|
-
#
|
141
74
|
def self.clear
|
142
75
|
Workpattern.clear
|
143
76
|
end
|
@@ -150,9 +83,8 @@ module Workpattern
|
|
150
83
|
# @return [Clock]
|
151
84
|
# @see Clock
|
152
85
|
#
|
153
|
-
# @since 0.2.0
|
154
|
-
#
|
155
86
|
def self.clock(hour, min)
|
156
87
|
Clock.new(hour, min)
|
157
88
|
end
|
89
|
+
|
158
90
|
end
|
data/lib/workpattern/clock.rb
CHANGED
File without changes
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Workpattern
|
2
|
+
|
3
|
+
# default name of a new Workpattern
|
4
|
+
DEFAULT_WORKPATTERN_NAME = 'default'.freeze
|
5
|
+
|
6
|
+
# default base year for a new workpattern
|
7
|
+
DEFAULT_BASE_YEAR = 2000
|
8
|
+
|
9
|
+
# default span of years for a new Workpattern
|
10
|
+
DEFAULT_SPAN = 100
|
11
|
+
|
12
|
+
# 60 seconds in a minute
|
13
|
+
MINUTE = 60
|
14
|
+
|
15
|
+
# 60 minutes in an hour
|
16
|
+
HOUR = MINUTE * 60
|
17
|
+
|
18
|
+
# 24 hours in a day
|
19
|
+
HOURS_IN_DAY = 24
|
20
|
+
|
21
|
+
# Seconds in a day
|
22
|
+
DAY = HOUR * HOURS_IN_DAY
|
23
|
+
|
24
|
+
# 60 minutes in a working hour as binary bit per minute
|
25
|
+
WORKING_HOUR = 2**MINUTE - 1
|
26
|
+
|
27
|
+
# 0 minutes in a working hour as binary bits per minute
|
28
|
+
RESTING_HOUR = 0
|
29
|
+
|
30
|
+
# Earliest or first time in the day
|
31
|
+
FIRST_TIME_IN_DAY = Clock.new(0, 0)
|
32
|
+
|
33
|
+
# Latest or last time in the day
|
34
|
+
LAST_TIME_IN_DAY = Clock.new(23, 59)
|
35
|
+
|
36
|
+
# Flags for calculations
|
37
|
+
PREVIOUS_DAY = -1
|
38
|
+
SAME_DAY = 0
|
39
|
+
NEXT_DAY = 1
|
40
|
+
|
41
|
+
# Specifies a working pattern
|
42
|
+
WORK_TYPE = 1
|
43
|
+
|
44
|
+
# Specifies a resting pattern
|
45
|
+
REST_TYPE = 0
|
46
|
+
|
47
|
+
# All the days of the week
|
48
|
+
SUNDAY=0
|
49
|
+
MONDAY=1
|
50
|
+
TUESDAY=2
|
51
|
+
WEDNESDAY=3
|
52
|
+
THURSDAY=4
|
53
|
+
FRIDAY=5
|
54
|
+
SATURDAY=6
|
55
|
+
|
56
|
+
# first and last day of week
|
57
|
+
FIRST_DAY_OF_WEEK = SUNDAY
|
58
|
+
LAST_DAY_OF_WEEK = SATURDAY
|
59
|
+
|
60
|
+
# Represents the days of the week to be used in applying working
|
61
|
+
# and resting patterns.
|
62
|
+
# Values exist for each day of the week as well as for the weekend
|
63
|
+
# (Saturday and Sunday),
|
64
|
+
# the week (Monday to Friday) and all days in the week.
|
65
|
+
#
|
66
|
+
daynames = { sun: [0], mon: [1], tue: [2], wed: [3],
|
67
|
+
thu: [4], fri: [5], sat: [6],
|
68
|
+
weekday: [1, 2, 3, 4, 5],
|
69
|
+
weekend: [0, 6],
|
70
|
+
all: [0, 1, 2, 3, 4, 5, 6] }
|
71
|
+
DAYNAMES = daynames.freeze
|
72
|
+
end
|