black_friday 1.0.2 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea12f11a5c0d8be650cc27e5d75d60ffbfc36c285d9a8f2213103f39e506694b
4
- data.tar.gz: 5c6061355894c4c599627fc6bba3b92e01e51cacfa70e043396335cdd1f267d3
3
+ metadata.gz: 0e23c17366d25e68bd87d013eaad0ce6d85b59c791dddcbf1015586ccd533727
4
+ data.tar.gz: 0fbd019abb0e765476f9360110ad6eb43a16266298be9a3dcc11295b24976fcb
5
5
  SHA512:
6
- metadata.gz: 80a4f74fcfabf32d203e24f1e80306f243287622dde2f5186a856b936965df94849850a97e036ac7149b42ae4d0cea6f8d62a74a0d726b861126435e5fa7cb88
7
- data.tar.gz: c47e9b57af07d2da3f83107e8e2b42361fe5c96550b218267ddfdc88184fb16bd0d3f531579e424ce4f91caeb85d5037e869c6b945616f84e420563aa849e8a0
6
+ metadata.gz: e573a96174ddfb06dc8ca4373711ee238cf107f28af55f411ac0e824be237189fce146abc9bfad1bff54aff57b99cd01d1d6b2808ef9c2ff6b91ca65b0e59be6
7
+ data.tar.gz: 560eeca28bbc44e4e8c60d6a4cbd0b1e10e065d824c39483af54a1367f733f85df78a5e0103231b34567fb302d4c88fb96aacd2269fcc7f5f49d18628a419179
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.4] - 2024-11-27
4
+
5
+ - Fix `current_sales` to return an array of names, not a hash.
6
+
7
+ ## [1.0.3] - 2024-11-22
8
+
9
+ - Add Canadian Thanksgiving
10
+ - Add `range_for(name)` to retrieve a range easily
11
+
3
12
  ## [1.0.2] - 2024-11-22
4
13
 
5
14
  - Add `BlackFriday.range_for(:name)` to retrieve a range
data/README.md CHANGED
@@ -56,6 +56,12 @@ BlackFriday.active?(:black_friday, :labor_day)
56
56
  #=> true/false
57
57
  ```
58
58
 
59
+ Render a banner when a sale is active:
60
+
61
+ ```erb
62
+ <%= render "banners/black_friday" if BlackFriday.active?(:black_friday) %>
63
+ ```
64
+
59
65
  To check the active sales:
60
66
 
61
67
  ```ruby
@@ -73,7 +79,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
73
79
 
74
80
  ## Contributing
75
81
 
76
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/black_friday. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/black_friday/blob/main/CODE_OF_CONDUCT.md).
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/excid3/black_friday. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/excid3/black_friday/blob/main/CODE_OF_CONDUCT.md).
77
83
 
78
84
  ## License
79
85
 
@@ -81,4 +87,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
81
87
 
82
88
  ## Code of Conduct
83
89
 
84
- Everyone interacting in the BlackFriday project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/black_friday/blob/main/CODE_OF_CONDUCT.md).
90
+ Everyone interacting in the BlackFriday project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/excid3/black_friday/blob/main/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlackFriday
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
5
5
  end
data/lib/black_friday.rb CHANGED
@@ -24,8 +24,8 @@ module BlackFriday
24
24
  end
25
25
 
26
26
  def current_sales
27
- sales.select do |name, block|
28
- in_range? instance_eval(&block)
27
+ sales.filter_map do |name, block|
28
+ name if in_range? instance_eval(&block)
29
29
  end
30
30
  end
31
31
 
@@ -49,6 +49,12 @@ module BlackFriday
49
49
  first_thursday + 3.weeks
50
50
  end
51
51
 
52
+ def canadian_thanksgiving(year = Date.today.year)
53
+ oct_1st = Date.new(year, 10, 1)
54
+ first_monday = oct_1st.monday? ? oct_1st : oct_1st.next_occurring(:monday)
55
+ first_monday + 1.weeks
56
+ end
57
+
52
58
  def black_friday(year = Date.today.year)
53
59
  thanksgiving(year) + 1.day
54
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: black_friday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-22 00:00:00.000000000 Z
11
+ date: 2024-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport