retail_calendar 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +10 -0
- data/lib/retail_calendar.rb +5 -0
- data/lib/retail_calendar/finder.rb +194 -0
- data/lib/retail_calendar/version.rb +3 -0
- data/retail_calendar.gemspec +27 -0
- data/spec/finder_spec.rb +80 -0
- data/spec/spec_helper.rb +2 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79f246262c55db15d88fa6dd5cd1450d3ba3fbd2
|
4
|
+
data.tar.gz: 13338541df1e303ce732d76057ec38305061407b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c107c94d647936706b3010f5da70f3221d77f3ef3a6f0112259d19ba7de4b0e5d5cb4635ea67b7beb41d028a6e6a7923f2fc53173992a8b00642f18c6c9085d
|
7
|
+
data.tar.gz: 77f074f0aa6ef995e03b307895d216c8ec87beb7db85164bdf0d01a2990995731c1ea0a5e54d2935535f7eb49699f72c8a4eb720aca7b2cb786960ec35187639
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format documentation
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kunwar Aditya Raghuwanshi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# RetailCalendar
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/kitwalker12/retail_calendar.svg?branch=master)](https://travis-ci.org/kitwalker12/retail_calendar)
|
4
|
+
|
5
|
+
Gem for finding ranges in Retail or the [4-5-4 Calendar format](http://en.wikipedia.org/wiki/4%E2%80%934%E2%80%935_calendar)
|
6
|
+
|
7
|
+
Reference Calendars:
|
8
|
+
|
9
|
+
* [2014](http://www.nrf.com/modules.php?name=Documents&op=viewlive&sp_id=7464)
|
10
|
+
* [2006 Retail Leap year](http://www.nrf.com/modules.php?name=Documents&op=viewlive&sp_id=245)
|
11
|
+
|
12
|
+
## Credits
|
13
|
+
|
14
|
+
* [Retail Calendar Gem](https://github.com/Totokaelo/retail_calendar)
|
15
|
+
* [DateTime::Fiscal::Retail454](https://metacpan.org/pod/DateTime::Fiscal::Retail454)
|
16
|
+
* [How to Set Up a 4-5-4 Calendar](http://www.smythretail.com/general-retailing/how-to-set-up-a-4-5-4-calendar/)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
gem 'retail_calendar'
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install retail_calendar
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Instantiate RetailCalendar::Finder object to get start and end dates for weeks/periods(months)/quarters/seasons/years
|
35
|
+
|
36
|
+
```
|
37
|
+
> cal = RetailCalendar::Finder.new
|
38
|
+
=> #<RetailCalendar::Finder:0x00000102125a40 @offset="+0000">
|
39
|
+
```
|
40
|
+
|
41
|
+
Instantiate with time zone
|
42
|
+
|
43
|
+
```
|
44
|
+
> cal = RetailCalendar::Finder.new('+7000')
|
45
|
+
=> #<RetailCalendar::Finder:0x000001021a3328 @offset="+7000">
|
46
|
+
```
|
47
|
+
|
48
|
+
### Functions
|
49
|
+
|
50
|
+
```
|
51
|
+
> res = cal.week(2014, 1, 1)
|
52
|
+
=> #<Dish::Plate:0x0000010214e6c0
|
53
|
+
@_original_hash=
|
54
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
55
|
+
"end_date"=>Sat, 08 Feb 2014 00:00:00 +0000}>
|
56
|
+
|
57
|
+
> res.start_date
|
58
|
+
=> Sun, 02 Feb 2014 00:00:00 +0000
|
59
|
+
|
60
|
+
> res.end_date
|
61
|
+
=> Sat, 08 Feb 2014 00:00:00 +0000
|
62
|
+
|
63
|
+
> res = cal.period(2014, 1)
|
64
|
+
=> #<Dish::Plate:0x000001014bd7a8
|
65
|
+
@_original_hash=
|
66
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
67
|
+
"end_date"=>Sat, 01 Mar 2014 00:00:00 +0000}>
|
68
|
+
|
69
|
+
> res = cal.quarter(2014, 1)
|
70
|
+
=> #<Dish::Plate:0x0000010153e628
|
71
|
+
@_original_hash=
|
72
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
73
|
+
"end_date"=>Sat, 03 May 2014 00:00:00 +0000}>
|
74
|
+
|
75
|
+
> res = cal.season(2014, 1)
|
76
|
+
=> #<Dish::Plate:0x0000010188eee0
|
77
|
+
@_original_hash=
|
78
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
79
|
+
"end_date"=>Sat, 02 Aug 2014 00:00:00 +0000}>
|
80
|
+
|
81
|
+
> res = cal.year(2014)
|
82
|
+
=> #<Dish::Plate:0x000001019100a8
|
83
|
+
@_original_hash=
|
84
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
85
|
+
"end_date"=>Sat, 31 Jan 2015 00:00:00 +0000}>
|
86
|
+
```
|
87
|
+
|
88
|
+
Handles Retail Leap years
|
89
|
+
|
90
|
+
```
|
91
|
+
> res = cal.year(2006)
|
92
|
+
=> #<Dish::Plate:0x00000101979558
|
93
|
+
@_original_hash=
|
94
|
+
{"start_date"=>Sun, 29 Jan 2006 00:00:00 +0000,
|
95
|
+
"end_date"=>Sat, 03 Feb 2007 00:00:00 +0000}>
|
96
|
+
```
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
1. Fork it ( http://github.com/kitwalker12/retail_calendar/fork )
|
101
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
102
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
103
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
104
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'nested']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
require "dish"
|
3
|
+
|
4
|
+
module RetailCalendar
|
5
|
+
class Finder
|
6
|
+
attr_accessor :offset
|
7
|
+
@offset
|
8
|
+
|
9
|
+
YEAR_LENGTH = 364
|
10
|
+
SEASON_LENGTH = YEAR_LENGTH / 2
|
11
|
+
QUARTER_LENGTH = SEASON_LENGTH / 2
|
12
|
+
|
13
|
+
def initialize(offset = '+0000')
|
14
|
+
@offset = offset
|
15
|
+
end
|
16
|
+
|
17
|
+
def week(year, period, week)
|
18
|
+
period = period.to_i
|
19
|
+
raise ArgumentError, 'invalid period' if (period > 12 or period < 1)
|
20
|
+
week = week.to_i
|
21
|
+
raise ArgumentError, 'invalid week' if (week > 5 or week < 1)
|
22
|
+
start_date = period(year, period).start_date
|
23
|
+
for i in 1..(week - 1)
|
24
|
+
start_date = start_date + 7
|
25
|
+
end
|
26
|
+
end_date = start_date + 1.week - 1
|
27
|
+
create_return_object(start_date,end_date)
|
28
|
+
end
|
29
|
+
|
30
|
+
def period(year, period)
|
31
|
+
period = period.to_i
|
32
|
+
raise ArgumentError, 'invalid period' if (period > 12 or period < 1)
|
33
|
+
start_date = start_time_for_year(year)
|
34
|
+
for i in 1..(period - 1)
|
35
|
+
start_date = start_date + weeks_in_month((i % 12) + 1).weeks
|
36
|
+
end
|
37
|
+
end_date = start_date + weeks_in_month((period % 12) + 1).weeks - 1
|
38
|
+
if year_has_extra_week?(year) and period == 12
|
39
|
+
end_date = end_date + 1.week
|
40
|
+
end
|
41
|
+
create_return_object(start_date,end_date)
|
42
|
+
end
|
43
|
+
|
44
|
+
def quarter(year, quarter)
|
45
|
+
quarter = quarter.to_i
|
46
|
+
raise ArgumentError, 'invalid quarter' if (quarter > 4 or quarter < 1)
|
47
|
+
start_date = start_time_for_year(year) + (QUARTER_LENGTH * (quarter - 1))
|
48
|
+
end_date = start_date + QUARTER_LENGTH - 1
|
49
|
+
if year_has_extra_week?(year) and quarter == 4
|
50
|
+
end_date = end_date + 1.week
|
51
|
+
end
|
52
|
+
create_return_object(start_date,end_date)
|
53
|
+
end
|
54
|
+
|
55
|
+
def season(year, season)
|
56
|
+
season = season.to_i
|
57
|
+
raise ArgumentError, 'invalid season' if (season > 2 or season < 1)
|
58
|
+
start_date = start_time_for_year(year) + (SEASON_LENGTH * (season - 1))
|
59
|
+
end_date = start_date + SEASON_LENGTH - 1
|
60
|
+
if year_has_extra_week?(year) and season == 2
|
61
|
+
end_date = end_date + 1.week
|
62
|
+
end
|
63
|
+
create_return_object(start_date,end_date)
|
64
|
+
end
|
65
|
+
|
66
|
+
def year(year)
|
67
|
+
start_date = start_time_for_year(year)
|
68
|
+
end_date = start_date + YEAR_LENGTH - 1
|
69
|
+
end_date = year_has_extra_week?(year) ? (end_date + 1.week) : end_date
|
70
|
+
create_return_object(start_date,end_date)
|
71
|
+
end
|
72
|
+
|
73
|
+
def last_year
|
74
|
+
previous_year = DateTime.now.change(:offset => @offset).year - 1
|
75
|
+
year(previous_year)
|
76
|
+
end
|
77
|
+
|
78
|
+
def last_season
|
79
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
80
|
+
current_season = get_current_season
|
81
|
+
if current_season == 1
|
82
|
+
previous_year = current_year - 1
|
83
|
+
previous_season = 2
|
84
|
+
else
|
85
|
+
previous_year = current_year
|
86
|
+
previous_season = current_season - 1
|
87
|
+
end
|
88
|
+
season(previous_year, previous_season)
|
89
|
+
end
|
90
|
+
|
91
|
+
def last_quarter
|
92
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
93
|
+
current_quarter = get_current_quarter
|
94
|
+
if current_quarter == 1
|
95
|
+
previous_year = current_year - 1
|
96
|
+
previous_quarter = 4
|
97
|
+
else
|
98
|
+
previous_year = current_year
|
99
|
+
previous_quarter = current_quarter - 1
|
100
|
+
end
|
101
|
+
quarter(previous_year, previous_quarter)
|
102
|
+
end
|
103
|
+
|
104
|
+
def last_period
|
105
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
106
|
+
current_period = get_current_period
|
107
|
+
if current_period == 1
|
108
|
+
previous_year = current_year - 1
|
109
|
+
previous_period = 12
|
110
|
+
else
|
111
|
+
previous_year = current_year
|
112
|
+
previous_period = current_period - 1
|
113
|
+
end
|
114
|
+
period(previous_year, previous_period)
|
115
|
+
end
|
116
|
+
|
117
|
+
def last_week
|
118
|
+
start_date = DateTime.now.change(:offset => @offset) - 1.week
|
119
|
+
start_date = start_date.beginning_of_week(start_day = :sunday)
|
120
|
+
end_date = start_date + 1.week - 1
|
121
|
+
create_return_object(start_date,end_date)
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def get_current_season
|
127
|
+
curr_date = DateTime.now.change(:offset => @offset)
|
128
|
+
start_date = start_time_for_year(curr_date.year)
|
129
|
+
days_passed = (curr_date.to_date - start_date.to_date).to_i
|
130
|
+
days_passed < SEASON_LENGTH ? 1 : 2
|
131
|
+
end
|
132
|
+
|
133
|
+
def get_current_quarter
|
134
|
+
curr_date = DateTime.now.change(:offset => @offset)
|
135
|
+
start_date = start_time_for_year(curr_date.year)
|
136
|
+
days_passed = (curr_date.to_date - start_date.to_date).to_i
|
137
|
+
case days_passed
|
138
|
+
when 0..91
|
139
|
+
1
|
140
|
+
when 92..182
|
141
|
+
2
|
142
|
+
when 183..273
|
143
|
+
3
|
144
|
+
else
|
145
|
+
4
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_current_period
|
150
|
+
curr_date = DateTime.now.change(:offset => @offset)
|
151
|
+
start_date = start_time_for_year(curr_date.year)
|
152
|
+
period = 1
|
153
|
+
while start_date < curr_date
|
154
|
+
no_weeks = weeks_in_month(period + 1)
|
155
|
+
start_date += no_weeks.weeks
|
156
|
+
period += 1
|
157
|
+
end
|
158
|
+
period - 1
|
159
|
+
end
|
160
|
+
|
161
|
+
def create_return_object(start_date, end_date)
|
162
|
+
Dish({
|
163
|
+
start_date: start_date,
|
164
|
+
end_date: end_date
|
165
|
+
})
|
166
|
+
end
|
167
|
+
|
168
|
+
def weeks_in_month(month)
|
169
|
+
month = month.to_i
|
170
|
+
month % 3 == 0 ? 5 : 4
|
171
|
+
end
|
172
|
+
|
173
|
+
def start_time_for_year(year)
|
174
|
+
year = year.to_i
|
175
|
+
jan31 = DateTime.new(year,1,31).change(:offset => @offset)
|
176
|
+
jan31day = jan31.cwday
|
177
|
+
if jan31day < 3
|
178
|
+
start = jan31 - jan31day
|
179
|
+
elsif jan31day < 7
|
180
|
+
start = jan31 + (7 - jan31day)
|
181
|
+
elsif jan31day == 7
|
182
|
+
start = jan31
|
183
|
+
end
|
184
|
+
start
|
185
|
+
end
|
186
|
+
|
187
|
+
def year_has_extra_week?(year)
|
188
|
+
year = year.to_i
|
189
|
+
expected = start_time_for_year(year) + 364
|
190
|
+
actual = start_time_for_year(year + 1)
|
191
|
+
actual > expected ? true : false
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'retail_calendar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "retail_calendar"
|
8
|
+
spec.version = RetailCalendar::VERSION
|
9
|
+
spec.authors = ["Aditya Raghuwanshi"]
|
10
|
+
spec.email = ["adi.version1@gmail.com"]
|
11
|
+
spec.summary = %q{Find Dates in the Retails Calendar}
|
12
|
+
spec.description = %q{Gem for finding ranges in Retail or the 4-5-4 Calendar format}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "activesupport"
|
24
|
+
spec.add_development_dependency "dish"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
end
|
data/spec/finder_spec.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RetailCalendar::Finder do
|
4
|
+
let(:cal) { RetailCalendar::Finder.new }
|
5
|
+
|
6
|
+
it "should return correct week start and end dates" do
|
7
|
+
res = cal.week(2014, 1, 1)
|
8
|
+
expect(res.start_date).to eq(DateTime.new(2014,2,2))
|
9
|
+
expect(res.end_date).to eq(DateTime.new(2014,2,8))
|
10
|
+
res = cal.week(2014, 5, 2)
|
11
|
+
expect(res.start_date).to eq(DateTime.new(2014,6,8))
|
12
|
+
expect(res.end_date).to eq(DateTime.new(2014,6,14))
|
13
|
+
res = cal.week(2014, 12, 3)
|
14
|
+
expect(res.start_date).to eq(DateTime.new(2015,1,18))
|
15
|
+
expect(res.end_date).to eq(DateTime.new(2015,1,24))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return correct period start and end dates" do
|
19
|
+
res = cal.period(2014, 1)
|
20
|
+
expect(res.start_date).to eq(DateTime.new(2014,2,2))
|
21
|
+
expect(res.end_date).to eq(DateTime.new(2014,3,1))
|
22
|
+
res = cal.period(2014, 4)
|
23
|
+
expect(res.start_date).to eq(DateTime.new(2014,5,4))
|
24
|
+
expect(res.end_date).to eq(DateTime.new(2014,5,31))
|
25
|
+
res = cal.period(2014, 8)
|
26
|
+
expect(res.start_date).to eq(DateTime.new(2014,8,31))
|
27
|
+
expect(res.end_date).to eq(DateTime.new(2014,10,4))
|
28
|
+
res = cal.period(2014, 12)
|
29
|
+
expect(res.start_date).to eq(DateTime.new(2015,1,4))
|
30
|
+
expect(res.end_date).to eq(DateTime.new(2015,1,31))
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return correct quarter start and end dates" do
|
34
|
+
res = cal.quarter(2014, 1)
|
35
|
+
expect(res.start_date).to eq(DateTime.new(2014,2,2))
|
36
|
+
expect(res.end_date).to eq(DateTime.new(2014,5,3))
|
37
|
+
res = cal.quarter(2014, 2)
|
38
|
+
expect(res.start_date).to eq(DateTime.new(2014,5,4))
|
39
|
+
expect(res.end_date).to eq(DateTime.new(2014,8,2))
|
40
|
+
res = cal.quarter(2014, 3)
|
41
|
+
expect(res.start_date).to eq(DateTime.new(2014,8,3))
|
42
|
+
expect(res.end_date).to eq(DateTime.new(2014,11,1))
|
43
|
+
res = cal.quarter(2014, 4)
|
44
|
+
expect(res.start_date).to eq(DateTime.new(2014,11,2))
|
45
|
+
expect(res.end_date).to eq(DateTime.new(2015,1,31))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return correct season start and end dates" do
|
49
|
+
res = cal.season(2014, 1)
|
50
|
+
expect(res.start_date).to eq(DateTime.new(2014,2,2))
|
51
|
+
expect(res.end_date).to eq(DateTime.new(2014,8,2))
|
52
|
+
res = cal.season(2014, 2)
|
53
|
+
expect(res.start_date).to eq(DateTime.new(2014,8,3))
|
54
|
+
expect(res.end_date).to eq(DateTime.new(2015,1,31))
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return correct year start and end dates" do
|
58
|
+
res = cal.year(2014)
|
59
|
+
expect(res.start_date).to eq(DateTime.new(2014,2,2))
|
60
|
+
expect(res.end_date).to eq(DateTime.new(2015,1,31))
|
61
|
+
end
|
62
|
+
|
63
|
+
it "handle leap years" do
|
64
|
+
res = cal.year(2006)
|
65
|
+
expect(res.start_date).to eq(DateTime.new(2006,1,29))
|
66
|
+
expect(res.end_date).to eq(DateTime.new(2007,2,3))
|
67
|
+
res = cal.season(2006,2)
|
68
|
+
expect(res.start_date).to eq(DateTime.new(2006,7,30))
|
69
|
+
expect(res.end_date).to eq(DateTime.new(2007,2,3))
|
70
|
+
res = cal.quarter(2006,3)
|
71
|
+
expect(res.start_date).to eq(DateTime.new(2006,7,30))
|
72
|
+
expect(res.end_date).to eq(DateTime.new(2006,10,28))
|
73
|
+
res = cal.period(2006,12)
|
74
|
+
expect(res.start_date).to eq(DateTime.new(2006,12,31))
|
75
|
+
expect(res.end_date).to eq(DateTime.new(2007,2,3))
|
76
|
+
res = cal.week(2006,12,5)
|
77
|
+
expect(res.start_date).to eq(DateTime.new(2007,1,28))
|
78
|
+
expect(res.end_date).to eq(DateTime.new(2007,2,3))
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: retail_calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aditya Raghuwanshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dish
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Gem for finding ranges in Retail or the 4-5-4 Calendar format
|
98
|
+
email:
|
99
|
+
- adi.version1@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/retail_calendar.rb
|
112
|
+
- lib/retail_calendar/finder.rb
|
113
|
+
- lib/retail_calendar/version.rb
|
114
|
+
- retail_calendar.gemspec
|
115
|
+
- spec/finder_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: ''
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.2.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Find Dates in the Retails Calendar
|
141
|
+
test_files:
|
142
|
+
- spec/finder_spec.rb
|
143
|
+
- spec/spec_helper.rb
|