merch_calendar 0.1.0.rc1 → 0.1.0.rc2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +0 -10
- data/lib/merch_calendar/util.rb +31 -2
- data/lib/merch_calendar/version.rb +1 -1
- data/lib/merch_calendar.rb +1 -3
- data/spec/merch_calendar_spec.rb +64 -18
- data/spec/spec_helper.rb +12 -1
- metadata +2 -8
- data/lib/merch_calendar/configurable.rb +0 -28
- data/lib/merch_calendar/configuration.rb +0 -13
- data/spec/merch_calendar/configurable_spec.rb +0 -19
- data/spec/merch_calendar/configuration_spec.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4258c9ca91b7427a13a40d020ea448f7a0bce7d3
|
|
4
|
+
data.tar.gz: e5892f68ea348e3901339aebdd186200773333bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 50c31a68c19cc6edd3aecf26467788afd0c23d1f688c97d2d08ee1a06ebe2c2ea6cd67445f891a8b6f22371a509a7cb4779023f6d48e6022e54b2c4d1f5e9462
|
|
7
|
+
data.tar.gz: d5a02533ff081b5d4fe07b3ad80fd882a62834c19a79023351c3c079664b9b169fd5e7cfb2a8c5026aceb81e25e63637280dd0ed13402212df80530e47283e08
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -18,16 +18,6 @@ Add the following line to your `Gemfile`:
|
|
|
18
18
|
gem "merch_calendar"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
## Configuration
|
|
23
|
-
```ruby
|
|
24
|
-
# NOTE: Configuration will be added soon, but is currently NOT available.
|
|
25
|
-
MerchCalendar.configure do |config|
|
|
26
|
-
# The month that Q1 begins. The default is 8 (August)
|
|
27
|
-
config.quarter_start_month = 8
|
|
28
|
-
end
|
|
29
|
-
```
|
|
30
|
-
|
|
31
21
|
## Usage
|
|
32
22
|
|
|
33
23
|
For converting a date into a `MerchWeek` object.
|
data/lib/merch_calendar/util.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require "merch_calendar/retail_calendar"
|
|
2
|
+
require "merch_calendar/fiscal_year_calendar"
|
|
3
|
+
|
|
1
4
|
module MerchCalendar
|
|
2
5
|
|
|
3
6
|
# Utility methods for the merch calendar
|
|
@@ -85,7 +88,7 @@ module MerchCalendar
|
|
|
85
88
|
#
|
|
86
89
|
# @return [Date] the starting date of the specified quarter
|
|
87
90
|
def start_of_quarter(year, quarter)
|
|
88
|
-
|
|
91
|
+
fiscal_year_calendar.start_of_quarter(year + 1, quarter)
|
|
89
92
|
end
|
|
90
93
|
|
|
91
94
|
# The end date of the quarter
|
|
@@ -95,7 +98,7 @@ module MerchCalendar
|
|
|
95
98
|
#
|
|
96
99
|
# @return [Date] the ending date of the specified quarter
|
|
97
100
|
def end_of_quarter(year, quarter)
|
|
98
|
-
|
|
101
|
+
fiscal_year_calendar.end_of_quarter(year + 1, quarter)
|
|
99
102
|
end
|
|
100
103
|
|
|
101
104
|
|
|
@@ -175,6 +178,10 @@ module MerchCalendar
|
|
|
175
178
|
@retail_calendar ||= RetailCalendar.new
|
|
176
179
|
end
|
|
177
180
|
|
|
181
|
+
def fiscal_year_calendar
|
|
182
|
+
@fiscal_year_calendar ||= FiscalYearCalendar.new
|
|
183
|
+
end
|
|
184
|
+
|
|
178
185
|
# Reads the provided parameter and converts the value
|
|
179
186
|
# to a MERCH MONTH
|
|
180
187
|
def get_merch_month_param(param)
|
|
@@ -199,6 +206,28 @@ module MerchCalendar
|
|
|
199
206
|
# Load the utils into the MerchCalendar namespace
|
|
200
207
|
class << self
|
|
201
208
|
include Util
|
|
209
|
+
extend Gem::Deprecate
|
|
210
|
+
|
|
211
|
+
[
|
|
212
|
+
:start_of_week,
|
|
213
|
+
:end_of_week,
|
|
214
|
+
:start_of_month,
|
|
215
|
+
:end_of_month,
|
|
216
|
+
:start_of_year,
|
|
217
|
+
:end_of_year,
|
|
218
|
+
:weeks_in_year,
|
|
219
|
+
:merch_months_in,
|
|
220
|
+
].each do |method|
|
|
221
|
+
deprecate method, "#{MerchCalendar::RetailCalendar}##{method}", DEPRECATION_DATE.year, DEPRECATION_DATE.month
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
[
|
|
225
|
+
:start_of_quarter,
|
|
226
|
+
:end_of_quarter
|
|
227
|
+
].each do |method|
|
|
228
|
+
deprecate method, "#{MerchCalendar::FiscalYearCalendar}##{method}", DEPRECATION_DATE.year, DEPRECATION_DATE.month
|
|
229
|
+
end
|
|
230
|
+
|
|
202
231
|
end
|
|
203
232
|
|
|
204
233
|
end
|
data/lib/merch_calendar.rb
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
#
|
|
3
3
|
module MerchCalendar
|
|
4
|
-
|
|
4
|
+
DEPRECATION_DATE = Date.new(2018, 1, 1)
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
require_relative 'merch_calendar/version'
|
|
8
8
|
require_relative 'merch_calendar/util'
|
|
9
|
-
require_relative 'merch_calendar/configurable'
|
|
10
|
-
require_relative 'merch_calendar/configuration'
|
|
11
9
|
require_relative 'merch_calendar/merch_week'
|
|
12
10
|
require_relative 'merch_calendar/retail_calendar'
|
|
13
11
|
require_relative 'merch_calendar/fiscal_year_calendar'
|
data/spec/merch_calendar_spec.rb
CHANGED
|
@@ -60,40 +60,86 @@ RSpec.describe MerchCalendar do
|
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
describe "#start_of_month" do
|
|
64
|
+
it "returns the correct date for 2017-1" do
|
|
65
|
+
expect(described_class.start_of_month(2017, 1)).to eq Date.new(2017, 12, 31)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "returns the correct date for 2017-5" do
|
|
69
|
+
expect(described_class.start_of_month(2017, 5)).to eq Date.new(2017, 4, 30)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "returns the correct date for 2018-1" do
|
|
73
|
+
expect(described_class.start_of_month(2018, 1)).to eq Date.new(2019, 1, 6)
|
|
74
|
+
end
|
|
65
75
|
end
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
describe "#end_of_month" do
|
|
78
|
+
it "returns the correct date for 2017-1" do
|
|
79
|
+
expect(described_class.end_of_month(2017, 1)).to eq Date.new(2018, 2, 3)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "returns the correct date for 2017-5" do
|
|
83
|
+
expect(described_class.end_of_month(2017, 5)).to eq Date.new(2017, 5, 27)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "returns the correct date for 2018-1" do
|
|
87
|
+
expect(described_class.end_of_month(2018, 1)).to eq Date.new(2019, 2, 2)
|
|
88
|
+
end
|
|
69
89
|
end
|
|
70
90
|
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
describe "#start_of_year" do
|
|
92
|
+
it "returns the correct date for 2014" do
|
|
93
|
+
expect(described_class.start_of_year(2014)).to eq Date.new(2014, 2, 2)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "returns the correct date for 2017" do
|
|
97
|
+
expect(described_class.start_of_year(2017)).to eq Date.new(2017, 1, 29)
|
|
98
|
+
end
|
|
73
99
|
end
|
|
74
100
|
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
describe "#end_of_year" do
|
|
102
|
+
it "returns the correct date for 2014" do
|
|
103
|
+
expect(described_class.end_of_year(2014)).to eq Date.new(2015, 1, 31)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "returns the correct date for 2017" do
|
|
107
|
+
expect(described_class.end_of_year(2017)).to eq Date.new(2018, 2, 3)
|
|
108
|
+
end
|
|
77
109
|
end
|
|
78
110
|
|
|
79
|
-
|
|
80
|
-
|
|
111
|
+
describe "#start_of_quarter" do
|
|
112
|
+
it "returns the correct date for 2014-Q1" do
|
|
113
|
+
expect(described_class.start_of_quarter(2014,1)).to eq Date.new(2014, 8, 3)
|
|
114
|
+
end
|
|
81
115
|
end
|
|
82
116
|
|
|
83
|
-
|
|
84
|
-
|
|
117
|
+
describe "#end_of_quarter" do
|
|
118
|
+
it "returns the correct date for 2014-Q1" do
|
|
119
|
+
expect(described_class.end_of_quarter(2014,1)).to eq Date.new(2014, 11, 1)
|
|
120
|
+
end
|
|
85
121
|
end
|
|
86
122
|
|
|
87
|
-
|
|
88
|
-
|
|
123
|
+
describe "#weeks_in_year" do
|
|
124
|
+
it "returns the right number of weeks for 2014" do
|
|
125
|
+
expect(described_class.weeks_in_year(2014)).to eq 52
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "returns the right number of weeks for 2017" do
|
|
129
|
+
expect(described_class.weeks_in_year(2017)).to eq 53
|
|
130
|
+
end
|
|
89
131
|
end
|
|
90
132
|
|
|
91
|
-
|
|
92
|
-
|
|
133
|
+
describe "#merch_to_julian" do
|
|
134
|
+
it "returns the right julian month" do
|
|
135
|
+
expect(described_class.merch_to_julian(1)).to eq 2
|
|
136
|
+
end
|
|
93
137
|
end
|
|
94
138
|
|
|
95
|
-
|
|
96
|
-
|
|
139
|
+
describe "#julian_to_merch" do
|
|
140
|
+
it "returns the right merch month" do
|
|
141
|
+
expect(described_class.julian_to_merch(1)).to eq 12
|
|
142
|
+
end
|
|
97
143
|
end
|
|
98
144
|
|
|
99
145
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -14,4 +14,15 @@ RSpec.configure do |config|
|
|
|
14
14
|
mocks_config.verify_doubled_constant_names = true
|
|
15
15
|
mocks_config.verify_partial_doubles = true
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
config.around do |example|
|
|
19
|
+
# Hide deprecation warnings within this gem from showing up in tests
|
|
20
|
+
if Date.today < MerchCalendar::DEPRECATION_DATE
|
|
21
|
+
Gem::Deprecate.skip_during do
|
|
22
|
+
example.run
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
example.run
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: merch_calendar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.
|
|
4
|
+
version: 0.1.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mitch Dempsey
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-
|
|
12
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -115,16 +115,12 @@ files:
|
|
|
115
115
|
- README.md
|
|
116
116
|
- Rakefile
|
|
117
117
|
- lib/merch_calendar.rb
|
|
118
|
-
- lib/merch_calendar/configurable.rb
|
|
119
|
-
- lib/merch_calendar/configuration.rb
|
|
120
118
|
- lib/merch_calendar/fiscal_year_calendar.rb
|
|
121
119
|
- lib/merch_calendar/merch_week.rb
|
|
122
120
|
- lib/merch_calendar/retail_calendar.rb
|
|
123
121
|
- lib/merch_calendar/util.rb
|
|
124
122
|
- lib/merch_calendar/version.rb
|
|
125
123
|
- merch_calendar.gemspec
|
|
126
|
-
- spec/merch_calendar/configurable_spec.rb
|
|
127
|
-
- spec/merch_calendar/configuration_spec.rb
|
|
128
124
|
- spec/merch_calendar/fiscal_year_calendar_spec.rb
|
|
129
125
|
- spec/merch_calendar/merch_week_spec.rb
|
|
130
126
|
- spec/merch_calendar/retail_calendar_spec.rb
|
|
@@ -156,8 +152,6 @@ signing_key:
|
|
|
156
152
|
specification_version: 4
|
|
157
153
|
summary: Utility for manipulating dates within a 4-5-4 retail calendar
|
|
158
154
|
test_files:
|
|
159
|
-
- spec/merch_calendar/configurable_spec.rb
|
|
160
|
-
- spec/merch_calendar/configuration_spec.rb
|
|
161
155
|
- spec/merch_calendar/fiscal_year_calendar_spec.rb
|
|
162
156
|
- spec/merch_calendar/merch_week_spec.rb
|
|
163
157
|
- spec/merch_calendar/retail_calendar_spec.rb
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module MerchCalendar
|
|
2
|
-
class << self
|
|
3
|
-
|
|
4
|
-
attr_writer :configuration
|
|
5
|
-
|
|
6
|
-
# Returns the global configuration object
|
|
7
|
-
#
|
|
8
|
-
# @return [Configuration]
|
|
9
|
-
def configuration
|
|
10
|
-
@configuration ||= Configuration.new
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Used in initializers to set the global configuration
|
|
14
|
-
#
|
|
15
|
-
# @return [void]
|
|
16
|
-
def configure
|
|
17
|
-
yield(configuration)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Resets the configuration to default values
|
|
21
|
-
#
|
|
22
|
-
# @return [void]
|
|
23
|
-
def reset_config!
|
|
24
|
-
@configuration = Configuration.new
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe MerchCalendar do
|
|
5
|
-
describe "#reset_config!" do
|
|
6
|
-
it "resets the configuration to defaults" do
|
|
7
|
-
MerchCalendar.configure do |config|
|
|
8
|
-
config.quarter_start_month = 1
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
MerchCalendar.reset_config!
|
|
12
|
-
|
|
13
|
-
expect(MerchCalendar.configuration.quarter_start_month).to eq MerchCalendar::Configuration.new.quarter_start_month
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe MerchCalendar::Configuration do
|
|
4
|
-
describe "#quarter_start_month" do
|
|
5
|
-
it "default value is 8" do
|
|
6
|
-
expect(described_class.new.quarter_start_month).to eq 8
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "#quarter_start_month=" do
|
|
11
|
-
it "can set value" do
|
|
12
|
-
config = described_class.new
|
|
13
|
-
config.quarter_start_month = 7
|
|
14
|
-
expect(config.quarter_start_month).to eq 7
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|