black_friday 1.0.1 → 1.0.3

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
  SHA256:
3
- metadata.gz: 4e679dd4cfca531e409eef4065b42bb7d057724366cdee2828749191f908547b
4
- data.tar.gz: 606472c6b02891eb1cac69679c07823ba5a6c082f8973fb66a7051cf80be76c2
3
+ metadata.gz: 7ffbcf76eea0862cddaa63f91a21a19eb41e666eb9321eb3115a8846a39c95ca
4
+ data.tar.gz: 942723a966fc7e783c3a3f5e39847c8b98dd5fca44acdde11c6e9f209f222250
5
5
  SHA512:
6
- metadata.gz: ce90f9beccdc0eb519ec21b1663dd180afd585c057ae0b075a16156467931fea49808ab25aadeccd5adec4036306215353034d8d2f9a0fa74d2fe17c0f3736b8
7
- data.tar.gz: 0eaf8488af278d3858040b27fb08f798032982355eb93558378b617a9891cad207ae95a26b2aa6fbc3e0d000dad74f0269369e10cc23f1fd9cccbc2af037468a
6
+ metadata.gz: 9572cb6a4739e4ac926f133783a88af828a8c571862f5430b52b8d693dc50ea035cfde6e56f31279dea77b7eaf97f34f622d67ecc7515e4645020b070f24bff0
7
+ data.tar.gz: aa148f4b131fded46ea48a28827723104f51687e9261e9e01554b7925ea68baac1d936e91f41bd5a6a7832e11cff256c1930c196dcd5be718a6733c9d284c4b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2024-11-21
3
+ ## [1.0.2] - 2024-11-22
4
+
5
+ - Add `BlackFriday.range_for(:name)` to retrieve a range
6
+
7
+ ## [1.0.1] - 2024-11-22
8
+
9
+ - Add support for `ActiveSupport::TimeWithZone` by switching to `cover?`
10
+
11
+ ## [1.0.0] - 2024-11-22
4
12
 
5
13
  - Initial release
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Add Black Friday sales to your Rails app.
4
4
 
5
+ [![Ruby](https://github.com/excid3/black_friday/actions/workflows/main.yml/badge.svg)](https://github.com/excid3/black_friday/actions/workflows/main.yml)
6
+
5
7
  ## Installation
6
8
 
7
9
  Install the gem and add to the application's Gemfile by executing:
@@ -54,6 +56,12 @@ BlackFriday.active?(:black_friday, :labor_day)
54
56
  #=> true/false
55
57
  ```
56
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
+
57
65
  To check the active sales:
58
66
 
59
67
  ```ruby
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlackFriday
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.3"
5
5
  end
data/lib/black_friday.rb CHANGED
@@ -37,6 +37,10 @@ module BlackFriday
37
37
  range.cover?(range.first.is_a?(Date) ? Date.today : Time.current)
38
38
  end
39
39
 
40
+ def range_for(sale_name)
41
+ instance_eval(&sales.fetch(sale_name))
42
+ end
43
+
40
44
  # Date helpers
41
45
 
42
46
  def thanksgiving(year = Date.today.year)
@@ -45,6 +49,12 @@ module BlackFriday
45
49
  first_thursday + 3.weeks
46
50
  end
47
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
+
48
58
  def black_friday(year = Date.today.year)
49
59
  thanksgiving(year) + 1.day
50
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: black_friday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver