workpattern 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bf0371cc0f47c34f3ab9e7e740975077e3edbf6
4
- data.tar.gz: bbd957d3fb41cedd503146cc8bb870e34c023994
3
+ metadata.gz: 369fff3d813c83a9202c4593c93222f0683a3bc5
4
+ data.tar.gz: e8c724250a725fecffbea9232e14e70422339e39
5
5
  SHA512:
6
- metadata.gz: fc1f35fbb2e5a1cf1f0cdb357da3348343041f47b034d139f470590949116fb78e889c80798241f627f05a90259f6c99ea3c390969e6806d68756888faa992b8
7
- data.tar.gz: 5f7cea5e6f7869a0da1a6cd9cdb92d9836867567514709b0a1792b6438976705d0c500c5584c9f21714475b1ef6082a9aed8ae95a8c3da4ae07b9f60188b499c
6
+ metadata.gz: ecf42d51cce8b9f68f29c0ba7009f88450fb510f028b7e246f5fa144c72cb1369e79e7502f021e2a09a49de2bfd637d8cf42aa4a10902427de808186f3079c8b
7
+ data.tar.gz: bad7c4fdfe5e04b9804742197ebdc91147130ce687b3b3558056c6736ddf70631ffdcb1d1a7e70fe7c36e670002f5883985f5290d87fef5392680fc423efe183
data/CHANGELOG CHANGED
@@ -1,12 +1,13 @@
1
- ## Workpattern v0.3.4 (Sep 23, 2013) ##
1
+ ## Workpattern v0.3.4 (Sep 27, 2013) ##
2
+
3
+ * diff doesn't calculate properly from working to resting day (#15) * Barrie Callender *
4
+
5
+
6
+ ## Workpattern v0.3.3 (Sep 23, 2013) ##
2
7
 
3
8
  * Failed to subtract 1 minute from end of resting hour (#12) * Barrie Callender *
4
9
  * Failed to add minutes starting from a resting period in a patterned hour (#13) * Barrie Callender *
5
10
  * Failed to subtract the exact amount of minutes from a patterned hour (#14) * Barrie Callender *
6
-
7
-
8
- ## Workpattern v0.3.3 (Aug 21, 2013) ##
9
-
10
11
  * The two tests no longer fail with Ruby 2.0 (#11) * Barrie Callender *
11
12
 
12
13
 
@@ -1,5 +1,5 @@
1
1
  module Workpattern
2
2
  # Version Number for Workpattern gem
3
3
  # @since 0.0.1
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.4'
5
5
  end
@@ -337,6 +337,7 @@ module Workpattern
337
337
  #
338
338
  def diff_detail(start,finish,finish_on)
339
339
  duration, start=@values[start.wday].diff(start,finish)
340
+ return duration,start if start > finish_on
340
341
  #rest of week to finish day
341
342
  while (start.wday<finish.wday) do
342
343
  duration+=@values[start.wday].total
@@ -5,6 +5,26 @@ class TestWeek < MiniTest::Unit::TestCase #:nodoc:
5
5
  def setup
6
6
 
7
7
  end
8
+
9
+ def test_must_diff_from_last_day_of_patterned_week
10
+ #issue 15
11
+ start=DateTime.new(2013,9,23,0,0)
12
+ finish=DateTime.new(2013,9,26,23,59)
13
+ working_week=week(start,finish,1)
14
+ working_week.workpattern :all, Workpattern.clock(0,0),Workpattern.clock(8,59),0
15
+ working_week.workpattern :all, Workpattern.clock(12,0),Workpattern.clock(12,59),0
16
+ working_week.workpattern :all, Workpattern.clock(18,0),Workpattern.clock(23,59),0
17
+
18
+ duration, start =working_week.diff(DateTime.civil(2013,9,26,17,0),DateTime.civil(2013,9,27,10,0))
19
+
20
+ assert_equal 60, duration
21
+ assert_equal DateTime.civil(2013,9,27,0,0), start
22
+ end
23
+
24
+
25
+ ######################################################
26
+ ######################################################
27
+ ######################################################
8
28
 
9
29
  def test_must_create_a_working_week
10
30
  start=DateTime.new(2000,1,1,11,3)
@@ -5,7 +5,23 @@ class TestWorkpattern < MiniTest::Unit::TestCase #:nodoc:
5
5
  def setup
6
6
  Workpattern.clear()
7
7
  end
8
-
8
+
9
+ def test_can_diff_between_working_period_and_resting_day
10
+ # This is the test for issue 15
11
+ mywp=Workpattern.new('My Workpattern',2013,3)
12
+ mywp.resting(:days => :weekend)
13
+ mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(0,0),:to_time=>Workpattern.clock(8,59))
14
+ mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(12,0),:to_time=>Workpattern.clock(12,59))
15
+ mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(18,0),:to_time=>Workpattern.clock(23,59))
16
+
17
+ mydate1=DateTime.civil(2013,9,27,0,0,0)
18
+ mydate2=DateTime.civil(2013,9,27,23,59,59)
19
+
20
+ mywp.resting(:start=>mydate1,:finish=>mydate2, :days =>:all, :from_time=>Workpattern.clock(0,0), :to_time=>Workpattern.clock(23,59))
21
+
22
+ assert_equal 60, mywp.diff(DateTime.civil(2013,9,26,17,0),DateTime.civil(2013,9,27,10,0))
23
+ end
24
+
9
25
  def test_must_create_a_working_workpattern
10
26
  name='mywp'
11
27
  base=2001
@@ -238,7 +254,7 @@ class TestWorkpattern < MiniTest::Unit::TestCase #:nodoc:
238
254
  assert !wp.working?(DateTime.new(2012,1,1,8,59))
239
255
  end
240
256
 
241
-
257
+
242
258
  private
243
259
 
244
260
  def get_week(ss)
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workpattern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barrie Callender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-23 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.2
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.2
27
27
  description: Workpattern performs date calculations that take into account working
@@ -32,8 +32,8 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .gitignore
36
- - .travis.yml
35
+ - ".gitignore"
36
+ - ".travis.yml"
37
37
  - CHANGELOG
38
38
  - Gemfile
39
39
  - Gemfile.lock
@@ -69,17 +69,17 @@ require_paths:
69
69
  - lib
70
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project: workpattern
82
- rubygems_version: 2.0.4
82
+ rubygems_version: 2.1.4
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: temporal calculations