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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db5766f9277eed621171cc03dc5ff1305c5044e476d0ab99e8481ed0befef341
4
- data.tar.gz: 92f3346ceb90d87c53e58537775f4a7c6a9aac692d06c22f9b6c10658dababaf
3
+ metadata.gz: ccf7bdbd850efb5313af654a3f148340aff5237fcd932c5260a2507e500159da
4
+ data.tar.gz: 020fe2b64a182ae1ae554ebf66c45b2397ee3db11a4188f12a057c257908cace
5
5
  SHA512:
6
- metadata.gz: 3f7bf2f8af77d887600e457c6ad1cec63a93dec3992f46ec3cc203364b1c8f3a90161792f313ce88f2cdf785c52b862155c82103cc5d4bb87b5548e33bbb2012
7
- data.tar.gz: adad32e7c72b74a3016cb99dde4583ff079c77b2217b49903ff499d992cf46807a25614f3f2a8a377d60823d2b9b74c057e176c2dccb6707de078068d422fb83
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
- How to use my plugin.
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
- ((from.presence && Time.zone.parse(from))...(to.presence && Time.zone.parse(to))).cover?(time)
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
@@ -1,3 +1,3 @@
1
1
  module GlobalAlerts
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
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
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-08-24 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails