app_status_notification 0.9.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +69 -0
  4. data/Gemfile +18 -0
  5. data/Gemfile.lock +112 -0
  6. data/LICENSE +21 -0
  7. data/README.md +22 -0
  8. data/app_status_notification.gemspec +46 -0
  9. data/config/locales/en.yml +10 -0
  10. data/config/locales/zh.yml +54 -0
  11. data/config/notification.yml +30 -0
  12. data/exe/app_status_notification +5 -0
  13. data/lib/app_status_notification.rb +24 -0
  14. data/lib/app_status_notification/command.rb +64 -0
  15. data/lib/app_status_notification/config.rb +234 -0
  16. data/lib/app_status_notification/connect_api.rb +92 -0
  17. data/lib/app_status_notification/connect_api/auth.rb +44 -0
  18. data/lib/app_status_notification/connect_api/clients/app.rb +46 -0
  19. data/lib/app_status_notification/connect_api/clients/app_store_version.rb +28 -0
  20. data/lib/app_status_notification/connect_api/clients/build.rb +29 -0
  21. data/lib/app_status_notification/connect_api/model.rb +152 -0
  22. data/lib/app_status_notification/connect_api/models/app.rb +27 -0
  23. data/lib/app_status_notification/connect_api/models/app_store_version.rb +84 -0
  24. data/lib/app_status_notification/connect_api/models/app_store_version_submission.rb +15 -0
  25. data/lib/app_status_notification/connect_api/models/build.rb +30 -0
  26. data/lib/app_status_notification/connect_api/models/pre_release_version.rb +16 -0
  27. data/lib/app_status_notification/connect_api/response.rb +102 -0
  28. data/lib/app_status_notification/error.rb +38 -0
  29. data/lib/app_status_notification/helper.rb +16 -0
  30. data/lib/app_status_notification/notification.rb +57 -0
  31. data/lib/app_status_notification/notifications/adapter.rb +25 -0
  32. data/lib/app_status_notification/notifications/dingtalk.rb +59 -0
  33. data/lib/app_status_notification/notifications/slack.rb +62 -0
  34. data/lib/app_status_notification/notifications/wecom.rb +48 -0
  35. data/lib/app_status_notification/runner.rb +409 -0
  36. data/lib/app_status_notification/store.rb +68 -0
  37. data/lib/app_status_notification/version.rb +5 -0
  38. data/lib/app_status_notification/watchman.rb +42 -0
  39. metadata +283 -0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/cache'
4
+ require 'forwardable'
5
+
6
+ module AppStatusNotification
7
+ class Store
8
+ extend Forwardable
9
+
10
+ ALLOWED_KEYS = %i[version status latest_build selected_build unselected_build]
11
+
12
+ def_delegators :@cache, :read, :write, :delete, :clear
13
+
14
+ attr_reader :app_id
15
+
16
+ def initialize(app_id, path)
17
+ @cache = ActiveSupport::Cache::FileStore.new(File.join(path, app_id.to_s))
18
+
19
+ configure!
20
+ end
21
+
22
+ def fetch(key, default_value)
23
+ @cache.fetch(key, force: true) { default_value }
24
+ end
25
+
26
+ def [](key)
27
+ @cache.read(key)
28
+ end
29
+
30
+ def []=(key, value)
31
+ @cache.write(key, value)
32
+ end
33
+
34
+ def to_h
35
+ ALLOWED_KEYS.each_with_object({}) do |key, obj|
36
+ obj[key] = @cache.read(key)
37
+ end
38
+ end
39
+
40
+ def method_missing(method_name, *kwargs)
41
+ allowed, key, write_mode = allowed_key?(method_name)
42
+ super unless allowed
43
+
44
+ write_mode ? @cache.write(key, kwargs.first) : @cache.read(key)
45
+ end
46
+
47
+ def respond_to_missing?(method_name, include_private = false)
48
+ allowed, _ = allowed_key?(method_name)
49
+ allowed || super
50
+ end
51
+
52
+ def configure!
53
+ ALLOWED_KEYS.each do |key|
54
+ @cache.fetch(key, nil)
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def allowed_key?(key)
61
+ key = key.to_s
62
+ write_mode = key.end_with?('=')
63
+ key = key[0..-2] if write_mode
64
+ key = key.to_sym
65
+ [ALLOWED_KEYS.include?(key), key, write_mode]
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStatusNotification
4
+ VERSION = '0.9.0.beta1'
5
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'app_status_notification/runner'
4
+
5
+ module AppStatusNotification
6
+ class Watchman
7
+ include AppStatusNotification::I18nHelper
8
+
9
+ def self.run(config_path = nil)
10
+ Anyway::Settings.default_config_path = config_path if Dir.exist?(config_file)
11
+
12
+ config = Config.new
13
+ yield config if block_given?
14
+
15
+ Watchman.new(config).run
16
+ end
17
+
18
+ attr_reader :config, :client, :logger
19
+
20
+ def initialize(config)
21
+ @config = config
22
+ configure_logger
23
+ end
24
+
25
+ def run
26
+ @logger.info t('logger.setup_accounts', numbers: config.accounts.size)
27
+ config.accounts.each do |account|
28
+ @logger.info t('logger.setup_apps', issuer_id: account.issuer_id, apps: account.apps.size)
29
+ account.apps.each do |app|
30
+ context = AppStatusNotification::Runner::Context.new(account, app, config)
31
+ Runner.new(context).start
32
+ end
33
+ end
34
+ end
35
+
36
+ def configure_logger
37
+ @logger ||= config.logger
38
+ @logger.info t('logger.current_env', name: config.env, version: AppStatusNotification::VERSION)
39
+ @logger.debug config
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,283 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: app_status_notification
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - icyleaf
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: jwt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ - - "<="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.2.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '1.4'
58
+ - - "<="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.2.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: anyway_config
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.0.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: activesupport
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 6.0.3.1
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 6.0.3.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: gli
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 2.20.0
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 2.20.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: i18n
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.5
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.8.5
117
+ - !ruby/object:Gem::Dependency
118
+ name: sentry-raven
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: awesome_print
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 2.0.0.pre2
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 2.0.0.pre2
145
+ - !ruby/object:Gem::Dependency
146
+ name: bundler
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '2.1'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '2.1'
159
+ - !ruby/object:Gem::Dependency
160
+ name: pry-byebug
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: 3.9.0
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: 3.9.0
173
+ - !ruby/object:Gem::Dependency
174
+ name: rake
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '13.0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '13.0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: rspec
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '3.10'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: '3.10'
201
+ - !ruby/object:Gem::Dependency
202
+ name: rubocop
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: 1.1.0
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: 1.1.0
215
+ description:
216
+ email:
217
+ - icyleaf.cn@gmail.com
218
+ executables:
219
+ - app_status_notification
220
+ extensions: []
221
+ extra_rdoc_files: []
222
+ files:
223
+ - ".gitignore"
224
+ - ".rubocop.yml"
225
+ - Gemfile
226
+ - Gemfile.lock
227
+ - LICENSE
228
+ - README.md
229
+ - app_status_notification.gemspec
230
+ - config/locales/en.yml
231
+ - config/locales/zh.yml
232
+ - config/notification.yml
233
+ - exe/app_status_notification
234
+ - lib/app_status_notification.rb
235
+ - lib/app_status_notification/command.rb
236
+ - lib/app_status_notification/config.rb
237
+ - lib/app_status_notification/connect_api.rb
238
+ - lib/app_status_notification/connect_api/auth.rb
239
+ - lib/app_status_notification/connect_api/clients/app.rb
240
+ - lib/app_status_notification/connect_api/clients/app_store_version.rb
241
+ - lib/app_status_notification/connect_api/clients/build.rb
242
+ - lib/app_status_notification/connect_api/model.rb
243
+ - lib/app_status_notification/connect_api/models/app.rb
244
+ - lib/app_status_notification/connect_api/models/app_store_version.rb
245
+ - lib/app_status_notification/connect_api/models/app_store_version_submission.rb
246
+ - lib/app_status_notification/connect_api/models/build.rb
247
+ - lib/app_status_notification/connect_api/models/pre_release_version.rb
248
+ - lib/app_status_notification/connect_api/response.rb
249
+ - lib/app_status_notification/error.rb
250
+ - lib/app_status_notification/helper.rb
251
+ - lib/app_status_notification/notification.rb
252
+ - lib/app_status_notification/notifications/adapter.rb
253
+ - lib/app_status_notification/notifications/dingtalk.rb
254
+ - lib/app_status_notification/notifications/slack.rb
255
+ - lib/app_status_notification/notifications/wecom.rb
256
+ - lib/app_status_notification/runner.rb
257
+ - lib/app_status_notification/store.rb
258
+ - lib/app_status_notification/version.rb
259
+ - lib/app_status_notification/watchman.rb
260
+ homepage: https://github.com/icyleaf/app_status_notification
261
+ licenses:
262
+ - MIT
263
+ metadata: {}
264
+ post_install_message:
265
+ rdoc_options: []
266
+ require_paths:
267
+ - lib
268
+ required_ruby_version: !ruby/object:Gem::Requirement
269
+ requirements:
270
+ - - ">="
271
+ - !ruby/object:Gem::Version
272
+ version: '0'
273
+ required_rubygems_version: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - ">"
276
+ - !ruby/object:Gem::Version
277
+ version: 1.3.1
278
+ requirements: []
279
+ rubygems_version: 3.1.4
280
+ signing_key:
281
+ specification_version: 4
282
+ summary: Get those App Store Connect notifications delivered directly to Slack.
283
+ test_files: []