russian_workdays 2.5.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -154
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/{russian_workdays/dates.yml → dates.yml} +68 -1
- data/lib/russian_workdays/collection.rb +34 -14
- data/lib/russian_workdays/collection_preset.rb +12 -4
- data/lib/russian_workdays/day.rb +19 -11
- data/lib/russian_workdays/missing_year_error.rb +16 -0
- data/lib/russian_workdays/month.rb +15 -3
- data/lib/russian_workdays/version.rb +1 -1
- data/lib/russian_workdays/year.rb +13 -2
- data/lib/russian_workdays.rb +13 -4
- data/russian_workdays.gemspec +16 -13
- data/spec/lib/collection_spec.rb +84 -0
- data/spec/lib/day_spec.rb +135 -0
- data/spec/lib/month_spec.rb +62 -0
- data/spec/lib/year_spec.rb +50 -0
- data/spec/spec_helper.rb +2 -2
- metadata +47 -30
- data/.codeclimate.yml +0 -16
- data/.travis.yml +0 -3
- data/spec/collection_spec.rb +0 -27
- data/spec/day_spec.rb +0 -31
- data/spec/month_spec.rb +0 -27
- data/spec/year_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 202f95e7558fdf25ad74f1c2b22af5802bb0e2c44c51a6522f262127a7a13179
|
4
|
+
data.tar.gz: e025d8cd63eb3c63f8b34d6209c1470fce148f4f5af64155399777e9244f4563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d0c957efda7da66731790c28931ae96d693089dbb1ce4a0c810b6e37f026e06ab1b98351762199eb76207a36a789694b2385c24226c653297cede860b9ad28
|
7
|
+
data.tar.gz: 7a96dfcaebb479bfe423121ba739178897b5ddf7a8f1309d5a40169f0dcfe8cf9e2d4f862b42dc48168b1302b41fb2c957740ca96a69b58ccd5915a0bd9cc960
|
data/.rubocop.yml
CHANGED
@@ -1,155 +1,8 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Enabled: true
|
10
|
-
|
11
|
-
# Do not use braces for hash literals when they are the last argument of a
|
12
|
-
# method call.
|
13
|
-
Style/BracesAroundHashParameters:
|
14
|
-
Enabled: true
|
15
|
-
EnforcedStyle: context_dependent
|
16
|
-
|
17
|
-
# Align `when` with `case`.
|
18
|
-
Layout/CaseIndentation:
|
19
|
-
Enabled: true
|
20
|
-
|
21
|
-
# Align comments with method definitions.
|
22
|
-
Layout/CommentIndentation:
|
23
|
-
Enabled: true
|
24
|
-
|
25
|
-
Layout/ElseAlignment:
|
26
|
-
Enabled: true
|
27
|
-
|
28
|
-
# Align `end` with the matching keyword or starting expression except for
|
29
|
-
# assignments, where it should be aligned with the LHS.
|
30
|
-
Layout/EndAlignment:
|
31
|
-
Enabled: true
|
32
|
-
EnforcedStyleAlignWith: variable
|
33
|
-
AutoCorrect: true
|
34
|
-
|
35
|
-
Layout/EmptyLineAfterMagicComment:
|
36
|
-
Enabled: true
|
37
|
-
|
38
|
-
# In a regular class definition, no empty lines around the body.
|
39
|
-
Layout/EmptyLinesAroundClassBody:
|
40
|
-
Enabled: true
|
41
|
-
|
42
|
-
# In a regular method definition, no empty lines around the body.
|
43
|
-
Layout/EmptyLinesAroundMethodBody:
|
44
|
-
Enabled: true
|
45
|
-
|
46
|
-
# In a regular module definition, no empty lines around the body.
|
47
|
-
Layout/EmptyLinesAroundModuleBody:
|
48
|
-
Enabled: true
|
49
|
-
|
50
|
-
Layout/FirstParameterIndentation:
|
51
|
-
Enabled: true
|
52
|
-
|
53
|
-
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
54
|
-
Style/HashSyntax:
|
55
|
-
Enabled: true
|
56
|
-
|
57
|
-
# Method definitions after `private` or `protected` isolated calls need one
|
58
|
-
# extra level of indentation.
|
59
|
-
Layout/IndentationConsistency:
|
60
|
-
Enabled: true
|
61
|
-
EnforcedStyle: rails
|
62
|
-
|
63
|
-
# Two spaces, no tabs (for indentation).
|
64
|
-
Layout/IndentationWidth:
|
65
|
-
Enabled: true
|
66
|
-
|
67
|
-
Layout/LeadingCommentSpace:
|
68
|
-
Enabled: true
|
69
|
-
|
70
|
-
Layout/SpaceAfterColon:
|
71
|
-
Enabled: true
|
72
|
-
|
73
|
-
Layout/SpaceAfterComma:
|
74
|
-
Enabled: true
|
75
|
-
|
76
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
77
|
-
Enabled: true
|
78
|
-
|
79
|
-
Layout/SpaceAroundKeyword:
|
80
|
-
Enabled: true
|
81
|
-
|
82
|
-
Layout/SpaceAroundOperators:
|
83
|
-
Enabled: true
|
84
|
-
|
85
|
-
Layout/SpaceBeforeComma:
|
86
|
-
Enabled: true
|
87
|
-
|
88
|
-
Layout/SpaceBeforeFirstArg:
|
89
|
-
Enabled: true
|
90
|
-
|
91
|
-
Style/DefWithParentheses:
|
92
|
-
Enabled: true
|
93
|
-
|
94
|
-
# Defining a method with parameters needs parentheses.
|
95
|
-
Style/MethodDefParentheses:
|
96
|
-
Enabled: true
|
97
|
-
|
98
|
-
Style/FrozenStringLiteralComment:
|
99
|
-
Enabled: true
|
100
|
-
EnforcedStyle: always
|
101
|
-
|
102
|
-
# Use `foo {}` not `foo{}`.
|
103
|
-
Layout/SpaceBeforeBlockBraces:
|
104
|
-
Enabled: true
|
105
|
-
|
106
|
-
# Use `foo { bar }` not `foo {bar}`.
|
107
|
-
Layout/SpaceInsideBlockBraces:
|
108
|
-
Enabled: true
|
109
|
-
|
110
|
-
# Use `{ a: 1 }` not `{a:1}`.
|
111
|
-
Layout/SpaceInsideHashLiteralBraces:
|
112
|
-
Enabled: true
|
113
|
-
|
114
|
-
Layout/SpaceInsideParens:
|
115
|
-
Enabled: true
|
116
|
-
|
117
|
-
# Check quotes usage according to lint rule below.
|
118
|
-
Style/StringLiterals:
|
119
|
-
Enabled: true
|
120
|
-
EnforcedStyle: double_quotes
|
121
|
-
|
122
|
-
# Detect hard tabs, no hard tabs.
|
123
|
-
Layout/Tab:
|
124
|
-
Enabled: true
|
125
|
-
|
126
|
-
# Blank lines should not have any spaces.
|
127
|
-
Layout/TrailingBlankLines:
|
128
|
-
Enabled: true
|
129
|
-
|
130
|
-
# No trailing whitespace.
|
131
|
-
Layout/TrailingWhitespace:
|
132
|
-
Enabled: true
|
133
|
-
|
134
|
-
# Use quotes for string literals when they are enough.
|
135
|
-
Style/UnneededPercentQ:
|
136
|
-
Enabled: true
|
137
|
-
|
138
|
-
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
139
|
-
Lint/RequireParentheses:
|
140
|
-
Enabled: true
|
141
|
-
|
142
|
-
Lint/StringConversionInInterpolation:
|
143
|
-
Enabled: true
|
144
|
-
|
145
|
-
Style/RedundantReturn:
|
146
|
-
Enabled: true
|
147
|
-
AllowMultipleReturnValues: true
|
148
|
-
|
149
|
-
Style/Semicolon:
|
150
|
-
Enabled: true
|
151
|
-
AllowAsExpressionSeparator: true
|
152
|
-
|
153
|
-
# Prefer Foo.method over Foo::method
|
154
|
-
Style/ColonMethodCall:
|
155
|
-
Enabled: true
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Lint/MissingSuper:
|
6
|
+
Enabled: false
|
7
|
+
Metrics/BlockLength:
|
8
|
+
AllowedMethods: ['describe', 'context']
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'russian_workdays'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -435,4 +435,71 @@
|
|
435
435
|
:preholidays:
|
436
436
|
- 2022-02-22
|
437
437
|
- 2022-03-05
|
438
|
-
- 2022-11-03
|
438
|
+
- 2022-11-03
|
439
|
+
---
|
440
|
+
2023:
|
441
|
+
:holidays:
|
442
|
+
- 2023-01-02
|
443
|
+
- 2023-01-03
|
444
|
+
- 2023-01-04
|
445
|
+
- 2023-01-05
|
446
|
+
- 2023-01-06
|
447
|
+
- 2023-02-23
|
448
|
+
- 2023-02-24
|
449
|
+
- 2023-03-08
|
450
|
+
- 2023-05-01
|
451
|
+
- 2023-05-08
|
452
|
+
- 2023-05-09
|
453
|
+
- 2023-06-12
|
454
|
+
- 2023-11-06
|
455
|
+
:preholidays:
|
456
|
+
- 2023-02-22
|
457
|
+
- 2023-03-07
|
458
|
+
- 2023-11-03
|
459
|
+
2024:
|
460
|
+
:holidays:
|
461
|
+
- 2024-01-01
|
462
|
+
- 2024-01-02
|
463
|
+
- 2024-01-03
|
464
|
+
- 2024-01-04
|
465
|
+
- 2024-01-05
|
466
|
+
- 2024-01-08
|
467
|
+
- 2024-02-23
|
468
|
+
- 2024-03-08
|
469
|
+
- 2024-04-29
|
470
|
+
- 2024-04-30
|
471
|
+
- 2024-05-01
|
472
|
+
- 2024-05-09
|
473
|
+
- 2024-05-10
|
474
|
+
- 2024-06-12
|
475
|
+
- 2024-11-04
|
476
|
+
- 2024-12-30
|
477
|
+
- 2024-12-31
|
478
|
+
:preholidays:
|
479
|
+
- 2024-02-22
|
480
|
+
- 2024-03-07
|
481
|
+
- 2024-05-08
|
482
|
+
- 2024-06-11
|
483
|
+
- 2024-11-02
|
484
|
+
2025:
|
485
|
+
:holidays:
|
486
|
+
- 2025-01-01
|
487
|
+
- 2025-01-02
|
488
|
+
- 2025-01-03
|
489
|
+
- 2025-01-06
|
490
|
+
- 2025-01-07
|
491
|
+
- 2025-01-08
|
492
|
+
- 2025-05-01
|
493
|
+
- 2025-05-02
|
494
|
+
- 2025-05-08
|
495
|
+
- 2025-05-09
|
496
|
+
- 2025-06-12
|
497
|
+
- 2025-06-13
|
498
|
+
- 2025-11-03
|
499
|
+
- 2025-11-04
|
500
|
+
- 2025-12-31
|
501
|
+
:preholidays:
|
502
|
+
- 2025-03-07
|
503
|
+
- 2025-04-30
|
504
|
+
- 2025-06-11
|
505
|
+
- 2025-11-01
|
@@ -3,32 +3,52 @@
|
|
3
3
|
module RussianWorkdays
|
4
4
|
class Collection
|
5
5
|
include Enumerable
|
6
|
-
|
6
|
+
|
7
|
+
WORK_HOURS_PER_DAY = {
|
8
|
+
24 => 4.8,
|
9
|
+
36 => 7.2,
|
10
|
+
40 => 8.0
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
attr_reader :collection
|
7
14
|
|
8
15
|
def initialize(collection)
|
9
|
-
unless
|
10
|
-
|
11
|
-
|
12
|
-
|
16
|
+
raise ArgumentError, 'Must be a Array or Range object' unless [Array, Range].include?(collection.class)
|
17
|
+
|
18
|
+
collection.each { |date| raise MissingYearError, date.year unless DATES.key?(date.year) }
|
19
|
+
|
20
|
+
@collection = collection.map { |day| Day.new(day) }
|
13
21
|
end
|
14
22
|
|
15
|
-
def each
|
16
|
-
|
23
|
+
def each(&block)
|
24
|
+
collection.each(&block)
|
17
25
|
end
|
18
26
|
|
19
27
|
%w[holiday preholiday work].each do |type|
|
20
28
|
define_method "#{type}s" do
|
21
|
-
|
29
|
+
collection.select { |day| day.send("#{type}?") }.map(&:to_date)
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
def work_hours_count(work_hours_per_week =
|
26
|
-
unless
|
27
|
-
raise ArgumentError, "Unknown work hours count. Must be one of #{
|
33
|
+
def work_hours_count(work_hours_per_week = WORK_HOURS_PER_DAY.keys.last)
|
34
|
+
unless WORK_HOURS_PER_DAY.keys.include?(work_hours_per_week)
|
35
|
+
raise ArgumentError, "Unknown work hours count. Must be one of: #{WORK_HOURS_PER_DAY.keys.join(', ')}"
|
36
|
+
end
|
37
|
+
|
38
|
+
collection.sum { |day| calculate_work_hours(day, work_hours_per_week) }.ceil(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def calculate_work_hours(day, work_hours_per_week)
|
44
|
+
case day.type
|
45
|
+
when :work
|
46
|
+
WORK_HOURS_PER_DAY[work_hours_per_week]
|
47
|
+
when :preholiday
|
48
|
+
WORK_HOURS_PER_DAY[work_hours_per_week] - 1
|
49
|
+
else
|
50
|
+
0
|
28
51
|
end
|
29
|
-
work_hours_per_day = (work_hours_per_week / 5.to_f)
|
30
|
-
mapping = { work: work_hours_per_day, preholiday: work_hours_per_day - 1 }
|
31
|
-
@collection.map { |i| mapping.fetch(Day.new(i).type, 0) }.sum.ceil(1)
|
32
52
|
end
|
33
53
|
end
|
34
54
|
end
|
@@ -1,8 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'forwardable'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
module RussianWorkdays
|
6
|
+
class CollectionPreset
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :dates, :holidays, :preholidays, :works, :work_hours_count
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def dates
|
13
|
+
Collection.new(range)
|
14
|
+
end
|
15
|
+
end
|
8
16
|
end
|
data/lib/russian_workdays/day.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'missing_year_error'
|
4
4
|
|
5
5
|
module RussianWorkdays
|
6
|
-
DATES = YAML.load_file(File.join(__dir__, "dates.yml")).freeze
|
7
|
-
|
8
6
|
class Day
|
7
|
+
attr_reader :date
|
8
|
+
|
9
9
|
def initialize(date)
|
10
|
+
raise ArgumentError, 'Must be a Date object' unless date.is_a?(::Date)
|
11
|
+
raise MissingYearError, date.year unless DATES.key?(date.year)
|
12
|
+
|
10
13
|
@date = date
|
11
|
-
raise ArgumentError, "Must be a Date object" unless @date.is_a?(::Date)
|
12
|
-
raise ArgumentError, "Data missing for that year" unless DATES.key?(@date.year)
|
13
14
|
end
|
14
15
|
|
15
16
|
def holiday?
|
16
|
-
|
17
|
+
return true if DATES[date.year][:holidays].include?(date)
|
18
|
+
|
19
|
+
!preholiday? && weekend?
|
17
20
|
end
|
18
21
|
|
19
22
|
def preholiday?
|
20
|
-
DATES[
|
23
|
+
DATES[date.year][:preholidays].include?(date)
|
21
24
|
end
|
22
25
|
|
23
26
|
def work?
|
@@ -27,13 +30,18 @@ module RussianWorkdays
|
|
27
30
|
def type
|
28
31
|
return :holiday if holiday?
|
29
32
|
return :preholiday if preholiday?
|
30
|
-
|
33
|
+
|
34
|
+
:work if work?
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_date
|
38
|
+
date
|
31
39
|
end
|
32
40
|
|
33
41
|
private
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
def weekend?
|
44
|
+
date.sunday? || date.saturday?
|
45
|
+
end
|
38
46
|
end
|
39
47
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RussianWorkdays
|
4
|
+
class MissingYearError < ArgumentError
|
5
|
+
attr_reader :year
|
6
|
+
|
7
|
+
def initialize(year)
|
8
|
+
super
|
9
|
+
@year = year
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
"Data missing for that year: #{year}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,12 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'missing_year_error'
|
4
|
+
require_relative 'collection_preset'
|
4
5
|
|
5
6
|
module RussianWorkdays
|
6
7
|
class Month < CollectionPreset
|
8
|
+
attr_reader :year, :month
|
9
|
+
|
7
10
|
def initialize(year = Date.today.year, month = 1)
|
8
|
-
raise
|
9
|
-
|
11
|
+
raise MissingYearError, year unless DATES.key?(year)
|
12
|
+
raise ArgumentError, 'Must be a number between 1 and 12' unless (1..12).include?(month)
|
13
|
+
|
14
|
+
@year = year
|
15
|
+
@month = month
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def range
|
21
|
+
Date.new(year, month, 1)..Date.new(year, month, -1)
|
10
22
|
end
|
11
23
|
end
|
12
24
|
end
|
@@ -1,11 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'missing_year_error'
|
4
|
+
require_relative 'collection_preset'
|
4
5
|
|
5
6
|
module RussianWorkdays
|
6
7
|
class Year < CollectionPreset
|
8
|
+
attr_reader :year
|
9
|
+
|
7
10
|
def initialize(year = Date.today.year)
|
8
|
-
|
11
|
+
raise MissingYearError, year unless DATES.key?(year)
|
12
|
+
|
13
|
+
@year = year
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def range
|
19
|
+
Date.new(year, 1, 1)..Date.new(year, 12, -1)
|
9
20
|
end
|
10
21
|
end
|
11
22
|
end
|
data/lib/russian_workdays.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative
|
6
|
-
require_relative
|
3
|
+
require 'yaml'
|
4
|
+
require 'date'
|
5
|
+
require_relative 'russian_workdays/collection'
|
6
|
+
require_relative 'russian_workdays/day'
|
7
|
+
require_relative 'russian_workdays/month'
|
8
|
+
require_relative 'russian_workdays/year'
|
9
|
+
|
10
|
+
module RussianWorkdays
|
11
|
+
YAML_FILE = File.read(File.join(__dir__, 'dates.yml')).freeze
|
12
|
+
DATES = YAML.safe_load(YAML_FILE, permitted_classes: [::Date, Symbol]).freeze
|
13
|
+
|
14
|
+
private_constant :YAML_FILE
|
15
|
+
end
|
data/russian_workdays.gemspec
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require_relative 'lib/russian_workdays/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version =
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
8
|
+
spec.name = 'russian_workdays'
|
9
|
+
spec.version = RussianWorkdays::VERSION
|
10
|
+
spec.authors = ['heckfy']
|
11
|
+
spec.email = ['heckfyoz@gmail.com']
|
12
|
+
spec.summary = 'Russian workdays'
|
13
|
+
spec.description = 'Производственный календарь РФ'
|
14
|
+
spec.homepage = 'https://github.com/heckfy/russian_workdays'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.required_ruby_version = '>= 2.6.0'
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0")
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
20
22
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 2.4'
|
24
|
+
spec.add_development_dependency 'rake', '~> 13.2'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 1.71.1'
|
24
27
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RussianWorkdays::Collection do
|
6
|
+
subject(:instance_of_collection) { described_class.new(range) }
|
7
|
+
|
8
|
+
let(:year) { 2014 }
|
9
|
+
let(:month) { 2 }
|
10
|
+
let(:range) { (Date.new(year, month, 20)..Date.new(year, month, -1)) }
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
context 'when missing data for that year' do
|
14
|
+
let(:year) { 1990 }
|
15
|
+
|
16
|
+
it 'raise MissingYearError' do
|
17
|
+
expect { instance_of_collection }
|
18
|
+
.to raise_error(RussianWorkdays::MissingYearError, /Data missing for that year: 1990/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when range is not Array or Range object' do
|
23
|
+
let(:range) { 0 }
|
24
|
+
|
25
|
+
it 'raise ArgumentError' do
|
26
|
+
expect { instance_of_collection }
|
27
|
+
.to raise_error(ArgumentError, /Must be a Array or Range object/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#holidays' do
|
33
|
+
let(:expected_array) do
|
34
|
+
[22, 23].map { |day| Date.new(year, month, day) }
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'array of holidays Date' do
|
38
|
+
expect(instance_of_collection.holidays).to eq(expected_array)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#preholidays' do
|
43
|
+
let(:expected_array) do
|
44
|
+
[Date.new(year, month, 24)]
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'array of preholidays Date' do
|
48
|
+
expect(instance_of_collection.preholidays).to eq(expected_array)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#works' do
|
53
|
+
let(:expected_array) do
|
54
|
+
[20, 21, 24, 25, 26, 27, 28].map do |day|
|
55
|
+
Date.new(year, month, day)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'array of works Date' do
|
60
|
+
expect(instance_of_collection.works).to eq(expected_array)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#work_hours_count' do
|
65
|
+
context 'when work_hours_per_week is not one of: 24, 36, 40' do
|
66
|
+
it 'raise ArgumentError' do
|
67
|
+
expect { instance_of_collection.work_hours_count(10) }
|
68
|
+
.to raise_error(ArgumentError, /Unknown work hours count. Must be one of: 24, 36, 40/)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when week have 24 work hours' do
|
73
|
+
it { expect(instance_of_collection.work_hours_count(24)).to eq(32.6) }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when week have 36 work hours' do
|
77
|
+
it { expect(instance_of_collection.work_hours_count(36)).to eq(49.4) }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when week have 40 work hours' do
|
81
|
+
it { expect(instance_of_collection.work_hours_count).to eq(55) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
describe RussianWorkdays::Day do
|
7
|
+
subject(:work?) { described_class.new(date).work? }
|
8
|
+
|
9
|
+
let(:work_date) { Date.new(2014, 5, 5) }
|
10
|
+
let(:preholiday_date) { Date.new(2014, 2, 24) }
|
11
|
+
let(:holiday_date) { Date.new(2014, 5, 1) }
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
context 'when date is not Date object' do
|
15
|
+
let(:date) { 'string' }
|
16
|
+
|
17
|
+
it 'raise ArgumentError' do
|
18
|
+
expect { described_class.new(date) }.to raise_error(ArgumentError, /Must be a Date object/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when missing data for that year' do
|
23
|
+
let(:date) { Date.new(1990, 1, 1) }
|
24
|
+
|
25
|
+
it 'raise MissingYearError' do
|
26
|
+
expect { described_class.new(date) }
|
27
|
+
.to raise_error(RussianWorkdays::MissingYearError, /Data missing for that year: 1990/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#work?' do
|
33
|
+
context 'when date is work day' do
|
34
|
+
let(:date) { work_date }
|
35
|
+
|
36
|
+
it 'return true' do
|
37
|
+
is_expected.to eq(true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when date is preholiday' do
|
42
|
+
let(:date) { preholiday_date }
|
43
|
+
|
44
|
+
it 'return true' do
|
45
|
+
is_expected.to eq(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when date is holiday' do
|
50
|
+
let(:date) { holiday_date }
|
51
|
+
|
52
|
+
it 'return false' do
|
53
|
+
is_expected.to eq(false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#preholiday?' do
|
59
|
+
context 'when date is work day' do
|
60
|
+
let(:date) { work_date }
|
61
|
+
|
62
|
+
it 'return true' do
|
63
|
+
expect(RussianWorkdays::Day.new(date).preholiday?).to eq(false)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when date is preholiday' do
|
68
|
+
let(:date) { preholiday_date }
|
69
|
+
|
70
|
+
it 'return true' do
|
71
|
+
expect(RussianWorkdays::Day.new(date).preholiday?).to eq(true)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when date is holiday' do
|
76
|
+
let(:date) { holiday_date }
|
77
|
+
|
78
|
+
it 'return false' do
|
79
|
+
expect(RussianWorkdays::Day.new(date).preholiday?).to eq(false)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#holiday?' do
|
85
|
+
context 'when date is work day' do
|
86
|
+
let(:date) { work_date }
|
87
|
+
|
88
|
+
it 'return true' do
|
89
|
+
expect(RussianWorkdays::Day.new(date).holiday?).to eq(false)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when date is preholiday' do
|
94
|
+
let(:date) { preholiday_date }
|
95
|
+
|
96
|
+
it 'return true' do
|
97
|
+
expect(RussianWorkdays::Day.new(date).holiday?).to eq(false)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when date is holiday' do
|
102
|
+
let(:date) { holiday_date }
|
103
|
+
|
104
|
+
it 'return false' do
|
105
|
+
expect(RussianWorkdays::Day.new(date).holiday?).to eq(true)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#type' do
|
111
|
+
context 'when date is work day' do
|
112
|
+
let(:date) { work_date }
|
113
|
+
|
114
|
+
it 'return :work' do
|
115
|
+
expect(RussianWorkdays::Day.new(date).type).to eq(:work)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when date is preholiday' do
|
120
|
+
let(:date) { preholiday_date }
|
121
|
+
|
122
|
+
it 'return :preholiday' do
|
123
|
+
expect(RussianWorkdays::Day.new(date).type).to eq(:preholiday)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when date is holiday' do
|
128
|
+
let(:date) { holiday_date }
|
129
|
+
|
130
|
+
it 'return :holiday' do
|
131
|
+
expect(RussianWorkdays::Day.new(date).type).to eq(:holiday)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RussianWorkdays::Month do
|
6
|
+
subject(:instance_of_month) { described_class.new(year, month) }
|
7
|
+
|
8
|
+
let(:year) { 2014 }
|
9
|
+
let(:month) { 2 }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
context 'when missing data for that year' do
|
13
|
+
let(:year) { 1990 }
|
14
|
+
|
15
|
+
it 'raise MissingYearError' do
|
16
|
+
expect { instance_of_month }
|
17
|
+
.to raise_error(RussianWorkdays::MissingYearError, /Data missing for that year: 1990/)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when month is not in 1..12' do
|
22
|
+
let(:month) { 0 }
|
23
|
+
|
24
|
+
it 'raise ArgumentError' do
|
25
|
+
expect { instance_of_month }
|
26
|
+
.to raise_error(ArgumentError, /Must be a number between 1 and 12/)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#holidays' do
|
32
|
+
let(:expected_array) do
|
33
|
+
[1, 2, 8, 9, 15, 16, 22, 23].map { |day| Date.new(year, month, day) }
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'array of holidays Date' do
|
37
|
+
expect(instance_of_month.holidays).to eq(expected_array)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#preholidays' do
|
42
|
+
let(:expected_array) do
|
43
|
+
[Date.new(year, month, 24)]
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'array of preholidays Date' do
|
47
|
+
expect(instance_of_month.preholidays).to eq(expected_array)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#works' do
|
52
|
+
let(:expected_array) do
|
53
|
+
[3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28].map do |day|
|
54
|
+
Date.new(year, month, day)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'array of works Date' do
|
59
|
+
expect(instance_of_month.works).to eq(expected_array)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RussianWorkdays::Year do
|
6
|
+
subject(:instance_of_year) { described_class.new(year) }
|
7
|
+
|
8
|
+
let(:year) { 2014 }
|
9
|
+
|
10
|
+
describe '#initialize' do
|
11
|
+
context 'when missing data for that year' do
|
12
|
+
let(:year) { 1990 }
|
13
|
+
|
14
|
+
it 'raise MissingYearError' do
|
15
|
+
expect { instance_of_year }
|
16
|
+
.to raise_error(RussianWorkdays::MissingYearError, /Data missing for that year: 1990/)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#holidays' do
|
22
|
+
let(:expected_array) do
|
23
|
+
(1..12).flat_map { |month| RussianWorkdays::Month.new(year, month).holidays }
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'array of holidays Date' do
|
27
|
+
expect(instance_of_year.holidays).to eq(expected_array)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#preholidays' do
|
32
|
+
let(:expected_array) do
|
33
|
+
(1..12).flat_map { |month| RussianWorkdays::Month.new(year, month).preholidays }
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'array of preholidays Date' do
|
37
|
+
expect(instance_of_year.preholidays).to eq(expected_array)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#works' do
|
42
|
+
let(:expected_array) do
|
43
|
+
(1..12).flat_map { |month| RussianWorkdays::Month.new(year, month).works }
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'array of works Date' do
|
47
|
+
expect(instance_of_year.works).to eq(expected_array)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russian_workdays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- heckfy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,76 +16,94 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.4'
|
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
|
-
version: '
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 1.71.1
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 1.71.1
|
55
69
|
description: Производственный календарь РФ
|
56
70
|
email:
|
57
71
|
- heckfyoz@gmail.com
|
58
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- setup
|
59
75
|
extensions: []
|
60
76
|
extra_rdoc_files: []
|
61
77
|
files:
|
62
|
-
- ".codeclimate.yml"
|
63
78
|
- ".gitignore"
|
64
79
|
- ".rubocop.yml"
|
65
|
-
-
|
80
|
+
- CHANGELOG.md
|
66
81
|
- Gemfile
|
67
82
|
- LICENSE.txt
|
68
83
|
- README.md
|
69
84
|
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/dates.yml
|
70
88
|
- lib/russian_workdays.rb
|
71
89
|
- lib/russian_workdays/collection.rb
|
72
90
|
- lib/russian_workdays/collection_preset.rb
|
73
|
-
- lib/russian_workdays/dates.yml
|
74
91
|
- lib/russian_workdays/day.rb
|
92
|
+
- lib/russian_workdays/missing_year_error.rb
|
75
93
|
- lib/russian_workdays/month.rb
|
76
94
|
- lib/russian_workdays/version.rb
|
77
95
|
- lib/russian_workdays/year.rb
|
78
96
|
- russian_workdays.gemspec
|
79
|
-
- spec/collection_spec.rb
|
80
|
-
- spec/day_spec.rb
|
81
|
-
- spec/month_spec.rb
|
97
|
+
- spec/lib/collection_spec.rb
|
98
|
+
- spec/lib/day_spec.rb
|
99
|
+
- spec/lib/month_spec.rb
|
100
|
+
- spec/lib/year_spec.rb
|
82
101
|
- spec/spec_helper.rb
|
83
|
-
- spec/year_spec.rb
|
84
102
|
homepage: https://github.com/heckfy/russian_workdays
|
85
103
|
licenses:
|
86
104
|
- MIT
|
87
105
|
metadata: {}
|
88
|
-
post_install_message:
|
106
|
+
post_install_message:
|
89
107
|
rdoc_options: []
|
90
108
|
require_paths:
|
91
109
|
- lib
|
@@ -93,21 +111,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
111
|
requirements:
|
94
112
|
- - ">="
|
95
113
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
114
|
+
version: 2.6.0
|
97
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
116
|
requirements:
|
99
117
|
- - ">="
|
100
118
|
- !ruby/object:Gem::Version
|
101
119
|
version: '0'
|
102
120
|
requirements: []
|
103
|
-
|
104
|
-
|
105
|
-
signing_key:
|
121
|
+
rubygems_version: 3.4.10
|
122
|
+
signing_key:
|
106
123
|
specification_version: 4
|
107
124
|
summary: Russian workdays
|
108
125
|
test_files:
|
109
|
-
- spec/collection_spec.rb
|
110
|
-
- spec/day_spec.rb
|
111
|
-
- spec/month_spec.rb
|
126
|
+
- spec/lib/collection_spec.rb
|
127
|
+
- spec/lib/day_spec.rb
|
128
|
+
- spec/lib/month_spec.rb
|
129
|
+
- spec/lib/year_spec.rb
|
112
130
|
- spec/spec_helper.rb
|
113
|
-
- spec/year_spec.rb
|
data/.codeclimate.yml
DELETED
data/.travis.yml
DELETED
data/spec/collection_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe RussianWorkdays::Collection do
|
6
|
-
before(:all) do
|
7
|
-
@collection = RussianWorkdays::Collection.new((Date.new(2014, 1, 1)..Date.new(2014, 12, -1)))
|
8
|
-
@holidays = %w[2014-01-01 2014-03-22 2014-07-12 2014-09-06 2014-10-26 2014-12-28]
|
9
|
-
@preholidays = %w[2014-02-24 2014-03-07 2014-04-30 2014-05-08 2014-06-11 2014-12-31]
|
10
|
-
@works = %w[2014-01-09 2014-02-03 2014-05-27 2014-07-22 2014-11-11 2014-12-30]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return the right preholiday days" do
|
14
|
-
preholidays = @collection.preholidays.map(&:to_s)
|
15
|
-
expect(preholidays).to eq(@preholidays)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return the right holydays" do
|
19
|
-
holidays = @collection.holidays.map(&:to_s)
|
20
|
-
expect(holidays).to include(*@holidays)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return the right preholiday works" do
|
24
|
-
works = @collection.works.map(&:to_s)
|
25
|
-
expect(works).to include(*@works)
|
26
|
-
end
|
27
|
-
end
|
data/spec/day_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "date"
|
5
|
-
|
6
|
-
describe RussianWorkdays::Year do
|
7
|
-
before(:all) do
|
8
|
-
@year = RussianWorkdays::Year.new(2014)
|
9
|
-
@holidays = %w[2014-05-01 2014-05-02 2014-05-03 2014-05-04]
|
10
|
-
@preholidays = %w[2014-02-24 2014-03-07 2014-04-30 2014-05-08 2014-06-11 2014-12-31]
|
11
|
-
@works = %w[2014-05-05 2014-05-06 2014-05-06]
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return true if date is preholiday day" do
|
15
|
-
@preholidays.each do |date|
|
16
|
-
expect(RussianWorkdays::Day.new(Date.parse(date)).preholiday?).to eq(true)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return true if date is holiday day" do
|
21
|
-
@holidays.each do |date|
|
22
|
-
expect(RussianWorkdays::Day.new(Date.parse(date)).holiday?).to eq(true)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should return true if date is work day" do
|
27
|
-
@works.each do |date|
|
28
|
-
expect(RussianWorkdays::Day.new(Date.parse(date)).work?).to eq(true)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/month_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe RussianWorkdays::Month do
|
6
|
-
before(:all) do
|
7
|
-
@month = RussianWorkdays::Month.new(2014, 5)
|
8
|
-
@holidays = %w[2014-05-01 2014-05-02 2014-05-03 2014-05-04]
|
9
|
-
@preholidays = %w[2014-05-08]
|
10
|
-
@works = %w[2014-05-05 2014-05-06 2014-05-06]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return the right preholiday days" do
|
14
|
-
preholidays = @month.preholidays.map(&:to_s)
|
15
|
-
expect(preholidays).to eq(@preholidays)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return the right holydays" do
|
19
|
-
holidays = @month.holidays.map(&:to_s)
|
20
|
-
expect(holidays).to include(*@holidays)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return the right preholiday works" do
|
24
|
-
works = @month.works.map(&:to_s)
|
25
|
-
expect(works).to include(*@works)
|
26
|
-
end
|
27
|
-
end
|
data/spec/year_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe RussianWorkdays::Year do
|
6
|
-
before(:all) do
|
7
|
-
@year = RussianWorkdays::Year.new(2014)
|
8
|
-
@holidays = %w[2014-05-01 2014-05-02 2014-05-03 2014-05-04]
|
9
|
-
@preholidays = %w[2014-02-24 2014-03-07 2014-04-30 2014-05-08 2014-06-11 2014-12-31]
|
10
|
-
@works = %w[2014-05-05 2014-05-06 2014-05-06]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return the right preholiday days" do
|
14
|
-
preholidays = @year.preholidays.map(&:to_s)
|
15
|
-
expect(preholidays).to eq(@preholidays)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return the right holydays" do
|
19
|
-
holidays = @year.holidays.map(&:to_s)
|
20
|
-
expect(holidays).to include(*@holidays)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return the right preholiday works" do
|
24
|
-
works = @year.works.map(&:to_s)
|
25
|
-
expect(works).to include(*@works)
|
26
|
-
end
|
27
|
-
end
|