global_alerts 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -1
- data/app/models/global_alerts/alert.rb +10 -1
- data/lib/global_alerts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf7bdbd850efb5313af654a3f148340aff5237fcd932c5260a2507e500159da
|
4
|
+
data.tar.gz: 020fe2b64a182ae1ae554ebf66c45b2397ee3db11a4188f12a057c257908cace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15da56ca9cec35b75406bd5f586c3084ffe273a8d63f58e92c30e561746275933fbc8e531add0aa580e04d97f696e61918c9ec89f56a45fcb8cfdab0bf58d399
|
7
|
+
data.tar.gz: 0f8514c204fed8003d143d9c5cf8b7ad97f13c5bd1ed79404c677928519acc614ecbc0bf1385d963d48a8e571558121de67fc8f0deaa8fda5f25640456a80f80
|
data/README.md
CHANGED
@@ -2,7 +2,27 @@
|
|
2
2
|
Short description and motivation.
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
|
5
|
+
|
6
|
+
### Consuming
|
7
|
+
|
8
|
+
- Add the gem
|
9
|
+
- Set any engine configuration:
|
10
|
+
- GlobalAlerts::Engine.config.cache (Cache for the alerts feed; defaults to the Rails cache)
|
11
|
+
- GlobalAlerts::Engine.config.application_name (Used for app-specific alerts, default is derived from the application name)
|
12
|
+
- GlobalAlerts::Engine.config.url (URL to pull alerts from)
|
13
|
+
- Render the global_alerts/alerts partial
|
14
|
+
|
15
|
+
### Publishing alerts
|
16
|
+
|
17
|
+
In a YAML file (e.g. https://github.com/sul-dlss/global_alerts/blob/main/sul.yaml by default), configure alerts using:
|
18
|
+
|
19
|
+
- `html`: the HTML-safe alert text
|
20
|
+
- `application_name`: used for application-specific alert text; matches against the consumer's `GlobalAlerts::Engine.config.application_name`
|
21
|
+
- `from`/`to`: schedule alerts for particular times (also supports open-ended ranges with only `from` or only `to`)
|
22
|
+
|
23
|
+
Consuming applications will pick only the first relevant alert.
|
24
|
+
|
25
|
+
Restart any consuming applications.
|
6
26
|
|
7
27
|
## Installation
|
8
28
|
Add this line to your application's Gemfile:
|
@@ -49,7 +49,16 @@ module GlobalAlerts
|
|
49
49
|
return false if for_application == application_name
|
50
50
|
|
51
51
|
return true if from.nil? && to.nil?
|
52
|
-
|
52
|
+
|
53
|
+
range.cover?(time)
|
54
|
+
end
|
55
|
+
|
56
|
+
def range
|
57
|
+
start_of_range = from.presence && Time.zone.parse(from)
|
58
|
+
start_of_range ||= Time.at(0) unless RUBY_VERSION > '2.7'
|
59
|
+
|
60
|
+
end_of_range = to.presence && Time.zone.parse(to)
|
61
|
+
start_of_range...end_of_range
|
53
62
|
end
|
54
63
|
|
55
64
|
def as_html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_alerts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|