unotifier 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed6bbfeff3bef2d52c7595a47b48858fc22e09e212ddebce377a2330140936c
4
- data.tar.gz: 875927c0296145d3b1c3a0ac2da3c2db85173efd2784607993abb2a7fac9456f
3
+ metadata.gz: 7e36c94a2ad43b15907fd815bdd1cbcf1ac57ccbaa74669a0679c047cad57cd7
4
+ data.tar.gz: 1f8b421d296c6cecd822a0dffa3570d7da90258e01ba1e8d17d8a01575c3a40e
5
5
  SHA512:
6
- metadata.gz: 6ae210ee39d61e74bad88908a5e9f662f73b73356c5607e80c6869da4f8c82339526887f8411b368c1cc831af4fd4f77965353ad71176628b9b8f88be9fee235
7
- data.tar.gz: 2949be7620780143fbcdbb04957dc70fdfcf63bb37bfb09b84d5cf1b69e7e367a29df3488eb258dc4827ed811d4bf69019633f85e3831ff8b38ae2cb582b78b6
6
+ metadata.gz: 849372e46b95eabf123e16a3be07a61b9b99842defaad61779294df947a89a09ee57b902efe1aab3f1af6e7d6a2b35a8251b25808b517de3cd56639db2ec8ab5
7
+ data.tar.gz: cac003f129456229908890a3bb42e8a0b29910ad7e2f36933c8ff64997d8c09fc9ff6170103f8c20da5944d56328879fe8b723966181a737179dc8b982bca399
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unotifier (0.2.1)
4
+ unotifier (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # UNotifier
2
2
 
3
- [![Build Status](https://travis-ci.com/mgpnd/unotifier.svg?branch=master)](https://travis-ci.com/mgpnd/unotifier)
4
-
5
3
  ## Installation
6
4
 
7
5
  Add this line to your application's Gemfile:
@@ -37,7 +35,7 @@ To store your notifications in database UNotifier uses provided ActiveRecord mod
37
35
 
38
36
  ## Contributing
39
37
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/mgpnd/unotifier.
38
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/hodlhodl/unotifier.
41
39
 
42
40
  ## License
43
41
 
data/lib/settings.rb CHANGED
@@ -13,18 +13,37 @@ module UNotifier
13
13
  (value.has_key?("target") && value["target"].values.any? { |subvalue| customizable?(subvalue) })
14
14
  end
15
15
 
16
- [key, filtered.keys]
17
- end.to_h.select { |_, subkeys| subkeys.any? }
16
+ filtered = filtered.each_with_object({}) do |(subkey, value), out|
17
+ out[subkey] = value["urgency"] ||
18
+ value["target"]
19
+ .select { |_, subvalue| customizable?(subvalue) }
20
+ .map { |_, subvalue| subvalue["urgency"] }
21
+ .first
22
+ end
23
+
24
+ [key, filtered]
25
+ end.to_h.select { |_, subkeys| !subkeys.empty? }
18
26
  end
19
27
 
20
28
  def self.keys_from(config)
21
29
  flatten_keys filter_customizable(config)
22
30
  end
23
31
 
32
+ def self.grouped_by_urgency_keys_from(config)
33
+ keys_from(config).each_with_object({}) do |(key, urgency), out|
34
+ out[urgency] ||= []
35
+ out[urgency] << key
36
+ end
37
+ end
38
+
24
39
  private
25
40
 
26
41
  def self.flatten_keys(keys)
27
- keys.map { |key, subkeys| subkeys.map { |s| "#{key}.#{s}" } }.flatten
42
+ keys.map do |key, subkeys|
43
+ subkeys.map do |subkey, urgency|
44
+ { "#{key}.#{subkey}" => urgency }
45
+ end
46
+ end.flatten.reduce({}, :merge)
28
47
  end
29
48
  end
30
49
  end
@@ -1,3 +1,3 @@
1
1
  module UNotifier
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/unotifier.rb CHANGED
@@ -100,9 +100,11 @@ module UNotifier
100
100
  def self.notification_settings_for(target)
101
101
  user_settings = target.notification_settings
102
102
  Settings
103
- .keys_from(notifications_config)
104
- .each_with_object({}) do |key, settings|
105
- settings[key] = user_settings[key] || Settings::DEFAULT_URGENCY
103
+ .grouped_by_urgency_keys_from(notifications_config)
104
+ .each_with_object({}) do |(urgency, keys), settings|
105
+ settings[urgency] = keys.each_with_object({}) do |(key, _), out|
106
+ out[key] = user_settings[key] || Settings::DEFAULT_URGENCY
107
+ end
106
108
  end
107
109
  end
108
110
 
data/unotifier.gemspec CHANGED
@@ -10,12 +10,12 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["stillintop@gmail.com"]
11
11
 
12
12
  spec.summary = "Ultimate user notification tool for web apps"
13
- spec.homepage = "https://github.com/mgpnd/unotifier"
13
+ spec.homepage = "https://gitlab.com/hodlhodl/unotifier"
14
14
  spec.license = "MIT"
15
15
 
16
16
  if spec.respond_to?(:metadata)
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["sourc_code_uri"] = "https://github.com/mgpnd/unotifier"
18
+ spec.metadata["sourc_code_uri"] = "https://gitlab.com/hodlhodl/unotifier"
19
19
  else
20
20
  raise "RubyGems 2.0 or newer is required to protect against " \
21
21
  "public gem pushes."
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  # Specify which files should be added to the gem when it is released.
25
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(%r{^(\.rspec|\.travis\.yml)}) }
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(%r{^\.rspec}) }
28
28
  end
29
29
  spec.bindir = "bin"
30
30
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
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.2.1
4
+ version: 0.2.2
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-29 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,12 +124,12 @@ files:
124
124
  - lib/unotifier.rb
125
125
  - lib/unotifier/version.rb
126
126
  - unotifier.gemspec
127
- homepage: https://github.com/mgpnd/unotifier
127
+ homepage: https://gitlab.com/hodlhodl/unotifier
128
128
  licenses:
129
129
  - MIT
130
130
  metadata:
131
- homepage_uri: https://github.com/mgpnd/unotifier
132
- sourc_code_uri: https://github.com/mgpnd/unotifier
131
+ homepage_uri: https://gitlab.com/hodlhodl/unotifier
132
+ sourc_code_uri: https://gitlab.com/hodlhodl/unotifier
133
133
  post_install_message:
134
134
  rdoc_options: []
135
135
  require_paths: