workpattern 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +4 -1
- data/.travis.yml +8 -2
- data/CHANGELOG +19 -0
- data/Gemfile +0 -0
- data/README.md +58 -57
- data/Rakefile +0 -0
- data/lib/workpattern.rb +65 -55
- data/lib/workpattern/clock.rb +17 -20
- data/lib/workpattern/utility/base.rb +16 -21
- data/lib/workpattern/version.rb +2 -2
- data/lib/workpattern/week.rb +266 -189
- data/lib/workpattern/workpattern.rb +170 -142
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- data/test/test_clock.rb +19 -22
- data/test/test_helper.rb +0 -0
- data/test/test_week.rb +393 -368
- data/test/test_workpattern.rb +238 -207
- data/test/test_workpattern_module.rb +57 -51
- data/workpattern.gemspec +7 -6
- metadata +44 -16
- data/config/website.yml +0 -2
@@ -1,82 +1,88 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class TestWorkpatternModule < MiniTest::
|
4
|
-
|
3
|
+
class TestWorkpatternModule < MiniTest::Test #:nodoc:
|
5
4
|
def setup
|
6
|
-
Workpattern.clear
|
5
|
+
Workpattern.clear
|
7
6
|
end
|
8
|
-
|
9
|
-
def
|
10
|
-
wp = Workpattern.new
|
11
|
-
assert_equal Workpattern::DEFAULT_WORKPATTERN_NAME, wp.name,
|
12
|
-
|
13
|
-
assert_equal Workpattern::
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
|
8
|
+
def test_must_create_workpattern_with_defaults
|
9
|
+
wp = Workpattern.new
|
10
|
+
assert_equal Workpattern::DEFAULT_WORKPATTERN_NAME, wp.name,
|
11
|
+
'not returned the default workpattern name'
|
12
|
+
assert_equal Workpattern::DEFAULT_BASE_YEAR, wp.from.year,
|
13
|
+
'not returned the default workpattern base year'
|
14
|
+
assert_equal Workpattern::DEFAULT_SPAN, wp.span,
|
15
|
+
'not returned the default workpattern span'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_must_create_workpattern_with_given_parameters
|
19
|
+
mywp_name = 'barrie callender'
|
20
|
+
mywp_base = 1963
|
21
|
+
mywp_span = 48
|
22
|
+
mywp = Workpattern.new(mywp_name, mywp_base, mywp_span)
|
23
|
+
assert_equal mywp_name, mywp.name,
|
24
|
+
'not returned the supplied workpattern name'
|
25
|
+
assert_equal mywp_base, mywp.from.year,
|
26
|
+
'not returned the supplied workpattern base year'
|
27
|
+
assert_equal mywp_span, mywp.span,
|
28
|
+
'not returned the supplied workpattern span'
|
22
29
|
end
|
23
|
-
|
30
|
+
|
24
31
|
def test_must_raise_error_when_creating_workpattern_with_existing_name
|
25
32
|
assert_raises NameError do
|
26
|
-
mywp_name='duplicate'
|
27
|
-
|
28
|
-
|
33
|
+
mywp_name = 'duplicate'
|
34
|
+
Workpattern.new(mywp_name)
|
35
|
+
Workpattern.new(mywp_name)
|
29
36
|
end
|
30
37
|
end
|
31
|
-
|
38
|
+
|
32
39
|
def test_must_return_an_array_of_all_known_workpattern_objects
|
33
|
-
names
|
34
|
-
names.each {|name|
|
40
|
+
names = %w(fred harry sally)
|
41
|
+
names.each { |name| Workpattern.new(name) }
|
35
42
|
wp_names = Workpattern.to_a
|
36
|
-
|
37
|
-
assert_equal names.size, wp_names.size,
|
38
|
-
|
39
|
-
wp_names.each {|name,
|
43
|
+
|
44
|
+
assert_equal names.size, wp_names.size, 'lists are not the same size'
|
45
|
+
|
46
|
+
wp_names.each { |name, _wp| assert names.include?(name) }
|
40
47
|
end
|
41
|
-
|
48
|
+
|
42
49
|
def test_must_return_empty_array_when_no_workpatterns_exist
|
43
50
|
assert Workpattern.to_a.empty?
|
44
51
|
end
|
45
|
-
|
52
|
+
|
46
53
|
def test_must_return_existing_workpattern
|
47
|
-
names
|
48
|
-
names.each {|name|
|
49
|
-
|
50
|
-
names.each
|
51
|
-
|
52
|
-
|
54
|
+
names = %w(fred harry sally)
|
55
|
+
names.each { |name| Workpattern.new(name) }
|
56
|
+
|
57
|
+
names.each do |name|
|
58
|
+
Workpattern.get(name)
|
59
|
+
end
|
53
60
|
end
|
54
|
-
|
61
|
+
|
55
62
|
def test_must_raise_error_when_workpattern_does_not_exist
|
56
|
-
names
|
57
|
-
names.each {|name|
|
63
|
+
names = %w(fred harry sally)
|
64
|
+
names.each { |name| Workpattern.new(name) }
|
58
65
|
assert_raises NameError do
|
59
|
-
|
66
|
+
Workpattern.get('missing')
|
60
67
|
end
|
61
68
|
end
|
62
|
-
|
69
|
+
|
63
70
|
def test_must_delete_existing_workpattern_returning_true
|
64
|
-
names
|
65
|
-
names.each {|name|
|
66
|
-
names.each {|name| assert Workpattern.delete(name)}
|
71
|
+
names = %w(fred harry sally)
|
72
|
+
names.each { |name| Workpattern.new(name) }
|
73
|
+
names.each { |name| assert Workpattern.delete(name) }
|
67
74
|
end
|
68
|
-
|
75
|
+
|
69
76
|
def test_must_return_false_deleting_workpattern_that_does_not_exist
|
70
|
-
names
|
71
|
-
names.each {|name|
|
77
|
+
names = %w(fred harry sally)
|
78
|
+
names.each { |name| Workpattern.new(name) }
|
72
79
|
assert !Workpattern.delete('missing')
|
73
80
|
end
|
74
|
-
|
81
|
+
|
75
82
|
def test_must_delete_all_workpatterns
|
76
|
-
names
|
77
|
-
names.each {|name|
|
83
|
+
names = %w(fred harry sally)
|
84
|
+
names.each { |name| Workpattern.new(name) }
|
78
85
|
Workpattern.clear
|
79
86
|
assert Workpattern.to_a.empty?
|
80
87
|
end
|
81
|
-
|
82
88
|
end
|
data/workpattern.gemspec
CHANGED
@@ -7,12 +7,12 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Workpattern::VERSION
|
8
8
|
s.authors = ["Barrie Callender"]
|
9
9
|
s.email = ["barrie@callenb.org"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
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
13
|
s.license = 'MIT'
|
14
14
|
|
15
|
-
s.
|
15
|
+
s.required_ruby_version = ">= 1.9.3"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
# specify any dependencies here; for example:
|
23
|
-
|
24
|
-
# s.add_runtime_dependency "rest-client"
|
23
|
+
s.add_runtime_dependency 'tzinfo'
|
25
24
|
s.add_development_dependency('rake', ['~> 0.9.2'])
|
25
|
+
s.add_development_dependency('minitest', ['~> 5.4.3'])
|
26
26
|
end
|
27
|
+
|
metadata
CHANGED
@@ -1,44 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workpattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barrie Callender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tzinfo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - ~>
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: 0.9.2
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - ~>
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: 0.9.2
|
27
|
-
|
28
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.4.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.4.3
|
55
|
+
description: Calculates dates and durations whilst taking into account working and
|
56
|
+
non-working times down to a minute. Business working time with holidays are a breeze.
|
29
57
|
email:
|
30
58
|
- barrie@callenb.org
|
31
59
|
executables: []
|
32
60
|
extensions: []
|
33
61
|
extra_rdoc_files: []
|
34
62
|
files:
|
35
|
-
- .gitignore
|
36
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
37
65
|
- CHANGELOG
|
38
66
|
- Gemfile
|
39
67
|
- README.md
|
40
68
|
- Rakefile
|
41
|
-
- config/website.yml
|
42
69
|
- lib/workpattern.rb
|
43
70
|
- lib/workpattern/clock.rb
|
44
71
|
- lib/workpattern/utility/base.rb
|
@@ -55,7 +82,7 @@ files:
|
|
55
82
|
- test/test_workpattern.rb
|
56
83
|
- test/test_workpattern_module.rb
|
57
84
|
- workpattern.gemspec
|
58
|
-
homepage:
|
85
|
+
homepage: http://github.com/callenb/workpattern
|
59
86
|
licenses:
|
60
87
|
- MIT
|
61
88
|
metadata: {}
|
@@ -65,18 +92,19 @@ require_paths:
|
|
65
92
|
- lib
|
66
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
94
|
requirements:
|
68
|
-
- -
|
95
|
+
- - ">="
|
69
96
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
97
|
+
version: 1.9.3
|
71
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
99
|
requirements:
|
73
|
-
- -
|
100
|
+
- - ">="
|
74
101
|
- !ruby/object:Gem::Version
|
75
102
|
version: '0'
|
76
103
|
requirements: []
|
77
|
-
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.6.7
|
79
106
|
signing_key:
|
80
107
|
specification_version: 4
|
81
|
-
summary:
|
108
|
+
summary: Calculates dates and durations whilst taking into account working and non-working
|
109
|
+
periods down to a minute
|
82
110
|
test_files: []
|
data/config/website.yml
DELETED