merch_calendar 0.0.4 → 0.0.5.rc1

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: 753130ad5089afe3bbf400936388243467903ece
4
- data.tar.gz: c070388ae4bc90740a312caa54af3c973f38c5d7
3
+ metadata.gz: 85573fff400cbd649739fb93ac2a8c2508b5bf79
4
+ data.tar.gz: fd9217298584820c4fb53bf18747eac9686eb3c5
5
5
  SHA512:
6
- metadata.gz: 2309d87f9066582a29f97c1c5bcff1c87ae6beaabc74586ad221f889c7092b5f3787d6948942364bab59441d625a869c60a1cce5c865286072875edc8530837b
7
- data.tar.gz: 07d1d3dff25f45f0a7ca81e308c8e1cf27ec455088238e130f9b2131745628c43175bf50e5937f0d41f885d008ba456a17f08c9f963341463ad387a33d9bf6ae
6
+ metadata.gz: 6821779fb805f04db16ab44b8dfc52358075c2bf53b6dec1a7af5405a10ab9a467a94be679a170c2bd8478261a6a7a1e30ea2f5d48297893ba1d7f83bfe1c130
7
+ data.tar.gz: 7c7a670ff7a74df32f987dc24b86c522c8847bd38d3ba15ae9d23f685e800b249de273d7973b43fb6813c85d766620e5b35e98afb72a9b1dc38e32a1ea0bed2f
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ merch_calendar
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.3.0
data/.travis.yml CHANGED
@@ -2,5 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.0
4
4
  - 2.0.0
5
+ - 2.2.0
6
+ - 1.9.3
5
7
  notifications:
6
8
  email: false
9
+
@@ -0,0 +1,6 @@
1
+ # Code of Conduct
2
+
3
+ We are committed to keeping our community open and inclusive.
4
+
5
+ **Our Code of Conduct can be found here**:
6
+ http://opensource.stitchfix.com/code-of-conduct.html
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,18 @@
1
+ # Contributing
2
+ Thanks for using and improving *merch_calendar*! If you'd like to help out, check out [the project's issues list](https://github.com/stitchfix/merch_calendar/issues) for ideas on what could be improved. If there's an idea you'd like to propose, or a design change, feel free to file a new issue or send a pull request:
3
+
4
+ 1. [Fork][fork] the repo.
5
+ 1. [Create a topic branch.][branch]
6
+ 1. Write tests.
7
+ 1. Implement your feature or fix bug.
8
+ 1. Add, commit, and push your changes.
9
+ 1. [Submit a pull request.][pr]
10
+
11
+ [fork]: https://help.github.com/articles/fork-a-repo/
12
+ [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
13
+ [pr]: https://help.github.com/articles/using-pull-requests/
14
+
15
+ ## General Guidelines
16
+
17
+ * When in doubt, test it. If you can't test it, re-think what you are doing.
18
+ * Code formatting and internal application architecture should be consistent.
data/Gemfile.lock CHANGED
@@ -1,63 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- merch_calendar (0.0.4)
4
+ merch_calendar (0.0.5.rc1)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
8
8
  specs:
9
- coderay (1.1.0)
10
- coveralls (0.8.1)
9
+ coderay (1.1.1)
10
+ coveralls (0.8.13)
11
11
  json (~> 1.8)
12
- rest-client (>= 1.6.8, < 2)
13
- simplecov (~> 0.10.0)
12
+ simplecov (~> 0.11.0)
14
13
  term-ansicolor (~> 1.3)
15
14
  thor (~> 0.19.1)
15
+ tins (~> 1.6.0)
16
16
  diff-lcs (1.2.5)
17
17
  docile (1.1.5)
18
- domain_name (0.5.24)
19
- unf (>= 0.0.5, < 1.0.0)
20
- http-cookie (1.0.2)
21
- domain_name (~> 0.5)
22
- json (1.8.2)
18
+ json (1.8.3)
23
19
  method_source (0.8.2)
24
- mime-types (2.5)
25
- netrc (0.10.3)
26
- pry (0.10.1)
20
+ pry (0.10.3)
27
21
  coderay (~> 1.1.0)
28
22
  method_source (~> 0.8.1)
29
23
  slop (~> 3.4)
30
- rake (10.4.2)
31
- rest-client (1.8.0)
32
- http-cookie (>= 1.0.2, < 2.0)
33
- mime-types (>= 1.16, < 3.0)
34
- netrc (~> 0.7)
35
- rspec (3.2.0)
36
- rspec-core (~> 3.2.0)
37
- rspec-expectations (~> 3.2.0)
38
- rspec-mocks (~> 3.2.0)
39
- rspec-core (3.2.2)
40
- rspec-support (~> 3.2.0)
41
- rspec-expectations (3.2.0)
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)
42
32
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.2.0)
44
- rspec-mocks (3.2.1)
33
+ rspec-support (~> 3.4.0)
34
+ rspec-mocks (3.4.1)
45
35
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.2.0)
47
- rspec-support (3.2.2)
48
- simplecov (0.10.0)
36
+ rspec-support (~> 3.4.0)
37
+ rspec-support (3.4.1)
38
+ simplecov (0.11.2)
49
39
  docile (~> 1.1.0)
50
40
  json (~> 1.8)
51
41
  simplecov-html (~> 0.10.0)
52
42
  simplecov-html (0.10.0)
53
43
  slop (3.6.0)
54
- term-ansicolor (1.3.0)
44
+ term-ansicolor (1.3.2)
55
45
  tins (~> 1.0)
56
46
  thor (0.19.1)
57
- tins (1.5.1)
58
- unf (0.1.4)
59
- unf_ext
60
- unf_ext (0.0.7.1)
47
+ tins (1.6.0)
61
48
 
62
49
  PLATFORMS
63
50
  ruby
@@ -69,3 +56,6 @@ DEPENDENCIES
69
56
  rake
70
57
  rspec (>= 3.0.0)
71
58
  simplecov
59
+
60
+ BUNDLED WITH
61
+ 1.15.0
data/README.md CHANGED
@@ -119,6 +119,14 @@ MerchCalendar.weeks_in_year(2015)
119
119
 
120
120
  # returns an array of MerchWeek objects for each week within the provided month
121
121
  MerchCalendar.weeks_for_month(2014, 1)
122
+
123
+ # get the start date of a given merch week
124
+ MerchCalendar.start_of_week(2017, 4, 1)
125
+ # => #<Date: 2017-04-02 ((2457846j,0s,0n),+0s,2299161j)>
126
+
127
+ # get the end date of a given merch week
128
+ MerchCalendar.end_of_week(2017, 4, 1)
129
+ # => #<Date: 2017-04-08 ((2457852j,0s,0n),+0s,2299161j)>
122
130
  ```
123
131
 
124
132
  ## Documentation
@@ -1,3 +1,5 @@
1
+ require "date"
2
+
1
3
  module MerchCalendar
2
4
 
3
5
  # @api private
@@ -49,6 +51,17 @@ module MerchCalendar
49
51
  end
50
52
  end
51
53
 
54
+ def start_of_week(year, month, merch_week)
55
+ weeks = MerchCalendar.weeks_for_month(year, month)
56
+
57
+ week = weeks.find { |week| week.week == merch_week }
58
+ week.start_of_week
59
+ end
60
+
61
+ def end_of_week(year, month, merch_week)
62
+ start_of_week(year, month, merch_week) + 6
63
+ end
64
+
52
65
  # Return the starting date for a particular quarter
53
66
  def start_of_quarter(year, quarter)
54
67
  case quarter
@@ -3,6 +3,28 @@ module MerchCalendar
3
3
  # Utility methods for the merch calendar
4
4
  module Util
5
5
 
6
+ # The start date of the week
7
+ #
8
+ # @param year [Fixnum] the merch year
9
+ # @param month [Fixnum] an integer specifying the julian month.
10
+ # @param month [Fixnum] an integer specifying the merch week.
11
+ #
12
+ # @return [Date] the starting date of the specified week
13
+ def start_of_week(year, month, week)
14
+ date_calc.start_of_week(year, month, week)
15
+ end
16
+
17
+ # The end date of the week
18
+ #
19
+ # @param year [Fixnum] the merch year
20
+ # @param month [Fixnum] an integer specifying the julian month.
21
+ # @param month [Fixnum] an integer specifying the merch week.
22
+ #
23
+ # @return [Date] the ending date of the specified week
24
+ def end_of_week(year, month, week)
25
+ date_calc.end_of_week(year, month, week)
26
+ end
27
+
6
28
  # The start date of the month
7
29
  #
8
30
  # @example
@@ -1,3 +1,3 @@
1
1
  module MerchCalendar
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5.rc1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MerchCalendar do
3
+ RSpec.describe MerchCalendar do
4
4
  context "responds to util methods" do
5
5
  [
6
6
  :start_of_month, :end_of_month,
@@ -17,6 +17,17 @@ describe MerchCalendar do
17
17
  end
18
18
  end
19
19
 
20
+ describe "#start_of_week" do
21
+ it "returns the correct date for a given merch week" do
22
+ expect(described_class.start_of_week(2017, 4, 1)).to eq Date.new(2017, 4, 2)
23
+ end
24
+ end
25
+
26
+ describe "#end_of_week" do
27
+ it "returns the correct date for a given merch week" do
28
+ expect(described_class.end_of_week(2017, 4, 1)).to eq Date.new(2017, 4, 8)
29
+ end
30
+ end
20
31
 
21
32
  it "#start_of_month" do
22
33
  expect(described_class.start_of_month(2014,1)).to be_a Date
@@ -34,7 +45,6 @@ describe MerchCalendar do
34
45
  expect(described_class.end_of_year(2014)).to be_a Date
35
46
  end
36
47
 
37
-
38
48
  it "#start_of_quarter" do
39
49
  expect(described_class.start_of_quarter(2014,1)).to be_a Date
40
50
  end
@@ -47,12 +57,12 @@ describe MerchCalendar do
47
57
  expect(described_class.weeks_in_year(2014)).to be_a Fixnum
48
58
  end
49
59
 
50
-
51
60
  it "#merch_to_julian" do
52
61
  expect(described_class.merch_to_julian(1)).to be_a Fixnum
53
62
  end
63
+
54
64
  it "#julian_to_merch" do
55
65
  expect(described_class.julian_to_merch(1)).to be_a Fixnum
56
66
  end
57
67
 
58
- end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merch_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch Dempsey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -90,8 +90,11 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
+ - ".ruby-gemset"
93
94
  - ".ruby-version"
94
95
  - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - CONTRIBUTING.md
95
98
  - Gemfile
96
99
  - Gemfile.lock
97
100
  - LICENSE
@@ -127,12 +130,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
130
  version: '0'
128
131
  required_rubygems_version: !ruby/object:Gem::Requirement
129
132
  requirements:
130
- - - ">="
133
+ - - ">"
131
134
  - !ruby/object:Gem::Version
132
- version: '0'
135
+ version: 1.3.1
133
136
  requirements: []
134
137
  rubyforge_project:
135
- rubygems_version: 2.2.0
138
+ rubygems_version: 2.6.12
136
139
  signing_key:
137
140
  specification_version: 4
138
141
  summary: Utility for manipulating dates within a 4-5-4 retail calendar