unotifier 0.2.3 → 0.2.10

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: b8d0d6e9fbcd78989dedfe9692b6995501e6dda0dccfc46c01e8a0d013a568d4
4
- data.tar.gz: bda785e4df5defce86a8741753825b5cfe2d0c8e0bfcdd1025fcb245892f74d9
3
+ metadata.gz: 5ec61a1237c2bdcf5f22b0f272805090d1a82f4e83dee871c3daa01bef627d5c
4
+ data.tar.gz: 8d0c39f00d10c01a8b452c2b1a29c7f995f144993e491102004f73f65488426e
5
5
  SHA512:
6
- metadata.gz: 82eaf6528bd654344a4927624d694a824f1e2832a0a251b5e760d8a3f38bcafdab6978c18405499a8994c78a7defbfda64986105d45e8843a33f3594edd31a4a
7
- data.tar.gz: 4f0d4e2f18c0d501334cc046fd501d4588e7dcf1578f44c5b8a11ae4232aeb89d14faf1381cf291e3eecd11798f293b6a17e1a2472498638a7391c1c9b7f0ed6
6
+ metadata.gz: 6d5bce4be79ee89ca014fdde94eb48ba55829dddefd86a8250d90e2c94ee244c49a70dcabf7fe8ff09b24d8e31c5cd92b2ef4dcb019fed6c4b8accbfda851f35
7
+ data.tar.gz: e087624c1ccfc08495ea06e2e8c53993c16f2c30f4fcfa017d51279da0f6f2a5bead5f7146d36c6543207edb1c41de155db8f3257d80498f1ac7643a22a8d07a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unotifier (0.2.3)
4
+ unotifier (0.2.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Artem Rashev
3
+ Copyright (c) 2018
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -35,8 +35,4 @@ To store your notifications in database UNotifier uses provided ActiveRecord mod
35
35
 
36
36
  ## Contributing
37
37
 
38
- Bug reports and pull requests are welcome on GitLab at https://gitlab.com/hodlhodl/unotifier.
39
-
40
- ## License
41
-
42
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/hodlhodl-public/unotifier.
data/lib/hash.rb ADDED
@@ -0,0 +1,6 @@
1
+ class ::Hash
2
+ def deep_merge!(second)
3
+ merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
4
+ self.merge!(second.to_h, &merger)
5
+ end
6
+ end
@@ -9,7 +9,12 @@ module UNotifier
9
9
 
10
10
  def notify(notification)
11
11
  return unless can_notify?(notification)
12
- @mailer.public_send(@sending_method, notification).deliver
12
+ sending_method = if @sending_method.kind_of?(Array)
13
+ @sending_method.map { |m| m.call(notification) }&.first
14
+ else
15
+ @sending_method
16
+ end
17
+ @mailer.public_send(sending_method, notification).deliver
13
18
  end
14
19
  end
15
20
  end
@@ -1,3 +1,3 @@
1
1
  module UNotifier
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.10"
3
3
  end
data/lib/unotifier.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "yaml"
2
2
 
3
+ require_relative "hash"
3
4
  require_relative "unotifier/version"
4
5
  require_relative "exceptions"
5
6
  require_relative "provider"
@@ -20,7 +21,13 @@ module UNotifier
20
21
  end
21
22
 
22
23
  def self.notifications_config
23
- @notifications_config ||= YAML.load_file(configuration.notifications_path)
24
+ @notifications_config ||= if configuration.notifications_path.kind_of?(Array)
25
+ configuration.notifications_path.each_with_object({}) do |path, config|
26
+ config.deep_merge!(YAML.load_file(path))
27
+ end
28
+ else
29
+ YAML.load_file(configuration.notifications_path)
30
+ end
24
31
  rescue Errno::ENOENT
25
32
  raise NotificationsConfigNotFoundError.new(configuration.notifications_path)
26
33
  end
@@ -75,8 +82,8 @@ module UNotifier
75
82
  notification = configuration.resource_class.new(
76
83
  key: key,
77
84
  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: "")),
85
+ title: configuration.localization_provider.t("#{locale_key}.title", params.merge(locale: target.locale)),
86
+ body: configuration.localization_provider.t("#{locale_key}.body", params.merge(locale: target.locale, default: "")),
80
87
  link: params[:link],
81
88
  autohide_delay: params[:autohide_delay],
82
89
  urgency: urgency
@@ -86,7 +93,13 @@ module UNotifier
86
93
  notify_with = []
87
94
  notify_with += configuration.site_providers if !params[:external_only] && notify_onsite?(notification, user_settings)
88
95
  notify_with += configuration.external_providers if !params[:onsite_only] && notify_external?(notification, user_settings)
89
- notify_with.each { |p| p.notify(notification) }
96
+ notify_with.each do |provider|
97
+ title_provider_key = "#{locale_key}.#{provider.class.to_s.split("::").last}.title"
98
+ body_provider_key = "#{locale_key}.#{provider.class.to_s.split("::").last}.body"
99
+ notification.title = configuration.localization_provider.t(title_provider_key, params.merge(locale: target.locale)) if configuration.localization_provider.exists?(title_provider_key)
100
+ notification.body = configuration.localization_provider.t(body_provider_key, params.merge(locale: target.locale, default: "")) if configuration.localization_provider.exists?(body_provider_key)
101
+ provider.notify(notification)
102
+ end
90
103
  end
91
104
 
92
105
  def self.notify_onsite(key, target, params)
data/unotifier.gemspec CHANGED
@@ -6,16 +6,18 @@ require "unotifier/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "unotifier"
8
8
  spec.version = UNotifier::VERSION
9
- spec.authors = ["Artem Rashev"]
9
+ spec.authors = ["mgpnd"]
10
10
  spec.email = ["stillintop@gmail.com"]
11
11
 
12
12
  spec.summary = "Ultimate user notification tool for web apps"
13
- spec.homepage = "https://gitlab.com/hodlhodl/unotifier"
13
+ spec.homepage = "https://gitlab.com/hodlhodl-public/unotifier"
14
14
  spec.license = "MIT"
15
15
 
16
16
  if spec.respond_to?(:metadata)
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
17
19
  spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["sourc_code_uri"] = "https://gitlab.com/hodlhodl/unotifier"
20
+ spec.metadata["sourc_code_uri"] = "https://gitlab.com/hodlhodl-public/unotifier"
19
21
  else
20
22
  raise "RubyGems 2.0 or newer is required to protect against " \
21
23
  "public gem pushes."
@@ -23,17 +25,18 @@ Gem::Specification.new do |spec|
23
25
 
24
26
  # Specify which files should be added to the gem when it is released.
25
27
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
29
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(%r{^\.rspec}) }
28
30
  end
31
+
29
32
  spec.bindir = "bin"
30
33
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
34
  spec.require_paths = ["lib"]
32
35
 
33
36
  spec.add_development_dependency "bundler", "~> 1.17"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_development_dependency "pry"
37
37
  spec.add_development_dependency "byebug"
38
38
  spec.add_development_dependency "i18n"
39
+ spec.add_development_dependency "pry"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
39
42
  end
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.3
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
- - Artem Rashev
7
+ - mgpnd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-03 00:00:00.000000000 Z
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.17'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: i18n
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,33 +67,33 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: byebug
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '10.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '10.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: i18n
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '3.0'
97
97
  description:
98
98
  email:
99
99
  - stillintop@gmail.com
@@ -117,6 +117,7 @@ files:
117
117
  - bin/setup
118
118
  - lib/configuration.rb
119
119
  - lib/exceptions.rb
120
+ - lib/hash.rb
120
121
  - lib/provider.rb
121
122
  - lib/provider/action_cable.rb
122
123
  - lib/provider/action_mailer.rb
@@ -125,12 +126,13 @@ files:
125
126
  - lib/unotifier.rb
126
127
  - lib/unotifier/version.rb
127
128
  - unotifier.gemspec
128
- homepage: https://gitlab.com/hodlhodl/unotifier
129
+ homepage: https://gitlab.com/hodlhodl-public/unotifier
129
130
  licenses:
130
131
  - MIT
131
132
  metadata:
132
- homepage_uri: https://gitlab.com/hodlhodl/unotifier
133
- sourc_code_uri: https://gitlab.com/hodlhodl/unotifier
133
+ allowed_push_host: https://rubygems.org
134
+ homepage_uri: https://gitlab.com/hodlhodl-public/unotifier
135
+ sourc_code_uri: https://gitlab.com/hodlhodl-public/unotifier
134
136
  post_install_message:
135
137
  rdoc_options: []
136
138
  require_paths:
@@ -146,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
148
  - !ruby/object:Gem::Version
147
149
  version: '0'
148
150
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.7.8
151
+ rubygems_version: 3.0.3
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: Ultimate user notification tool for web apps