working_hours 1.1.4 → 1.2.0

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
- SHA1:
3
- metadata.gz: f00a9f2b6cd9d293631464feb64a41d6c738b03f
4
- data.tar.gz: c18fa540c8033e1d8c1f42cad501420f16c6c7d7
2
+ SHA256:
3
+ metadata.gz: 1c6ba325dcb5811a04a8eb5102e65b6d48e291a7d4a581baaf6f5e63b5394cf1
4
+ data.tar.gz: 302e9f7a199ac7db4049e288f141c7dad3674e6618f99a2c4380af14e316b121
5
5
  SHA512:
6
- metadata.gz: fb32d4257bb17d0c0dc5d7595e19f808ec76970d38bb46ab3b4bf0893ed3d05e9f1734db7f49ec09a89eb495bc21e45a98bd08ce40979edd89efbbfd039f8539
7
- data.tar.gz: f9874b5d95e6b47846d194347de5e78c14fe56d95a36071a1215e016dfe9312c3a57f0343aabdb4a4280fc89900e100e5c5598975954683d32a08cb18cfd92bd
6
+ metadata.gz: d5ff45d737ba62afd04c0322d4010e6bac9cad0954a1fadcbd38564540367f32e2e8da8f78529921f755a46663cd1dbabf4562ec6d02235d8c1d0ddcc047316b
7
+ data.tar.gz: 686a39afbad5ff340de57db83173dd75dd6c2b5b0ec244e25fbc2263b2eb7f90764f7cb8a95aed53a689507c19b4ba337a987ee00eac33bdce0c9fc903865772
@@ -1,29 +1,25 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.8
5
- - 2.2.4
6
- - 2.3.0
7
- - 2.4.0
8
- - ruby-head
9
- - jruby-1.7.23
10
- - jruby-9.0.4.0
11
- - jruby-head
12
- before_install:
13
- - bundler --version || gem install bundler
14
- env: JRUBY_OPTS=--2.0
3
+ - 2.4.9
4
+ - 2.5.7
5
+ - 2.6.5
6
+ - 2.7.0
7
+ - jruby-9.2.11.0
15
8
  gemfile:
16
- - gemfiles/Gemfile.activesupport-3.2.x
17
- - gemfiles/Gemfile.activesupport-4.0.x
18
- - gemfiles/Gemfile.activesupport-4.1.x
19
- - gemfiles/Gemfile.activesupport-4.2.x
20
- - gemfiles/Gemfile.activesupport-edge
21
- matrix:
9
+ - gemfiles/Gemfile.activesupport-4.x
10
+ - gemfiles/Gemfile.activesupport-5.x
11
+ - gemfiles/Gemfile.activesupport-6.x
12
+ jobs:
22
13
  exclude:
23
- - rvm: 2.4.0
24
- env: JRUBY_OPTS=--2.0
25
- gemfile: gemfiles/Gemfile.activesupport-3.2.x
26
- allow_failures:
27
- - gemfile: gemfiles/Gemfile.activesupport-edge
14
+ - rvm: 2.4.9
15
+ gemfile: gemfiles/Gemfile.activesupport-6.x
16
+ - rvm: 2.7.0
17
+ gemfile: gemfiles/Gemfile.activesupport-4.x
18
+ include:
28
19
  - rvm: ruby-head
20
+ gemfile: gemfiles/Gemfile.activesupport-edge
29
21
  - rvm: jruby-head
22
+ gemfile: gemfiles/Gemfile.activesupport-edge
23
+ allow_failures:
24
+ - gemfile: gemfiles/Gemfile.activesupport-edge
25
+ fast_finish: true
@@ -1,6 +1,16 @@
1
1
  # Unreleased
2
2
 
3
- [Compare master with v1.1.4](https://github.com/intrepidd/working_hours/compare/v1.1.4...master)
3
+ [Compare master with v1.2.0](https://github.com/intrepidd/working_hours/compare/v1.2.0...master)
4
+
5
+ # v1.2.0
6
+ * Drop support for ruby 2.0, 2.1, 2.2 and 2.3
7
+ * Drop support for jruby 1.7 and 9.0
8
+ * Drop support for ActiveSupport 3.x
9
+ * Add support for jruby 9.2
10
+ * Add support for ruby 2.5, 2.6 and 2.7
11
+ * Add support for ActiveSupport 5.x and 6.x
12
+ * Fix day computations when origin is a holiday or a non worked day - [#39](https://github.com/Intrepidd/working_hours/pull/39)
13
+
4
14
 
5
15
  # v1.1.4
6
16
  * Fix thread safety - [#36](https://github.com/Intrepidd/working_hours/pull/36)
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
  A modern ruby gem allowing to do time calculation with working hours.
6
6
 
7
7
  Compatible and tested with:
8
- - Ruby `2.x`, JRuby `9.0.x`, JRuby `1.7.x` ( with 2.0 syntax: `--2.0` )
9
- - ActiveSupport `3.2.x`, `4.x`
8
+ - Ruby `2.4`, `2.5`, `2.6`, `2.7`, JRuby `9.2`
9
+ - ActiveSupport `4.x`, `5.x`, `6.x`
10
10
 
11
11
  ## Installation
12
12
 
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem 'activesupport', '~> 3.2'
5
+ gem 'activesupport', '~> 5.2'
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem 'activesupport', '~> 4.0'
5
+ gem 'activesupport', '~> 6.0'
@@ -5,8 +5,12 @@ module WorkingHours
5
5
  module Computation
6
6
 
7
7
  def add_days origin, days, config: nil
8
+ return origin if days.zero?
9
+
8
10
  config ||= wh_config
9
11
  time = in_config_zone(origin, config: config)
12
+ time += (days <=> 0).day until working_day?(time, config: config)
13
+
10
14
  while days > 0
11
15
  time += 1.day
12
16
  days -= 1 if working_day?(time, config: config)
@@ -1,3 +1,3 @@
1
1
  module WorkingHours
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -32,12 +32,26 @@ describe WorkingHours::Computation do
32
32
  expect(add_days(time, 1)).to eq(Date.new(2014, 4, 9)) # Wednesday
33
33
  end
34
34
 
35
+ it 'skips non worked days when origin is not worked' do
36
+ time = Date.new(2014, 4, 8) # Tuesday
37
+ WorkingHours::Config.working_hours = {mon: {'09:00' => '17:00'}, wed: {'09:00' => '17:00'}, thu: {'09:00' => '17:00'}, sun: {'09:00' => '17:00'}}
38
+ expect(add_days(time, 1)).to eq(Date.new(2014, 4, 10)) # Thursday
39
+ expect(add_days(time, -1)).to eq(Date.new(2014, 4, 6)) # Sunday
40
+ end
41
+
35
42
  it 'skips holidays' do
36
43
  time = Date.new(2014, 4, 7) # Monday
37
44
  WorkingHours::Config.holidays = [Date.new(2014, 4, 8)] # Tuesday
38
45
  expect(add_days(time, 1)).to eq(Date.new(2014, 4, 9)) # Wednesday
39
46
  end
40
47
 
48
+ it 'skips holidays when origin is holiday' do
49
+ time = Date.new(2014, 4, 9) # Wednesday
50
+ WorkingHours::Config.holidays = [time] # Wednesday
51
+ expect(add_days(time, 1)).to eq(Date.new(2014, 4, 11)) # Friday
52
+ expect(add_days(time, -1)).to eq(Date.new(2014, 4, 7)) # Monday
53
+ end
54
+
41
55
  it 'skips holidays and non worked days' do
42
56
  time = Date.new(2014, 4, 7) # Monday
43
57
  WorkingHours::Config.holidays = [Date.new(2014, 4, 9)] # Wednesday
@@ -45,6 +59,12 @@ describe WorkingHours::Computation do
45
59
  expect(add_days(time, 3)).to eq(Date.new(2014, 4, 21))
46
60
  end
47
61
 
62
+ it 'returns the original value when adding 0 days' do
63
+ time = Date.new(2014, 4, 7)
64
+ WorkingHours::Config.holidays = [time]
65
+ expect(add_days(time, 0)).to eq(time)
66
+ end
67
+
48
68
  it 'accepts time given from any time zone' do
49
69
  time = Time.utc(1991, 11, 14, 21, 0, 0) # Thursday 21 pm UTC
50
70
  WorkingHours::Config.time_zone = 'Tokyo' # But we are at tokyo, so it's already Friday 6 am
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'activesupport', '>= 3.2'
22
22
  spec.add_dependency 'tzinfo'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.5'
24
+ spec.add_development_dependency 'bundler', '>= 1.5'
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rspec', '~> 3.2'
27
27
  spec.add_development_dependency 'timecop'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: working_hours
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Jarthon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-30 00:00:00.000000000 Z
12
+ date: 2020-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -43,14 +43,14 @@ dependencies:
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '1.5'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.5'
56
56
  - !ruby/object:Gem::Dependency
@@ -111,11 +111,10 @@ files:
111
111
  - LICENSE.txt
112
112
  - README.md
113
113
  - Rakefile
114
- - gemfiles/Gemfile.activesupport-3.2.x
115
- - gemfiles/Gemfile.activesupport-4.0.x
116
- - gemfiles/Gemfile.activesupport-4.1.x
117
- - gemfiles/Gemfile.activesupport-4.2.x
118
- - gemfiles/Gemfile.activesupport-head
114
+ - gemfiles/Gemfile.activesupport-4.x
115
+ - gemfiles/Gemfile.activesupport-5.x
116
+ - gemfiles/Gemfile.activesupport-6.x
117
+ - gemfiles/Gemfile.activesupport-edge
119
118
  - lib/working_hours.rb
120
119
  - lib/working_hours/computation.rb
121
120
  - lib/working_hours/config.rb
@@ -153,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
152
  - !ruby/object:Gem::Version
154
153
  version: '0'
155
154
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.5.1
155
+ rubygems_version: 3.0.8
158
156
  signing_key:
159
157
  specification_version: 4
160
158
  summary: time calculation with working hours
@@ -167,4 +165,3 @@ test_files:
167
165
  - spec/working_hours/duration_proxy_spec.rb
168
166
  - spec/working_hours/duration_spec.rb
169
167
  - spec/working_hours_spec.rb
170
- has_rdoc:
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '..'
4
-
5
- gem 'activesupport', '~> 4.1'