unotifier 0.1.1 → 0.2.0
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/Gemfile.lock +1 -1
- data/lib/configuration.rb +2 -0
- data/lib/provider/action_cable.rb +1 -0
- data/lib/settings.rb +28 -0
- data/lib/unotifier/version.rb +1 -1
- data/lib/unotifier.rb +6 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab124f207e21102d80111f02fca618367788bb09e0c3a4565fd9aa74087253e7
|
4
|
+
data.tar.gz: 06b4f14f4252785d1e41a1d79ed754f7c939d6449f33717343f1b1515ee5be99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a441acebc93d75306f68dc241184891d17908c6737c535a2c18f089885814d9ccedc40db76319c0ab7d1e854f2f70e100bff1be9e3a5fe73bf147d91cd3d8d73
|
7
|
+
data.tar.gz: '094405411bf9a32bfde02c00de440c1ffff31c2d051c76c5404688a6395a00f646a613623633a4737573ed8c0e1ab2d7ef52f7d08e6ed46638009d7bf37bf297'
|
data/Gemfile.lock
CHANGED
data/lib/configuration.rb
CHANGED
@@ -4,12 +4,14 @@ module UNotifier
|
|
4
4
|
attr_accessor :external_providers
|
5
5
|
attr_accessor :resource_class
|
6
6
|
attr_accessor :notifications_path
|
7
|
+
attr_accessor :localization_provider
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@site_providers = []
|
10
11
|
@external_providers = []
|
11
12
|
@resource_class = nil
|
12
13
|
@notifications_path = nil
|
14
|
+
@localization_provider = nil
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/settings.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module UNotifier
|
2
|
+
class Settings
|
3
|
+
def self.customizable?(config)
|
4
|
+
%w(regular optional).include?(config["urgency"])
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.filter_customizable(config)
|
8
|
+
config.map do |key, subkeys|
|
9
|
+
filtered = subkeys.select do |subkey, value|
|
10
|
+
(value.has_key?("urgency") && customizable?(value)) ||
|
11
|
+
(value.has_key?("target") && value["target"].values.any? { |subvalue| customizable?(subvalue) })
|
12
|
+
end
|
13
|
+
|
14
|
+
[key, filtered.keys]
|
15
|
+
end.to_h.select { |_, subkeys| subkeys.any? }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.keys_from(config)
|
19
|
+
flatten_keys filter_customizable(config)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.flatten_keys(keys)
|
25
|
+
keys.map { |key, subkeys| subkeys.map { |s| "#{key}.#{s}" } }.flatten
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/unotifier/version.rb
CHANGED
data/lib/unotifier.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "yaml"
|
2
|
-
require "i18n"
|
3
2
|
|
4
3
|
require_relative "unotifier/version"
|
5
4
|
require_relative "exceptions"
|
6
5
|
require_relative "provider"
|
7
6
|
require_relative "configuration"
|
7
|
+
require_relative "settings"
|
8
8
|
|
9
9
|
module UNotifier
|
10
10
|
class << self
|
@@ -21,7 +21,7 @@ module UNotifier
|
|
21
21
|
|
22
22
|
def self.notifications_config
|
23
23
|
@notifications_config ||= YAML.load_file(configuration.notifications_path)
|
24
|
-
rescue Errno::ENOENT
|
24
|
+
rescue Errno::ENOENT
|
25
25
|
raise NotificationsConfigNotFoundError.new(configuration.notifications_path)
|
26
26
|
end
|
27
27
|
|
@@ -74,9 +74,11 @@ module UNotifier
|
|
74
74
|
|
75
75
|
notification = configuration.resource_class.new(
|
76
76
|
key: key,
|
77
|
-
|
78
|
-
|
77
|
+
target: target,
|
78
|
+
title: configuration.localization_provider.t("#{locale_key}.title", params.merge(locale: target.locale, default: "")),
|
79
|
+
body: configuration.localization_provider.t("#{locale_key}.title", params.merge(locale: target.locale, default: "")),
|
79
80
|
link: params[:link],
|
81
|
+
autohide_delay: params[:autohide_delay],
|
80
82
|
urgency: urgency
|
81
83
|
)
|
82
84
|
notification.save!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unotifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Rashev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/provider.rb
|
121
121
|
- lib/provider/action_cable.rb
|
122
122
|
- lib/provider/action_mailer.rb
|
123
|
+
- lib/settings.rb
|
123
124
|
- lib/unotifier.rb
|
124
125
|
- lib/unotifier/version.rb
|
125
126
|
- unotifier.gemspec
|