black_friday 1.0.1 → 1.0.3
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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +8 -0
- data/lib/black_friday/version.rb +1 -1
- data/lib/black_friday.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ffbcf76eea0862cddaa63f91a21a19eb41e666eb9321eb3115a8846a39c95ca
|
4
|
+
data.tar.gz: 942723a966fc7e783c3a3f5e39847c8b98dd5fca44acdde11c6e9f209f222250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9572cb6a4739e4ac926f133783a88af828a8c571862f5430b52b8d693dc50ea035cfde6e56f31279dea77b7eaf97f34f622d67ecc7515e4645020b070f24bff0
|
7
|
+
data.tar.gz: aa148f4b131fded46ea48a28827723104f51687e9261e9e01554b7925ea68baac1d936e91f41bd5a6a7832e11cff256c1930c196dcd5be718a6733c9d284c4b4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [
|
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
|
+
[](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
|
data/lib/black_friday/version.rb
CHANGED
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
|