hey-you 1.3.4 → 1.4.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: af4fe24304e8d627f618c3cc5b6e93695a2be2f4d2207034f59feb0a7ad0d906
4
- data.tar.gz: b60aa9ec6a472bc008d57e472406cb00e49b2f3d5827a5a3119a494fc83cfcbb
3
+ metadata.gz: a02aef783a1b2fa450d1c420595f9c7df0a06eefa7a877c0e3e97fe072449f20
4
+ data.tar.gz: b4ff049fe645dab2263b0ffb2c947c537a3fcdde985b6a228e2daa455f4c38da
5
5
  SHA512:
6
- metadata.gz: d1cf816831a4962b2f795621585156447cb837256773f4663da7009e6d404be2488e017ab2d96944b205764416f5bd4ee3b6c4bf28c399fbe6463abdcbbe65df
7
- data.tar.gz: 165f7490a9a3eb749b2c966adf412a95027995bbcdb257c86b91c02484982ad56e48a99189157abcccf07cb88081bda0af3aa8673429c599ad336d14441a1709
6
+ metadata.gz: a1b41481fdc55fe9463a5e017dae21ec53cf490c04925bfd43d350f717acdb4a9a20eeb2908666f28ab8e3db02daef420a0edf6922c25779168bdbc58ba8a864
7
+ data.tar.gz: 650584118b560468f1c428e9e203eadd11571b3c5576b64dcc5e3322bfbcc237ab571ace0af62c079fc988278879aac332b812e2e6e82ceea680868670b6aab2
@@ -1,9 +1,12 @@
1
1
  # Changelog for hey-you gem
2
- ## 1.3.1/1.3.2/1.3.3/1.3.4
3
- Fixing bugs
4
2
 
5
- ## 1.3.0
3
+ # 1.4.0
4
+ - Improvement: configs validations for custom classes
5
+ - Improvement: allow custom classes with '_' in name
6
+
7
+ ## 1.3.0 - 1.3.4
6
8
  - Feature: `body_part` in email builder.
9
+ - Fixes
7
10
 
8
11
  ### 1.2.3
9
12
  - Improvement: fix ruby 2.7 warnings
@@ -37,8 +37,8 @@ module HeyYou
37
37
  return
38
38
  end
39
39
 
40
- ch_builder =
41
- HeyYou::Builder.const_get("#{ch.downcase.capitalize}").new(data[ch.to_s], key, **options)
40
+ klass_name = ch.to_s.downcase.split('_').map(&:capitalize).join
41
+ ch_builder = HeyYou::Builder.const_get(klass_name).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)
@@ -74,4 +74,4 @@ module HeyYou
74
74
  class DataNotFound < StandardError; end
75
75
  class RequiredChannelNotFound < StandardError; end
76
76
  end
77
- end
77
+ end
@@ -62,6 +62,13 @@ module HeyYou
62
62
  @registered_receivers << receiver_class
63
63
  end
64
64
 
65
+ def validate_config
66
+ registered_channels.each do |ch|
67
+ ch_config = send(ch)
68
+ ch_config.validate_config if ch_config.respond_to?(:validate_config)
69
+ end
70
+ end
71
+
65
72
  # Registrate new custom channel.
66
73
  # For successful registration, in application must be exists:
67
74
  # 1. HeyYou::Channels::<YOUR_CHANNEL_NAME> < HeyYou::Channels::Base
@@ -94,7 +101,8 @@ module HeyYou
94
101
  # For example, if ch == 'push' will define method #push for class instance.
95
102
  # New method will return instance of channel config instance
96
103
  def define_ch_config_method(ch)
97
- method_proc = -> { self.class.const_get(ch.capitalize).config }
104
+ klass_name = ch.to_s.split('_').map(&:capitalize).join
105
+ method_proc = -> { self.class.const_get(klass_name).config }
98
106
  self.class.send(:define_method, ch, method_proc)
99
107
  end
100
108
 
@@ -102,4 +110,4 @@ module HeyYou
102
110
  data_source.load_data
103
111
  end
104
112
  end
105
- end
113
+ end
@@ -13,6 +13,7 @@ module HeyYou
13
13
  def configure(&block)
14
14
  @configured ? raise(AlreadyConfiguredError, 'You already configure HeyYou') : instance_eval(&block)
15
15
  @configured = true
16
+ instance.validate_config if instance.respond_to?(:validate_config)
16
17
  end
17
18
 
18
19
  def config
@@ -20,6 +21,7 @@ module HeyYou
20
21
  end
21
22
 
22
23
  class AlreadyConfiguredError < StandardError; end
24
+ class RequiredConfigsNotPassed < StandardError; end
23
25
  end
24
26
  end
25
- end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module HeyYou
2
- VERSION = "1.3.4"
2
+ VERSION = "1.4.0"
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.3.4
4
+ version: 1.4.0
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-10-30 00:00:00.000000000 Z
11
+ date: 2020-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fcm