hey-you 1.2.2 → 1.2.3

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: 755f8775f2918592a3faf297f7dbed8f5b7253d137ac47ffedae9a9106a5d44f
4
- data.tar.gz: 17c927968d8fe27c6a5e8b2ace86af1bb30683f3cc968099aca19401c94cbcd7
3
+ metadata.gz: e45a6c6dcd683af58756e5bc3702ac92e0cd7e0f4fefb469f356002334f33fce
4
+ data.tar.gz: b8144f42b5cac765f8610ab05e046524e2ac9a4c5e47f08a7e6f4e7a409c309f
5
5
  SHA512:
6
- metadata.gz: 592e4f17b2e26f26f04477150118a91d2cf68696bc17f3021617e554a14bddb19fd3fec5e2c8d2dc37342d045e6ca2c2c679969de645aa9269edf6cc139ea596
7
- data.tar.gz: 83aa1a371cffa0efce33fb69e410abbe6d0eda85e019ab117f1e1ccb93cfee8d7ce92fb4b23d83a4b19d08615ccc0616c378ebd030801bc10b0773edb71e1596
6
+ metadata.gz: a96ab10f4b7dd0c0a07d6e16be547f2c97d2f51f7bf5be91386541fddde61f7739154d3867695ce7e814d6974b1377e4fa64e98239c4ab296ffff20dfe2602c8
7
+ data.tar.gz: e1cdb47a072bd632ea89ee6e072bc49afac86abaf570666ce92b2392b10787268552d1b599bdcb059da3488b7cc19c898b72dc3859730ab48514785291e44adf
@@ -1,6 +1,10 @@
1
1
  # Changelog for hey-you gem
2
2
 
3
- ## 1.2.2
3
+ ### 1.2.3
4
+ - Improvement: fix ruby 2.7 warnings
5
+ - Fix: fix `NoMethodError` in `sender.rb` when channel must be ignored by `if`
6
+
7
+ ### 1.2.2
4
8
  - Improvement: `if` condition for receiver (if condition `false` - sending will be skipped).
5
9
  - Improvement: `force` option - send message independent on `if` condition.
6
10
 
@@ -38,7 +38,7 @@ module HeyYou
38
38
  end
39
39
 
40
40
  ch_builder =
41
- HeyYou::Builder.const_get("#{ch.downcase.capitalize}").new(data[ch.to_s], key, options)
41
+ HeyYou::Builder.const_get("#{ch.downcase.capitalize}").new(data[ch.to_s], key, **options)
42
42
  instance_variable_set("@#{ch}".to_sym, ch_builder)
43
43
 
44
44
  define_ch_method(ch)
@@ -7,13 +7,13 @@ module HeyYou
7
7
  class << self
8
8
  def send!(builder, to:, **options)
9
9
  method = config.email.use_default_mailing ? :send_via_mail : :send_via_custom_class
10
- public_send(method, builder, to, options)
10
+ public_send(method, builder, to, **options)
11
11
  end
12
12
 
13
13
  # Send email via custom class instance.
14
14
  def send_via_custom_class(builder, to, **options)
15
- mailer = mailer_class_from_builder(builder, options)
16
- mailer_method = mailer_method_from_builder(mailer, builder, options)
15
+ mailer = mailer_class_from_builder(builder, **options)
16
+ mailer_method = mailer_method_from_builder(mailer, builder, **options)
17
17
  delivery_method = options[:delivery_method] ||
18
18
  builder.email.delivery_method ||
19
19
  config.email.default_delivery_method
@@ -22,7 +22,7 @@ module HeyYou
22
22
  raise InvalidDataSourceError, 'You must pass `config.data_source.source_class` in configuration.'
23
23
  end
24
24
 
25
- source_class.new(options).load_collections
25
+ source_class.new(**options).load_collections
26
26
  rescue ArgumentError => err
27
27
  problem_fields =
28
28
  err.message.gsub(/missing keyword(.?):\s/, '').split(', ').map { |f| "`#{f}`" }.join(', ')
@@ -42,14 +42,14 @@ module HeyYou
42
42
  }
43
43
  end
44
44
 
45
- send_to_receive_info(notification_key, to_hash, options)
45
+ send_to_receive_info(notification_key, to_hash, **options)
46
46
  end
47
47
 
48
48
  def send_to_receive_info(notification_key, receive_info, **options)
49
- builder = Builder.new(notification_key, options)
49
+ builder = Builder.new(notification_key, **options)
50
50
  response = {}
51
51
  config.registered_channels.each do |ch|
52
- if channel_allowed?(ch, receive_info, builder, options) && builder.respond_to?(ch) && builder.public_send(ch)
52
+ if channel_allowed?(ch, receive_info, builder, **options) && builder.respond_to?(ch) && builder.public_send(ch)
53
53
  config.log(
54
54
  "Send #{ch}-message to `#{receive_info[ch][:subject]}` with data: #{builder.public_send(ch).data}" \
55
55
  " and options: #{receive_info[ch][:options]}"
@@ -68,7 +68,10 @@ module HeyYou
68
68
  private
69
69
 
70
70
  def channel_allowed?(ch, to, builder, **options)
71
- condition = to[ch].is_a?(Hash) ? to[ch.to_sym][:subject] || to[ch.to_s][:subject] : to[ch.to_sym] || to[ch.to_s]
71
+ data_in_subject = to[ch.to_sym]&.fetch(:subject, nil) || to[ch.to_s]&.fetch(:subject, nil)
72
+ data_in_core = to[ch.to_sym] || to[ch.to_s]
73
+
74
+ condition = to[ch].is_a?(Hash) ? data_in_subject : data_in_core
72
75
  return false unless condition
73
76
  channel_allowed_by_only?(ch, options[:only]) && !builder.send(ch).nil?
74
77
  end
@@ -1,3 +1,3 @@
1
1
  module HeyYou
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hey-you
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nesterov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-02 00:00:00.000000000 Z
11
+ date: 2020-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fcm
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubygems_version: 3.0.3
169
+ rubygems_version: 3.1.2
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Send multichannel notification with one command.