merch_calendar 0.3.0 → 1.0.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
2
  SHA1:
3
- metadata.gz: 13a41aecf0152a0c3bffeed5ecf51f15dd5d6927
4
- data.tar.gz: 482637d57739642817b9c8729f6598fdd4ba4ff7
3
+ metadata.gz: 0325ba6521496a2043a1abacc779ab8fee857ba0
4
+ data.tar.gz: 13621f1cde48c5097e07debf1f46e43becf3f7b7
5
5
  SHA512:
6
- metadata.gz: cee1f7ae6cf8817c0616eb46eb572f3a39cf6deb087ed6515335ad693030ae5106353915199be23b471d53e494a7f190ba7ccf021523c66674fd96e52ac71085
7
- data.tar.gz: c49c4924295a06b57a71c164a2f6c57a6b433ef25b0eb3359e42da3cec27f8b3f25affc94009c57337cf4d872747deddff78585a4a95c65e57b3093aa7bd6e03
6
+ metadata.gz: ee990e81e979a167c5ef882280d9c9be11eae652e6d7c437db6d306caee28230c7fb3f4e36864ba912f65329d90a779319e69e6210ca941fa2d46746fd7d481f
7
+ data.tar.gz: b0cdff703e3e26cced58d342cce2297b4c94a5dc9147581ac3a445c99208f125f1f7f12d671f08be65f8bf1d6437a940cbbbf88b74c12c1074057da54c876e19
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.4.1
data/.travis.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
4
3
  - 2.0.0
5
- - 2.2.0
6
- - 1.9.3
4
+ - 2.1.10
5
+ - 2.2.7
6
+ - 2.3.5
7
+ - 2.4.1
8
+ - ruby-head
7
9
  notifications:
8
10
  email: false
9
11
 
data/Gemfile.lock CHANGED
@@ -1,50 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- merch_calendar (0.3.0)
4
+ merch_calendar (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
8
8
  specs:
9
- coderay (1.1.1)
10
- coveralls (0.8.13)
11
- json (~> 1.8)
12
- simplecov (~> 0.11.0)
9
+ coderay (1.1.2)
10
+ coveralls (0.8.21)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.14.1)
13
13
  term-ansicolor (~> 1.3)
14
- thor (~> 0.19.1)
15
- tins (~> 1.6.0)
16
- diff-lcs (1.2.5)
14
+ thor (~> 0.19.4)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.3)
17
17
  docile (1.1.5)
18
- json (1.8.3)
18
+ json (2.1.0)
19
19
  method_source (0.8.2)
20
20
  pry (0.10.4)
21
21
  coderay (~> 1.1.0)
22
22
  method_source (~> 0.8.1)
23
23
  slop (~> 3.4)
24
- rake (10.5.0)
25
- rspec (3.4.0)
26
- rspec-core (~> 3.4.0)
27
- rspec-expectations (~> 3.4.0)
28
- rspec-mocks (~> 3.4.0)
29
- rspec-core (3.4.3)
30
- rspec-support (~> 3.4.0)
31
- rspec-expectations (3.4.0)
24
+ rake (12.1.0)
25
+ rspec (3.6.0)
26
+ rspec-core (~> 3.6.0)
27
+ rspec-expectations (~> 3.6.0)
28
+ rspec-mocks (~> 3.6.0)
29
+ rspec-core (3.6.0)
30
+ rspec-support (~> 3.6.0)
31
+ rspec-expectations (3.6.0)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.4.0)
34
- rspec-mocks (3.4.1)
33
+ rspec-support (~> 3.6.0)
34
+ rspec-mocks (3.6.0)
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.4.0)
37
- rspec-support (3.4.1)
38
- simplecov (0.11.2)
36
+ rspec-support (~> 3.6.0)
37
+ rspec-support (3.6.0)
38
+ simplecov (0.14.1)
39
39
  docile (~> 1.1.0)
40
- json (~> 1.8)
40
+ json (>= 1.8, < 3)
41
41
  simplecov-html (~> 0.10.0)
42
- simplecov-html (0.10.0)
42
+ simplecov-html (0.10.2)
43
43
  slop (3.6.0)
44
- term-ansicolor (1.3.2)
44
+ term-ansicolor (1.6.0)
45
45
  tins (~> 1.0)
46
- thor (0.19.1)
47
- tins (1.6.0)
46
+ thor (0.19.4)
47
+ tins (1.15.0)
48
48
 
49
49
  PLATFORMS
50
50
  ruby
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  simplecov
59
59
 
60
60
  BUNDLED WITH
61
- 1.15.3
61
+ 1.15.4
data/README.md CHANGED
@@ -19,6 +19,16 @@ Add the following line to your `Gemfile`:
19
19
  gem "merch_calendar"
20
20
  ```
21
21
 
22
+ ## Ruby Version Compatibility
23
+ This gem has been tested against Ruby 2.0 - 2.4.
24
+
25
+ Support for Ruby 1.9.3 was discontinued as of version 0.3.0 of this gem. If you're on Ruby 1.9.3, you'll want to
26
+ install the gem like so:
27
+
28
+ ```ruby
29
+ gem "merch_calendar", "0.3.0"
30
+ ```
31
+
22
32
  ## Usage
23
33
 
24
34
  For converting a date into a `MerchWeek` object.
@@ -36,15 +36,15 @@ module MerchCalendar
36
36
  #
37
37
  # @overload find(year, julian_month, week_number=nil, options)
38
38
  # Returns an array of +MerchWeek+s for a given month
39
- # @param year [Fixnum] the merch year to locate
40
- # @param julian_month [Fixnum] the month to find merch months for
39
+ # @param year [Integer] the merch year to locate
40
+ # @param julian_month [Integer] the month to find merch months for
41
41
  # @param week_number [Nil] set week_number to nil
42
42
  # @param options [Hash] options to set your calendar, if none it will default to RetailCalendar
43
43
  # @return [Array<MerchWeek>]
44
44
  # @overload find(year, julian_month, week_number)
45
- # @param year [Fixnum] the merch year to locate
46
- # @param julian_month [Fixnum] the month to find merch months for
47
- # @param week_number [Fixnum] the specific week number.
45
+ # @param year [Integer] the merch year to locate
46
+ # @param julian_month [Integer] the month to find merch months for
47
+ # @param week_number [Integer] the specific week number.
48
48
  # @param options [Hash] options to set your calendar, if none it will default to RetailCalendar
49
49
  # @return [MerchWeek] the specific merch week based on the week number
50
50
  def self.find(year, julian_month, week_number=nil, options={})
@@ -87,7 +87,7 @@ module MerchCalendar
87
87
 
88
88
  # What week it is within the year from 1-53
89
89
  #
90
- # @return [Fixnum] The week number of the year, from 1-53
90
+ # @return [Integer] The week number of the year, from 1-53
91
91
  def year_week
92
92
  @year_week ||= (((date-start_of_year)+1)/7.0).ceil
93
93
  end
@@ -96,7 +96,7 @@ module MerchCalendar
96
96
  # Month 1 is Feb for the retail calendar
97
97
  # Month 1 is August for the fiscal calendar
98
98
  #
99
- # @return [Fixnum]
99
+ # @return [Integer]
100
100
  def merch_month
101
101
  # TODO: This is very inefficient, but less complex than strategic guessing
102
102
  # maybe switch to a binary search or something
@@ -108,21 +108,21 @@ module MerchCalendar
108
108
 
109
109
  # Returns the Merch year depending whether it is from the Retail or Fiscal calendar
110
110
  #
111
- # @return [Fixnum]
111
+ # @return [Integer]
112
112
  def year
113
113
  @year ||= calendar.merch_year_from_date(date)
114
114
  end
115
115
 
116
116
  # Returns julian month where the merch week falls
117
117
  #
118
- # @return [Fixnum]
118
+ # @return [Integer]
119
119
  def month
120
120
  @month ||= calendar.merch_to_julian(merch_month)
121
121
  end
122
122
 
123
123
  # Returns the quarter that this merch week falls
124
124
  #
125
- # @return [Fixnum]
125
+ # @return [Integer]
126
126
  def quarter
127
127
  @quarter ||= calendar.quarter(merch_month)
128
128
  end
@@ -144,7 +144,7 @@ module MerchCalendar
144
144
  # The number of the week within the given merch month
145
145
  # will be between 1 and 5
146
146
  #
147
- # @return [Fixnum]
147
+ # @return [Integer]
148
148
  def week
149
149
  @week ||= (((date-start_of_month)+1)/7.0).ceil
150
150
  end
@@ -13,7 +13,7 @@ module MerchCalendar
13
13
 
14
14
  # The the first date of the retail year
15
15
  #
16
- # @param year [Fixnum] the retail year
16
+ # @param year [Integer] the retail year
17
17
  # @return [Date] the first date of the retail year
18
18
  def end_of_year(year)
19
19
  year_end = Date.new((year + 1), 1, -1) # Jan 31st
@@ -29,7 +29,7 @@ module MerchCalendar
29
29
 
30
30
  # The last date of the retail year
31
31
  #
32
- # @param year [Fixnum] the retail year
32
+ # @param year [Integer] the retail year
33
33
  # @return [Date] the last date of the retail year
34
34
  def start_of_year(year)
35
35
  end_of_year(year - 1) + 1
@@ -37,8 +37,8 @@ module MerchCalendar
37
37
 
38
38
  # The starting date of the given merch month
39
39
  #
40
- # @param year [Fixnum] the retail year
41
- # @param merch_month [Fixnum] the nth merch month of the retail calendar
40
+ # @param year [Integer] the retail year
41
+ # @param merch_month [Integer] the nth merch month of the retail calendar
42
42
  # @return [Date] the start date of the merch month
43
43
  def start_of_month(year, merch_month)
44
44
  # 91 = number of days in a single 4-5-4 set
@@ -59,8 +59,8 @@ module MerchCalendar
59
59
 
60
60
  # The ending date of the given merch month
61
61
  #
62
- # @param year [Fixnum] the retail year
63
- # @param merch_month [Fixnum] the nth merch month of the retail calendar
62
+ # @param year [Integer] the retail year
63
+ # @param merch_month [Integer] the nth merch month of the retail calendar
64
64
  # @return [Date] the end date of the merch month
65
65
  def end_of_month(year, merch_month)
66
66
  if merch_month == 12
@@ -72,9 +72,9 @@ module MerchCalendar
72
72
 
73
73
  # Returns the date that corresponds to the first day in the merch week
74
74
  #
75
- # @param year [Fixnum] the retail year
76
- # @param month [Fixnum] the nth merch month of the retail calendar
77
- # @param merch_week [Fixnum] the nth week of the merch month
75
+ # @param year [Integer] the retail year
76
+ # @param month [Integer] the nth merch month of the retail calendar
77
+ # @param merch_week [Integer] the nth week of the merch month
78
78
  # @return [Date] the start date of the merch week
79
79
  def start_of_week(year, month, merch_week)
80
80
  start_of_month(year, month) + ((merch_week - 1) * 7)
@@ -82,9 +82,9 @@ module MerchCalendar
82
82
 
83
83
  # Returns the date that corresponds to the last day in the merch week
84
84
  #
85
- # @param year [Fixnum] the retail year
86
- # @param month [Fixnum] the nth merch month of the retail calendar
87
- # @param merch_week [Fixnum] the nth week of the merch month
85
+ # @param year [Integer] the retail year
86
+ # @param month [Integer] the nth merch month of the retail calendar
87
+ # @param merch_week [Integer] the nth week of the merch month
88
88
  # @return [Date] the end date of the merch week
89
89
  def end_of_week(year, month, merch_week)
90
90
  start_of_month(year, month) + (6 + ((merch_week - 1) * 7))
@@ -92,8 +92,8 @@ module MerchCalendar
92
92
 
93
93
  # Return the starting date for a particular quarter
94
94
  #
95
- # @param year [Fixnum] the retail year
96
- # @param quarter [Fixnum] the quarter of the year, a number from 1 - 4
95
+ # @param year [Integer] the retail year
96
+ # @param quarter [Integer] the quarter of the year, a number from 1 - 4
97
97
  # @return [Date] the start date of the quarter
98
98
  def start_of_quarter(year, quarter)
99
99
  case quarter
@@ -112,8 +112,8 @@ module MerchCalendar
112
112
 
113
113
  # Return the ending date for a particular quarter
114
114
  #
115
- # @param year [Fixnum] the retail year
116
- # @param quarter [Fixnum] the quarter of the year, a number from 1 - 4
115
+ # @param year [Integer] the retail year
116
+ # @param quarter [Integer] the quarter of the year, a number from 1 - 4
117
117
  # @return [Date] the end date of the quarter
118
118
  def end_of_quarter(year, quarter)
119
119
  case quarter
@@ -132,7 +132,7 @@ module MerchCalendar
132
132
 
133
133
  # Returns the quarter that the merch month falls in
134
134
  #
135
- # @param merch_month [Fixnum] merch month
135
+ # @param merch_month [Integer] merch month
136
136
  # @return [Date] the quarter that the merch_month falls in
137
137
  def quarter(merch_month)
138
138
  case merch_month
@@ -151,7 +151,7 @@ module MerchCalendar
151
151
 
152
152
  #Returns the season given for the merch_month
153
153
  #
154
- # @param merch_month [Fixnum] the nth month of the retail calendar
154
+ # @param merch_month [Integer] the nth month of the retail calendar
155
155
  # @return [String] the season that the merch_month falls under
156
156
  def season(merch_month)
157
157
  case merch_month
@@ -166,8 +166,8 @@ module MerchCalendar
166
166
 
167
167
  # Returns the number of weeks in the retail year
168
168
  #
169
- # @param year [Fixnum] the retail year
170
- # @return [Fixnum] the number of weeks within the retail year
169
+ # @param year [Integer] the retail year
170
+ # @return [Integer] the number of weeks within the retail year
171
171
  def weeks_in_year(year)
172
172
  ((start_of_year(year + 1) - start_of_year(year)) / 7).to_i
173
173
  end
@@ -175,7 +175,7 @@ module MerchCalendar
175
175
  # Given any julian date it will return what retail year it belongs to
176
176
  #
177
177
  # @param date [Date] the julian date to convert to its Retail Year
178
- # @return [Fixnum] the retail year that the julian date falls into
178
+ # @return [Integer] the retail year that the julian date falls into
179
179
  def merch_year_from_date(date)
180
180
  date_end_of_year = end_of_year(date.year)
181
181
  date_start_of_year = start_of_year(date.year)
@@ -189,8 +189,8 @@ module MerchCalendar
189
189
 
190
190
  # Converts a merch month to the correct julian month
191
191
  #
192
- # @param merch_month [Fixnum] the merch month to convert
193
- # @return [Fixnum] the julian month
192
+ # @param merch_month [Integer] the merch month to convert
193
+ # @return [Integer] the julian month
194
194
  def merch_to_julian(merch_month)
195
195
  if merch_month > 12 || merch_month <= 0
196
196
  raise ArgumentError
@@ -205,8 +205,8 @@ module MerchCalendar
205
205
 
206
206
  # Converts a julian month to a merch month
207
207
  #
208
- # @param julian_month [Fixnum] the julian month to convert
209
- # @return [Fixnum] the merch month
208
+ # @param julian_month [Integer] the julian month to convert
209
+ # @return [Integer] the merch month
210
210
  def julian_to_merch(julian_month)
211
211
  if julian_month > 12 || julian_month <= 0
212
212
  raise ArgumentError
@@ -240,8 +240,8 @@ module MerchCalendar
240
240
 
241
241
  # Returns an array of Merch Weeks that pertains to the Julian Month of a Retail Year
242
242
  #
243
- # @param year [Fixnum] the Retail year
244
- # @param month_param [Fixnum] the julian month
243
+ # @param year [Integer] the Retail year
244
+ # @param month_param [Integer] the julian month
245
245
  # @return [Array] Array of MerchWeeks
246
246
  def weeks_for_month(year, month_param)
247
247
  merch_month = get_merch_month_param(month_param)
@@ -266,7 +266,7 @@ module MerchCalendar
266
266
  private
267
267
 
268
268
  def get_merch_month_param(param)
269
- if param.is_a? Fixnum
269
+ if param.is_a? Integer
270
270
  return julian_to_merch(param)
271
271
  elsif param.is_a? Hash
272
272
  julian_month = param.delete(:julian_month) || param.delete(:month)
@@ -11,7 +11,7 @@ module MerchCalendar
11
11
 
12
12
  # The date of the first day of the fiscal year
13
13
  #
14
- # @param year [Fixnum] the fiscal year
14
+ # @param year [Integer] the fiscal year
15
15
  # @return [Date] the first date of the fiscal year
16
16
  def start_of_year(year)
17
17
  end_of_year(year - 1) + 1
@@ -19,7 +19,7 @@ module MerchCalendar
19
19
 
20
20
  # The date of the last day of the fiscal year
21
21
  #
22
- # @param year [Fixnum] the fiscal year
22
+ # @param year [Integer] the fiscal year
23
23
  # @return [Date] the last date of the fiscal year
24
24
  def end_of_year(year)
25
25
  year_end = Date.new((year), 7, -1) # Jul 31st
@@ -35,8 +35,8 @@ module MerchCalendar
35
35
 
36
36
  # Return the starting date for a particular quarter
37
37
  #
38
- # @param year [Fixnum] the fiscal year
39
- # @param quarter [Fixnum] the quarter of the year, a number from 1 - 4
38
+ # @param year [Integer] the fiscal year
39
+ # @param quarter [Integer] the quarter of the year, a number from 1 - 4
40
40
  # @return [Date] the start date of the quarter
41
41
  def start_of_quarter(year, quarter)
42
42
  case quarter
@@ -55,7 +55,7 @@ module MerchCalendar
55
55
 
56
56
  # Returns the quarter that the merch month falls in
57
57
  #
58
- # @param merch_month [Fixnum] merch month
58
+ # @param merch_month [Integer] merch month
59
59
  # @return [Date] the quarter that the merch_month falls in
60
60
  def quarter(merch_month)
61
61
  case merch_month
@@ -74,8 +74,8 @@ module MerchCalendar
74
74
 
75
75
  # Return the ending date for a particular quarter
76
76
  #
77
- # @param year [Fixnum] the fiscal year
78
- # @param quarter [Fixnum] the quarter of the year, a number from 1 - 4
77
+ # @param year [Integer] the fiscal year
78
+ # @param quarter [Integer] the quarter of the year, a number from 1 - 4
79
79
  # @return [Date] the end date of the quarter
80
80
  def end_of_quarter(year, quarter)
81
81
  case quarter
@@ -94,7 +94,7 @@ module MerchCalendar
94
94
 
95
95
  #Returns the season given for the merch_month
96
96
  #
97
- # @param merch_month [Fixnum] the nth merch month of the retail calendar
97
+ # @param merch_month [Integer] the nth merch month of the retail calendar
98
98
  # @return [String] the season that the merch month falls under
99
99
  def season(merch_month)
100
100
  case merch_month
@@ -109,8 +109,8 @@ module MerchCalendar
109
109
 
110
110
  # The starting date of the given merch month
111
111
  #
112
- # @param year [Fixnum] the fiscal year
113
- # @param merch_month [Fixnum] the nth merch month of the fiscal calendar
112
+ # @param year [Integer] the fiscal year
113
+ # @param merch_month [Integer] the nth merch month of the fiscal calendar
114
114
  # @return [Date] the start date of the merch month
115
115
  def start_of_month(year, merch_month)
116
116
  # 91 = number of days in a single 4-5-4 set
@@ -131,8 +131,8 @@ module MerchCalendar
131
131
 
132
132
  # The ending date of the given merch month
133
133
  #
134
- # @param year [Fixnum] the fiscal year
135
- # @param merch_month [Fixnum] the nth merch month of the fiscal calendar
134
+ # @param year [Integer] the fiscal year
135
+ # @param merch_month [Integer] the nth merch month of the fiscal calendar
136
136
  # @return [Date] the end date of the merch month
137
137
  def end_of_month(year, merch_month)
138
138
  if merch_month == 12
@@ -144,9 +144,9 @@ module MerchCalendar
144
144
 
145
145
  # Returns the date that corresponds to the first day in the merch week
146
146
  #
147
- # @param year [Fixnum] the fiscal year
148
- # @param merch_month [Fixnum] the nth month of the fiscal calendar
149
- # @param merch_week [Fixnum] the nth week of the merch month
147
+ # @param year [Integer] the fiscal year
148
+ # @param merch_month [Integer] the nth month of the fiscal calendar
149
+ # @param merch_week [Integer] the nth week of the merch month
150
150
  # @return [Date] the start date of the merch week
151
151
  def start_of_week(year, month, merch_week)
152
152
  start_of_month(year, month) + ((merch_week - 1) * 7)
@@ -154,9 +154,9 @@ module MerchCalendar
154
154
 
155
155
  # Returns the date that corresponds to the last day in the merch week
156
156
  #
157
- # @param year [Fixnum] the fiscal year
158
- # @param merch_month [Fixnum] the nth merch month of the fiscal calendar
159
- # @param merch_week [Fixnum] the nth week of the merch month
157
+ # @param year [Integer] the fiscal year
158
+ # @param merch_month [Integer] the nth merch month of the fiscal calendar
159
+ # @param merch_week [Integer] the nth week of the merch month
160
160
  # @return [Date] the end date of the merch week
161
161
  def end_of_week(year, month, merch_week)
162
162
  start_of_month(year, month) + (6 + ((merch_week - 1) * 7))
@@ -164,8 +164,8 @@ module MerchCalendar
164
164
 
165
165
  # Returns the number of weeks in the fiscal year
166
166
  #
167
- # @param year [Fixnum] the fiscal year
168
- # @return [Fixnum] the number of weeks within the fiscal year
167
+ # @param year [Integer] the fiscal year
168
+ # @return [Integer] the number of weeks within the fiscal year
169
169
  def weeks_in_year(year)
170
170
  ((start_of_year(year + 1) - start_of_year(year)) / 7).to_i
171
171
  end
@@ -173,7 +173,7 @@ module MerchCalendar
173
173
  # Given any julian date it will return what Fiscal Year it belongs to
174
174
  #
175
175
  # @param date [Date] the julian date to convert to its Fiscal Year
176
- # @return [Fixnum] the fiscal year that the julian date falls into
176
+ # @return [Integer] the fiscal year that the julian date falls into
177
177
  def merch_year_from_date(date)
178
178
  if end_of_year(date.year) >= date
179
179
  return date.year
@@ -184,8 +184,8 @@ module MerchCalendar
184
184
 
185
185
  # Converts a merch month to the correct julian month
186
186
  #
187
- # @param merch_month [Fixnum] the merch month to convert
188
- # @return [Fixnum] the julian month
187
+ # @param merch_month [Integer] the merch month to convert
188
+ # @return [Integer] the julian month
189
189
  def merch_to_julian(merch_month)
190
190
  if merch_month > 12 || merch_month <= 0
191
191
  raise ArgumentError
@@ -200,8 +200,8 @@ module MerchCalendar
200
200
 
201
201
  # Converts a julian month to a fiscal month
202
202
  #
203
- # @param julian_month [Fixnum] the julian month to convert
204
- # @return [Fixnum] the merch month
203
+ # @param julian_month [Integer] the julian month to convert
204
+ # @return [Integer] the merch month
205
205
  def julian_to_merch(julian_month)
206
206
  if julian_month > 12 || julian_month <= 0
207
207
  raise ArgumentError
@@ -226,8 +226,8 @@ module MerchCalendar
226
226
 
227
227
  # Returns an array of Merch Weeks that pertains to the Julian Month of a Fiscal Year
228
228
  #
229
- # @param year [Fixnum] the fiscal year
230
- # @param month_param [Fixnum] the julian month
229
+ # @param year [Integer] the fiscal year
230
+ # @param month_param [Integer] the julian month
231
231
  # @return [Array] Array of MerchWeeks that falls within that julian month
232
232
  def weeks_for_month(year, month_param)
233
233
  merch_month = julian_to_merch(month_param)
@@ -8,9 +8,9 @@ module MerchCalendar
8
8
 
9
9
  # The start date of the week
10
10
  #
11
- # @param year [Fixnum] the merch year
12
- # @param month [Fixnum] an integer specifying the julian month.
13
- # @param week [Fixnum] an integer specifying the merch week.
11
+ # @param year [Integer] the merch year
12
+ # @param month [Integer] an integer specifying the julian month.
13
+ # @param week [Integer] an integer specifying the merch week.
14
14
  #
15
15
  # @return [Date] the starting date of the specified week
16
16
  def start_of_week(year, month, week)
@@ -19,9 +19,9 @@ module MerchCalendar
19
19
 
20
20
  # The end date of the week
21
21
  #
22
- # @param year [Fixnum] the merch year
23
- # @param month [Fixnum] an integer specifying the julian month.
24
- # @param week [Fixnum] an integer specifying the merch week.
22
+ # @param year [Integer] the merch year
23
+ # @param month [Integer] an integer specifying the julian month.
24
+ # @param week [Integer] an integer specifying the merch week.
25
25
  #
26
26
  # @return [Date] the ending date of the specified week
27
27
  def end_of_week(year, month, week)
@@ -37,11 +37,11 @@ module MerchCalendar
37
37
  # MerchCalendar.start_of_month(2015, julian_month: 5)
38
38
  # MerchCalendar.start_of_month(2015, merch_month: 4)
39
39
  #
40
- # @param year [Fixnum] the merch year
41
- # @param month_param [Fixnum,Hash] an integer specifying the julian month. This can also be a named hash
42
- # @option month_param [Fixnum] :month the julian month
43
- # @option month_param [Fixnum] :julian_month the julian month
44
- # @option month_param [Fixnum] :merch_month the MERCH month
40
+ # @param year [Integer] the merch year
41
+ # @param month_param [Integer,Hash] an integer specifying the julian month. This can also be a named hash
42
+ # @option month_param [Integer] :month the julian month
43
+ # @option month_param [Integer] :julian_month the julian month
44
+ # @option month_param [Integer] :merch_month the MERCH month
45
45
  #
46
46
  # @return [Date] the starting date of the specified month
47
47
  def start_of_month(year, month_param)
@@ -51,7 +51,7 @@ module MerchCalendar
51
51
 
52
52
  # The end date of the month
53
53
  #
54
- # @param year [Fixnum] the merch year
54
+ # @param year [Integer] the merch year
55
55
  # @param month_param [Hash] month hash
56
56
  #
57
57
  # @see #start_of_month The start_of_month method for examples using month_param
@@ -64,7 +64,7 @@ module MerchCalendar
64
64
 
65
65
  # The start date of the year
66
66
  #
67
- # @param year [Fixnum] the merch year
67
+ # @param year [Integer] the merch year
68
68
  #
69
69
  # @return [Date] the starting date of the specified year
70
70
  def start_of_year(year)
@@ -73,7 +73,7 @@ module MerchCalendar
73
73
 
74
74
  # The end date of the year
75
75
  #
76
- # @param year [Fixnum] the merch year
76
+ # @param year [Integer] the merch year
77
77
  #
78
78
  # @return [Date] the ending date of the specified year
79
79
  def end_of_year(year)
@@ -83,8 +83,8 @@ module MerchCalendar
83
83
 
84
84
  # The start date of the quarter
85
85
  #
86
- # @param year [Fixnum] the merch year
87
- # @param quarter [Fixnum] the quarter
86
+ # @param year [Integer] the merch year
87
+ # @param quarter [Integer] the quarter
88
88
  #
89
89
  # @return [Date] the starting date of the specified quarter
90
90
  def start_of_quarter(year, quarter)
@@ -93,8 +93,8 @@ module MerchCalendar
93
93
 
94
94
  # The end date of the quarter
95
95
  #
96
- # @param year [Fixnum] the merch year
97
- # @param quarter [Fixnum] the quarter
96
+ # @param year [Integer] the merch year
97
+ # @param quarter [Integer] the quarter
98
98
  #
99
99
  # @return [Date] the ending date of the specified quarter
100
100
  def end_of_quarter(year, quarter)
@@ -104,9 +104,9 @@ module MerchCalendar
104
104
 
105
105
  # Returns the number of weeks in a given merch year
106
106
  #
107
- # @param year [Fixnum] the merch year
107
+ # @param year [Integer] the merch year
108
108
  #
109
- # @return [Fixnum] number of weeks
109
+ # @return [Integer] number of weeks
110
110
  def weeks_in_year(year)
111
111
  retail_calendar.weeks_in_year(year)
112
112
  end
@@ -125,8 +125,8 @@ module MerchCalendar
125
125
 
126
126
  # Converts a merch month to the correct julian month
127
127
  #
128
- # @param merch_month [Fixnum] the merch month to convert
129
- # @return [Fixnum] the julian month
128
+ # @param merch_month [Integer] the merch month to convert
129
+ # @return [Integer] the julian month
130
130
  def merch_to_julian(merch_month)
131
131
  if merch_month == 12
132
132
  1
@@ -138,8 +138,8 @@ module MerchCalendar
138
138
 
139
139
  # Converts a julian month to a merch month
140
140
  #
141
- # @param julian_month [Fixnum] the julian month to convert
142
- # @return [Fixnum] the merch month
141
+ # @param julian_month [Integer] the julian month to convert
142
+ # @return [Integer] the merch month
143
143
  def julian_to_merch(julian_month)
144
144
  if julian_month == 1
145
145
  12
@@ -151,7 +151,7 @@ module MerchCalendar
151
151
 
152
152
  # An array of merch weeks in a given month
153
153
  #
154
- # @param year [Fixnum] the merch year
154
+ # @param year [Integer] the merch year
155
155
  # @param month_param [Hash] month hash
156
156
  #
157
157
  # @see #start_of_month The start_of_month method for examples using month_param
@@ -185,7 +185,7 @@ module MerchCalendar
185
185
  # Reads the provided parameter and converts the value
186
186
  # to a MERCH MONTH
187
187
  def get_merch_month_param(param)
188
- if param.is_a? Fixnum
188
+ if param.is_a?(Integer)
189
189
  return julian_to_merch(param)
190
190
  elsif param.is_a? Hash
191
191
  julian_month = param.delete(:julian_month) || param.delete(:month)
@@ -1,3 +1,3 @@
1
1
  module MerchCalendar
2
- VERSION = '0.3.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -250,7 +250,7 @@ RSpec.describe MerchCalendar::RetailCalendar do
250
250
  expect(weeks.size).to eq 4
251
251
  end
252
252
 
253
- it "raises an ArgumentError if the param is not a hash with a key we care about or Fixnum" do
253
+ it "raises an ArgumentError if the param is not a hash with a key we care about or Integer" do
254
254
  expect { subject.weeks_for_month(2018, "3") }.to raise_error ArgumentError
255
255
  expect { subject.weeks_for_month(2018, some_month: 4) }.to raise_error ArgumentError
256
256
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require "simplecov"
2
2
  require "coveralls"
3
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
4
5
  SimpleCov::Formatter::HTMLFormatter,
5
6
  Coveralls::SimpleCov::Formatter
6
- ]
7
+ ])
7
8
  SimpleCov.start { add_filter "/spec/" }
8
9
 
9
10
  require "pry"
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.3.0
4
+ version: 1.0.0
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-08-30 00:00:00.000000000 Z
12
+ date: 2017-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.6.12
136
+ rubygems_version: 2.6.13
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Utility for manipulating dates within a 4-5-4 retail calendar