workpattern 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +9 -19
- data/.travis.yml +17 -12
- data/{CHANGELOG → CHANGELOG.md} +27 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +17 -20
- data/Rakefile +0 -0
- data/lib/workpattern/clock.rb +0 -0
- data/lib/workpattern/constants.rb +72 -0
- data/lib/workpattern/day.rb +268 -0
- data/lib/workpattern/version.rb +1 -1
- data/lib/workpattern/week.rb +135 -298
- data/lib/workpattern/week_pattern.rb +142 -0
- data/lib/workpattern/workpattern.rb +124 -132
- data/lib/workpattern.rb +25 -73
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- data/workpattern.gemspec +41 -20
- metadata +20 -36
- 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
data/workpattern.gemspec
CHANGED
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
-
require "workpattern/version"
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
s.homepage = "http://github.com/callenb/workpattern"
|
|
11
|
-
s.summary = %q{Calculates dates and durations whilst taking into account working and non-working periods down to a minute}
|
|
12
|
-
s.description = %q{Calculates dates and durations whilst taking into account working and non-working times down to a minute. Business working time with holidays are a breeze.}
|
|
13
|
-
s.license = 'MIT'
|
|
4
|
+
if RUBY_VERSION >= "2.4"
|
|
5
|
+
require_relative "lib/workpattern/version"
|
|
6
|
+
else
|
|
7
|
+
require "workpattern/version"
|
|
8
|
+
end
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
Gem::Specification.new do |spec|
|
|
11
|
+
spec.name = "workpattern"
|
|
12
|
+
spec.version = Workpattern::VERSION
|
|
13
|
+
spec.authors = ["Barrie Callender"]
|
|
14
|
+
spec.email = ["barrie@callenb.org"]
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
spec.summary = "Calculates dates and durations whilst taking into account working and non-working periods down to a minute"
|
|
17
|
+
spec.description = "Calculates dates and durations whilst taking into account working and non-working times down to a minute. Business working time with holidays are a breeze."
|
|
18
|
+
spec.homepage = "http://workpattern.org"
|
|
19
|
+
spec.license = "MIT"
|
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
|
|
21
|
+
if RUBY_VERSION >= "2.4"
|
|
22
|
+
spec.metadata["homepage_url"] = spec.homepage
|
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/callenb/workpattern"
|
|
24
|
+
spec.metadata["changelog_uri"] = "https://workpattern.org/2021/02/25/changelog.html"
|
|
25
|
+
end
|
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
28
|
+
if RUBY_VERSION >= "2.4"
|
|
29
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
spec.files = `git ls-files`.split("\n")
|
|
34
|
+
end
|
|
35
|
+
spec.require_paths = ["lib"]
|
|
21
36
|
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
s.add_development_dependency('rake', ['~> 0.9.2'])
|
|
25
|
-
s.add_development_dependency('minitest', ['~> 5.4.3'])
|
|
26
|
-
end
|
|
37
|
+
# Uncomment to register a new dependency of your gem
|
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
27
39
|
|
|
40
|
+
# For more information and examples about making a new gem, checkout our
|
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
42
|
+
spec.add_runtime_dependency 'tzinfo'
|
|
43
|
+
spec.add_runtime_dependency 'sorted_set' if RUBY_VERSION >= "2.4"
|
|
44
|
+
|
|
45
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
46
|
+
spec.require_paths = ["lib"]
|
|
47
|
+
|
|
48
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: workpattern
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Barrie Callender
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: tzinfo
|
|
@@ -25,33 +24,19 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: sorted_set
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.9.2
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.9.2
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: minitest
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
30
|
+
- - ">="
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
48
|
-
type: :
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
|
-
- - "
|
|
37
|
+
- - ">="
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
39
|
+
version: '0'
|
|
55
40
|
description: Calculates dates and durations whilst taking into account working and
|
|
56
41
|
non-working times down to a minute. Business working time with holidays are a breeze.
|
|
57
42
|
email:
|
|
@@ -62,31 +47,32 @@ extra_rdoc_files: []
|
|
|
62
47
|
files:
|
|
63
48
|
- ".gitignore"
|
|
64
49
|
- ".travis.yml"
|
|
65
|
-
- CHANGELOG
|
|
50
|
+
- CHANGELOG.md
|
|
51
|
+
- CODE_OF_CONDUCT.md
|
|
66
52
|
- Gemfile
|
|
53
|
+
- LICENSE.txt
|
|
67
54
|
- README.md
|
|
68
55
|
- Rakefile
|
|
69
56
|
- lib/workpattern.rb
|
|
70
57
|
- lib/workpattern/clock.rb
|
|
71
|
-
- lib/workpattern/
|
|
58
|
+
- lib/workpattern/constants.rb
|
|
59
|
+
- lib/workpattern/day.rb
|
|
72
60
|
- lib/workpattern/version.rb
|
|
73
61
|
- lib/workpattern/week.rb
|
|
62
|
+
- lib/workpattern/week_pattern.rb
|
|
74
63
|
- lib/workpattern/workpattern.rb
|
|
75
64
|
- script/console
|
|
76
65
|
- script/destroy
|
|
77
66
|
- script/generate
|
|
78
67
|
- script/txt2html
|
|
79
|
-
- test/test_clock.rb
|
|
80
|
-
- test/test_helper.rb
|
|
81
|
-
- test/test_week.rb
|
|
82
|
-
- test/test_workpattern.rb
|
|
83
|
-
- test/test_workpattern_module.rb
|
|
84
68
|
- workpattern.gemspec
|
|
85
|
-
homepage: http://
|
|
69
|
+
homepage: http://workpattern.org
|
|
86
70
|
licenses:
|
|
87
71
|
- MIT
|
|
88
|
-
metadata:
|
|
89
|
-
|
|
72
|
+
metadata:
|
|
73
|
+
homepage_url: http://workpattern.org
|
|
74
|
+
source_code_uri: https://github.com/callenb/workpattern
|
|
75
|
+
changelog_uri: https://workpattern.org/2021/02/25/changelog.html
|
|
90
76
|
rdoc_options: []
|
|
91
77
|
require_paths:
|
|
92
78
|
- lib
|
|
@@ -101,9 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
101
87
|
- !ruby/object:Gem::Version
|
|
102
88
|
version: '0'
|
|
103
89
|
requirements: []
|
|
104
|
-
|
|
105
|
-
rubygems_version: 2.6.7
|
|
106
|
-
signing_key:
|
|
90
|
+
rubygems_version: 3.6.7
|
|
107
91
|
specification_version: 4
|
|
108
92
|
summary: Calculates dates and durations whilst taking into account working and non-working
|
|
109
93
|
periods down to a minute
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Workpattern
|
|
2
|
-
# Mixins expected to be used in more than one class
|
|
3
|
-
#
|
|
4
|
-
# @since 0.2.0
|
|
5
|
-
#
|
|
6
|
-
# @private
|
|
7
|
-
module Base
|
|
8
|
-
# Holds local timezone info
|
|
9
|
-
@@tz = nil
|
|
10
|
-
|
|
11
|
-
# Converts a date like object into utc
|
|
12
|
-
#
|
|
13
|
-
def to_utc(date)
|
|
14
|
-
date.to_time.utc
|
|
15
|
-
end
|
|
16
|
-
# Converts a date like object into local time
|
|
17
|
-
#
|
|
18
|
-
def to_local(date)
|
|
19
|
-
date.to_time.getgm
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Retrieves the local timezone
|
|
23
|
-
def timezone
|
|
24
|
-
@@tz || @@tz = TZInfo::Timezone.get(Time.now.zone)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
data/test/test_clock.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
|
-
|
|
3
|
-
class TestClock < MiniTest::Test #:nodoc:
|
|
4
|
-
def setup
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def test_must_create_midnight_default
|
|
8
|
-
clock = Workpattern::Clock.new
|
|
9
|
-
|
|
10
|
-
assert_equal 0, clock.minutes, 'total default minutes'
|
|
11
|
-
assert_equal 0, clock.hour, 'default hour is zero'
|
|
12
|
-
assert_equal 0, clock.min, 'default minute is zero'
|
|
13
|
-
time = clock.time
|
|
14
|
-
assert time.is_a?(DateTime), 'must return a DateTime object'
|
|
15
|
-
assert_equal 0, time.hour, 'hour in the day must be zero'
|
|
16
|
-
assert_equal 0, time.min, 'minute in the day must be zero'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_must_account_for_out_of_range_values
|
|
20
|
-
clock = Workpattern::Clock.new(27, 80)
|
|
21
|
-
|
|
22
|
-
assert_equal 1700, clock.minutes, 'total minutes'
|
|
23
|
-
assert_equal 4, clock.hour, 'hour is 4'
|
|
24
|
-
assert_equal 20, clock.min, 'minute is 20'
|
|
25
|
-
time = clock.time
|
|
26
|
-
assert time.is_a?(DateTime), 'must return a DateTime object'
|
|
27
|
-
assert_equal DateTime.new(1963, 6, 10, 4, 20), time
|
|
28
|
-
end
|
|
29
|
-
end
|
data/test/test_helper.rb
DELETED