spok 2.0.0 → 2.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d490966e3e874d1bd9d6b7f58d0624b4d289fee8f682602c7f0b83efa2fed975
4
- data.tar.gz: c7bf5a468befc59655b8dfb2fe9545cf4a28b399e2562e8928fe2d79a8cce535
3
+ metadata.gz: bad6a856cfcef094c9d9791cc1ae7e0e3431ef676d14c9f38cf0e1e055a3f077
4
+ data.tar.gz: c480cec8388c406da6752bffc197f0ede4cce333142b2370304f9d149e95b1eb
5
5
  SHA512:
6
- metadata.gz: a2047afcb781e7c6c53ef76389f4beb99cb14d98becab02589432d2f9e8f2313f7b1bc5f1694a87fe337f35f29c6c1579448fab0c144a50871e2eb19e12ccda1
7
- data.tar.gz: cf914c3b6ff784d12939a373e8b43dac7dc6c2291cf44d1c8473cb9ae8684fdd20c6e1540261a339623f20868dc4b95ddba463df745744e260aac0e72de700f3
6
+ metadata.gz: b4508d77222fa85698bcfdf7878ab7cf52faf6e71caaaa5493841bf89555394ff75e9939a8735178f5d193595f5f79547e66283ace77697a1770355ae05350ca
7
+ data.tar.gz: 8f3e6839a98f3b0541275fa1a13c35257acffb5b4ab964ddeb30b3cb1d1bb1437c860a214d42e397c7ef8c5787a1ed9b957854a8235da2a0f2ac37f3adde1b48
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [2.1.3] - 2020-11-17
7
+
8
+ * Remove 2020-11-20 holiday from Bovespa calendar due to their note about
9
+ the day.
10
+ Check it here: http://www.b3.com.br/pt_br/noticias/funcionamento-da-b3-8AE490C97215B74E0172959F18F11323.htm
11
+
12
+ ## [2.1.2] - 2020-04-29
13
+
14
+ * Add 2020's Good Friday holiday on US calendar
15
+
16
+ ## [2.1.1] - 2020-04-15
17
+
18
+ * Remove deprecation warnings and create a note about it on README file.
19
+
20
+ ## [2.1.0] - 2020-04-13
21
+
22
+ * Replace the access of `Spok::Workday` by `Spok` interface.
23
+
24
+ All methods before accessed by `Spok::Workday` module now is accessible by `Spok` interface.
25
+
26
+ ```ruby
27
+ Spok.restday?
28
+ Spok.workday?
29
+ Spok.weekend?
30
+ Spok.holiday?
31
+ Spok.last_workday
32
+ Spok.next_workday
33
+ ```
34
+
35
+ You can still use the `Spok::Workday` interface but it will warn you about the deprecation. We are planning to drop the support of `Spok::Workday` by the end of 2020.
36
+
37
+ ## [2.0.1] - 2019-10-24
38
+
39
+ * Relax `activesupport` dependency to include the `6.x` series
40
+
6
41
  ## [2.0.0] - 2019-10-07
7
42
 
8
43
  - Added calendars for `australia`, `austria`, `belgium`, `colombia`, `france`, `germany`,
@@ -1,39 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spok (2.0.0)
5
- activesupport (~> 5.1)
4
+ spok (2.1.3)
5
+ activesupport (>= 5.1, < 7.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.3)
10
+ activesupport (6.0.3.4)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- concurrent-ruby (1.1.5)
16
- diff-lcs (1.3)
17
- i18n (1.7.0)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ concurrent-ruby (1.1.7)
17
+ diff-lcs (1.4.4)
18
+ i18n (1.8.5)
18
19
  concurrent-ruby (~> 1.0)
19
- minitest (5.12.2)
20
- rake (12.3.2)
21
- rspec (3.8.0)
22
- rspec-core (~> 3.8.0)
23
- rspec-expectations (~> 3.8.0)
24
- rspec-mocks (~> 3.8.0)
25
- rspec-core (3.8.0)
26
- rspec-support (~> 3.8.0)
27
- rspec-expectations (3.8.3)
20
+ minitest (5.14.2)
21
+ rake (13.0.1)
22
+ rspec (3.10.0)
23
+ rspec-core (~> 3.10.0)
24
+ rspec-expectations (~> 3.10.0)
25
+ rspec-mocks (~> 3.10.0)
26
+ rspec-core (3.10.0)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-expectations (3.10.0)
28
29
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.8.0)
30
- rspec-mocks (3.8.0)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-mocks (3.10.0)
31
32
  diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.8.0)
33
- rspec-support (3.8.0)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-support (3.10.0)
34
35
  thread_safe (0.3.6)
35
- tzinfo (1.2.5)
36
+ tzinfo (1.2.8)
36
37
  thread_safe (~> 0.1)
38
+ zeitwerk (2.4.1)
37
39
 
38
40
  PLATFORMS
39
41
  ruby
@@ -45,4 +47,4 @@ DEPENDENCIES
45
47
  spok!
46
48
 
47
49
  BUNDLED WITH
48
- 1.17.3
50
+ 2.1.4
data/README.md CHANGED
@@ -25,22 +25,27 @@ Or install it yourself as:
25
25
 
26
26
  ### Dealing with workdays
27
27
 
28
- You can use the `Spok::Workday` module to check if a date is either a restday or a workday:
28
+ NOTE: All methods available on `Spok::Workday` now are available on `Spok` interface, `Spok::Workday` still works but we have plans to make `Spok:: Workday` a private resource, you should update your code to rely on `Spok` interface.
29
+
30
+ You can use the Spok to check if a date is either a rest day or a workday:
29
31
 
30
32
  ```ruby
31
33
  require 'spok'
32
34
 
33
- Spok::Workday.workday?(Date.new(2012, 12, 24))
35
+ Spok.restday?(Date.new(2012, 12, 24))
36
+ # => false
37
+
38
+ Spok.workday?(Date.new(2012, 12, 24))
34
39
  # => true
35
40
  ```
36
41
 
37
42
  Spok also supports different calendars for checking if a date is a workday or a
38
- restday
43
+ restday.
39
44
 
40
45
  ```ruby
41
46
  require 'spok'
42
47
 
43
- Spok::Workday.workday?(Date.new(2012, 12, 24), calendar: :bovespa)
48
+ Spok.workday?(Date.new(2012, 12, 24), calendar: :bovespa)
44
49
  # => false
45
50
  ```
46
51
 
@@ -117,6 +117,96 @@ class Spok
117
117
  (@start_date..@end_date).to_a.delete_if{ |date| Workday.restday?(date, calendar: calendar) }
118
118
  end
119
119
 
120
+ # Public: Checks if a given day is a restday.
121
+ #
122
+ # date - The Date to be checked.
123
+ # calendar - Symbol informing in which calendar the date will be checked
124
+ # (default: :brazil).
125
+ #
126
+ # Examples
127
+ #
128
+ # Spok.restday?(Date.new(2012, 8, 6))
129
+ # # => false
130
+ #
131
+ # Returns a boolean.
132
+ def self.restday?(date, calendar: Spok.default_calendar)
133
+ Workday.restday?(date, calendar: calendar)
134
+ end
135
+
136
+ # Public: Checks if a given day is a workday.
137
+ #
138
+ # date - The Date to be checked.
139
+ # calendar - Symbol informing in which calendar the date will be checked
140
+ # (default: :brazil).
141
+ #
142
+ # Examples
143
+ #
144
+ # Spok.workday?(Date.new(2012, 8, 6))
145
+ # # => true
146
+ #
147
+ # Returns a boolean.
148
+ def self.workday?(date, calendar: Spok.default_calendar)
149
+ Workday.workday?(date, calendar: calendar)
150
+ end
151
+
152
+ # Public: Checks if a given Date is on a weekend.
153
+ #
154
+ # date - The Date to be checked.
155
+ #
156
+ # Examples
157
+ #
158
+ # Spok.weekend?(Date.new(2012, 8, 6))
159
+ # # => false
160
+ #
161
+ # Returns a boolean.
162
+ def self.weekend?(date)
163
+ Workday.weekend?(date)
164
+ end
165
+
166
+ # Public: Checks if a given Date is on a holiday.
167
+ #
168
+ # date - The Date to be checked.
169
+ # calendar - Symbol informing in which calendar the date will be checked
170
+ # (default: :brazil).
171
+ #
172
+ # Examples
173
+ #
174
+ # Spok.holiday?(Date.new(2012, 5, 1))
175
+ # # => true
176
+ #
177
+ # Returns a boolean.
178
+ def self.holiday?(date, calendar: Spok.default_calendar)
179
+ Workday.holiday?(date, calendar: calendar)
180
+ end
181
+
182
+ # Public: Returns the last workday until the informed date.
183
+ # It returns the informed date in case it is a workday.
184
+ #
185
+ # date - End Date to check for workdays.
186
+ # calendar - Symbol informing in which calendar the date will be checked
187
+ # (default: :brazil).
188
+ #
189
+ # Examples
190
+ # Spok.last_workday(Date.new(2012, 10, 21))
191
+ # # => #<Date: 2012-10-19 ((2456220j,0s,0n),+0s,2299161j)>
192
+ def self.last_workday(date, calendar: Spok.default_calendar)
193
+ Workday.last_workday(date, calendar: calendar)
194
+ end
195
+
196
+ # Public: Returns the next workday starting from the informed date.
197
+ # It returns the informed date in case it is a workday.
198
+ #
199
+ # date - Start Date to check for workdays.
200
+ # calendar - Symbol informing in which calendar the date will be checked
201
+ # (default: :brazil).
202
+ #
203
+ # Examples
204
+ # Spok.next_workday(Date.new(2012, 10, 21))
205
+ # # => #<Date: 2012-10-19 ((2456220j,0s,0n),+0s,2299161j)>
206
+ def self.next_workday(date, calendar: Spok.default_calendar)
207
+ Workday.next_workday(date, calendar: calendar)
208
+ end
209
+
120
210
  # Public: Returns a Spok containing the same dates in a different calendar.
121
211
  #
122
212
  # calendar - Symbol informing calendar for new Spok (default: :brazil).
@@ -383,7 +383,6 @@ bovespa:
383
383
  - 2020-09-07
384
384
  - 2020-10-12
385
385
  - 2020-11-02
386
- - 2020-11-20
387
386
  - 2020-12-24
388
387
  - 2020-12-25
389
388
  - 2020-12-31
@@ -267,6 +267,7 @@ united_states:
267
267
  - 2020-01-01
268
268
  - 2020-01-20
269
269
  - 2020-02-17
270
+ - 2020-04-10
270
271
  - 2020-05-25
271
272
  - 2020-07-03
272
273
  - 2020-09-07
@@ -277,6 +278,7 @@ united_states:
277
278
  - 2021-01-01
278
279
  - 2021-01-18
279
280
  - 2021-02-15
281
+ - 2021-04-02
280
282
  - 2021-05-31
281
283
  - 2021-07-05
282
284
  - 2021-09-06
@@ -287,6 +289,7 @@ united_states:
287
289
  - 2021-12-31
288
290
  - 2022-01-17
289
291
  - 2022-02-21
292
+ - 2022-04-15
290
293
  - 2022-05-30
291
294
  - 2022-07-04
292
295
  - 2022-09-05
@@ -297,6 +300,7 @@ united_states:
297
300
  - 2023-01-02
298
301
  - 2023-01-16
299
302
  - 2023-02-20
303
+ - 2023-04-07
300
304
  - 2023-05-29
301
305
  - 2023-07-04
302
306
  - 2023-09-04
@@ -307,6 +311,7 @@ united_states:
307
311
  - 2024-01-01
308
312
  - 2024-01-15
309
313
  - 2024-02-19
314
+ - 2024-03-29
310
315
  - 2024-05-27
311
316
  - 2024-07-04
312
317
  - 2024-09-02
@@ -317,6 +322,7 @@ united_states:
317
322
  - 2025-01-01
318
323
  - 2025-01-20
319
324
  - 2025-02-17
325
+ - 2025-04-18
320
326
  - 2025-05-26
321
327
  - 2025-07-04
322
328
  - 2025-09-01
@@ -325,6 +331,7 @@ united_states:
325
331
  - 2025-11-27
326
332
  - 2025-12-25
327
333
  - 2026-01-01
334
+ - 2026-04-03
328
335
  - 2026-01-19
329
336
  - 2026-02-16
330
337
  - 2026-05-25
@@ -451,4 +458,4 @@ united_states:
451
458
  - 2038-11-11
452
459
  - 2038-11-25
453
460
  - 2038-12-24
454
- - 2038-12-31
461
+ - 2038-12-31
@@ -1,3 +1,3 @@
1
1
  class Spok
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.3'.freeze
3
3
  end
@@ -1,12 +1,13 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext'
3
+ require 'spok'
3
4
 
4
5
  class Spok
5
- # Public: Various methods useful for checking for restdays and workdays.
6
+ # Internal: Various methods useful for checking for restdays and workdays.
6
7
  # All methods are module methods and should be called on the Spok::Workday
7
8
  # module.
8
9
  module Workday
9
- # Public: Hash containing all weekdays.
10
+ # Internal: Hash containing all weekdays.
10
11
  WEEKDAYS = {
11
12
  sunday: 0,
12
13
  monday: 1,
@@ -17,7 +18,7 @@ class Spok
17
18
  saturday: 6
18
19
  }.freeze
19
20
 
20
- # Public: Checks if a given day is a restday.
21
+ # Internal: Checks if a given day is a restday.
21
22
  #
22
23
  # date - The Date to be checked.
23
24
  # calendar - Symbol informing in which calendar the date will be checked
@@ -33,7 +34,7 @@ class Spok
33
34
  self.weekend?(date) || self.holiday?(date, calendar: calendar)
34
35
  end
35
36
 
36
- # Public: Checks if a given day is a workday.
37
+ # Internal: Checks if a given day is a workday.
37
38
  #
38
39
  # date - The Date to be checked.
39
40
  # calendar - Symbol informing in which calendar the date will be checked
@@ -49,7 +50,7 @@ class Spok
49
50
  !restday?(date, calendar: calendar)
50
51
  end
51
52
 
52
- # Public: Checks if a given Date is on a weekend.
53
+ # Internal: Checks if a given Date is on a weekend.
53
54
  #
54
55
  # date - The Date to be checked.
55
56
  #
@@ -65,7 +66,7 @@ class Spok
65
66
  [WEEKDAYS[:saturday], WEEKDAYS[:sunday]].include? weekday
66
67
  end
67
68
 
68
- # Public: Checks if a given Date is on a holiday.
69
+ # Internal: Checks if a given Date is on a holiday.
69
70
  #
70
71
  # date - The Date to be checked.
71
72
  # calendar - Symbol informing in which calendar the date will be checked
@@ -82,7 +83,7 @@ class Spok
82
83
  dates.include?(date.to_date)
83
84
  end
84
85
 
85
- # Public: Returns the last workday until the informed date.
86
+ # Internal: Returns the last workday until the informed date.
86
87
  # It returns the informed date in case it is a workday.
87
88
  #
88
89
  # date - End Date to check for workdays.
@@ -98,7 +99,7 @@ class Spok
98
99
  last_workday((date - 1.day), calendar: calendar)
99
100
  end
100
101
 
101
- # Public: Returns the next workday starting from the informed date.
102
+ # Internal: Returns the next workday starting from the informed date.
102
103
  # It returns the informed date in case it is a workday.
103
104
  #
104
105
  # date - Start Date to check for workdays.
@@ -216,4 +216,64 @@ describe Spok do
216
216
  expect(default_calendar_was).to eq(:brazil)
217
217
  end
218
218
  end
219
+
220
+ describe '#restday?' do
221
+ it 'calls for the restday implementation' do
222
+ date = Date.new(2020, 4, 9)
223
+
224
+ expect(Spok::Workday).to receive(:restday?).with(date, calendar: :brazil).and_call_original
225
+
226
+ Spok.restday?(date)
227
+ end
228
+ end
229
+
230
+ describe '.workday?' do
231
+ it 'calls for the workday implementation' do
232
+ date = Date.new(2020, 4, 9)
233
+
234
+ expect(Spok::Workday).to receive(:workday?).with(date, calendar: :brazil).and_call_original
235
+
236
+ Spok.workday?(date)
237
+ end
238
+ end
239
+
240
+ describe '.weekend?' do
241
+ it 'calls for the weekend implementation' do
242
+ date = Date.new(2020, 4, 9)
243
+
244
+ expect(Spok::Workday).to receive(:weekend?).with(date).and_call_original
245
+
246
+ Spok.weekend?(date)
247
+ end
248
+ end
249
+
250
+ describe '.holiday?' do
251
+ it 'calls for the holiday implementation' do
252
+ date = Date.new(2020, 4, 9)
253
+
254
+ expect(Spok::Workday).to receive(:holiday?).with(date, calendar: :brazil).and_call_original
255
+
256
+ Spok.holiday?(date)
257
+ end
258
+ end
259
+
260
+ describe '.last_workday' do
261
+ it 'calls for the last workday implementation' do
262
+ date = Date.new(2020, 4, 9)
263
+
264
+ expect(Spok::Workday).to receive(:last_workday).with(date, calendar: :brazil).and_call_original
265
+
266
+ Spok.last_workday(date)
267
+ end
268
+ end
269
+
270
+ describe '.next_workday' do
271
+ it 'calls for the next workday implementation' do
272
+ date = Date.new(2020, 4, 9)
273
+
274
+ expect(Spok::Workday).to receive(:next_workday).with(date, calendar: :brazil).and_call_original
275
+
276
+ Spok.next_workday(date)
277
+ end
278
+ end
219
279
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'activesupport', '~> 5.1'
24
+ spec.add_dependency 'activesupport', '>= 5.1', '< 7.0'
25
25
 
26
26
  spec.add_development_dependency 'bundler'
27
27
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spok
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnetis Staff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +116,6 @@ files:
110
116
  - lib/spok/config/vietnam.yml
111
117
  - lib/spok/version.rb
112
118
  - lib/spok/workday.rb
113
- - pkg/spok-2.0.0.gem
114
119
  - spec/fixtures/custom-calendar.yml
115
120
  - spec/lib/spok/calendars_spec.rb
116
121
  - spec/lib/spok/workday_spec.rb
@@ -136,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
141
  - !ruby/object:Gem::Version
137
142
  version: '0'
138
143
  requirements: []
139
- rubygems_version: 3.0.4
144
+ rubygems_version: 3.1.2
140
145
  signing_key:
141
146
  specification_version: 4
142
147
  summary: A gem to work with periods of dates
Binary file