jobly 0.4.1 → 0.4.2

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: 1dfd28e13f7a8721263780b81e03fd6906dbca241723f9cf69077022d98c0558
4
- data.tar.gz: 1634628adb87ba6674e368a154a9c1a87db89ee8ba1c11dae5a5fbb185a5ebd6
3
+ metadata.gz: 1cf3d3077df95fb824e2012b4d381f262ebfce21968c08ded075240ae8861856
4
+ data.tar.gz: 89dc7fcfef708b922c8a3297dce7c4be2c7948b6c5f5ffcf7a8a666286837695
5
5
  SHA512:
6
- metadata.gz: 01ed0fe3c87cab6f2b29033bc01e49ab33e15222760e3acc61bcfecf7ea85e0787d4e360e95b339ce3f5ca5c3ea84f4ca69a1ed47d14cad3124fc895a61a9ec3
7
- data.tar.gz: 82d84d080205679692ea3e7310b89fc1262b5a55e3011bd253c9d8740bedbe224a3e22ff685a2d60b7da9d89da9c6f632392b3dcedc8ad38b0c6c8c45f44ea71
6
+ metadata.gz: e44878130cb1cc5ebd8d4ff044bc3d73a9435fb49fb52eee1074e893460e07a621d43f382501be1b63d9aa9d9df897ffee3d88030c058db9f88c6ac266829864
7
+ data.tar.gz: 401daa2e8a8d6277452e62a9d2964b48155564006a2aff7752c3fef8a36200ec48678bd94fc78377c8a3d8df1005645b80cde4c30d5a016b7fe7765cec730663
data/README.md CHANGED
@@ -27,7 +27,7 @@ Installation
27
27
 
28
28
  $ gem install jobly
29
29
 
30
- Or with the official [Jobly docker image][2].
30
+ Or with the official [Jobly docker image][docker].
31
31
 
32
32
 
33
33
  What's in the Box
@@ -47,10 +47,19 @@ sidekiq backgronud jobs system. It includes the following components:
47
47
  Documentation
48
48
  --------------------------------------------------
49
49
 
50
- - Visit the [Jobly documentation][1].
51
- - Visit the [interactive demo on Katacoda][3].
50
+ - Visit the [Jobly documentation][docs].
51
+ - Visit the [interactive demo on Katacoda][katacoda].
52
52
 
53
53
 
54
- [1]: https://jobly.dannyb.co
55
- [2]: https://github.com/dannyben/docker-jobly
56
- [3]: https://www.katacoda.com/dannyb/scenarios/jobly
54
+ Contributing / Support
55
+ --------------------------------------------------
56
+
57
+ If you experience any issue, have a question or a suggestion, or if you wish
58
+ to contribute, feel free to [open an issue][issues].
59
+
60
+ ---
61
+
62
+ [docs]: https://jobly.dannyb.co
63
+ [docker]: https://github.com/dannyben/docker-jobly
64
+ [katacoda]: https://www.katacoda.com/dannyb/scenarios/jobly
65
+ [issues]: https://github.com/DannyBen/jobly/issues
data/bin/jobly CHANGED
@@ -1,18 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'colsole'
3
+ require 'pretty_trace/enable-trim'
3
4
  include Colsole
4
5
 
5
- begin
6
- require 'jobly'
7
- require 'jobly/boot'
6
+ require 'jobly'
7
+ require 'jobly/boot'
8
8
 
9
- router = Jobly::CLI.router
9
+ PrettyTrace.filter [
10
+ %r[commands/run],
11
+ %r[mister_bin],
12
+ %r[bin/jobly],
13
+ %r[bin/ruby],
14
+ ]
10
15
 
11
- exit router.run ARGV
12
-
13
- rescue => e
14
- puts e.backtrace.reverse if ENV['DEBUG']
15
- say! "!txtred!#{e.class}: #{e.message}"
16
- say! "Run with !txtpur!DEBUG=1!txtrst! for backtrace details" unless ENV['DEBUG']
17
- exit 1
18
- end
16
+ router = Jobly::CLI.router
17
+ exit router.run ARGV
data/lib/jobly.rb CHANGED
@@ -5,8 +5,10 @@ requires 'jobly/polyfills'
5
5
  requires 'jobly/extensions'
6
6
  requires 'jobly/refinements'
7
7
  requires 'jobly/job_extensions'
8
+ requires 'jobly/helpers'
9
+
10
+ require 'jobly/helpers'
8
11
  require 'jobly/exceptions'
9
- require 'jobly/logging'
10
12
  require 'jobly/log'
11
13
  require 'jobly/sidekiq'
12
14
  require 'jobly/module_functions'
@@ -0,0 +1,15 @@
1
+ module Jobly
2
+ # This module includes all the modules that are needed for a Jobly::Job
3
+ # It may also be included by the user, in a non-job context (for example,
4
+ # in code inside the ./app folder).
5
+ module Helpers
6
+ def self.included(klass)
7
+ klass.class_eval do
8
+ include Logging
9
+ include Settings
10
+ include Shell
11
+ include Slack
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ Note that although these files are in a separate folder, the modules they
2
+ define are **using the main `Jobly` namespace** - so caution is required
3
+ when adding additional files.
4
+
5
+ This is done on purpose, since these modules may also be included by the
6
+ user, and we would like the users to have a simple `include Jobly::Slack`
7
+ rather than `include Jobly::Helpers::Slack`.
8
+
File without changes
@@ -0,0 +1,24 @@
1
+ require 'sting'
2
+
3
+ module Jobly
4
+ module Settings
5
+ def settings
6
+ @settings ||= settings!
7
+ end
8
+
9
+ def settings!
10
+ settings = Sting.new
11
+
12
+ files = [
13
+ "#{Jobly.full_config_path}/settings",
14
+ "#{Jobly.full_config_path}/settings.#{Jobly.environment}"
15
+ ]
16
+
17
+ files.each do |file|
18
+ settings << file if File.exist? "#{file}.yml"
19
+ end
20
+
21
+ settings
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'tty-command'
2
+
3
+ module Jobly
4
+ module Shell
5
+ def shell
6
+ @shell ||= TTY::Command.new(output: logger, color: false)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,43 @@
1
+ require 'slack-notifier'
2
+
3
+ module Jobly
4
+ module Slack
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def slack_channel(channel = nil)
11
+ if channel
12
+ @slack_channel = channel
13
+ else
14
+ @slack_channel ||= Jobly.slack_channel
15
+ end
16
+ end
17
+
18
+ def slack_user(user = nil)
19
+ if user
20
+ @slack_user = user
21
+ else
22
+ @slack_user ||= Jobly.slack_user
23
+ end
24
+ end
25
+ end
26
+
27
+ def slack
28
+ @slack ||= slack!
29
+ end
30
+
31
+ private
32
+
33
+ def slack!
34
+ raise ArgumentError, "Slack webhook is not set" unless Jobly.slack_webhook
35
+ opts = {
36
+ channel: self.class.slack_channel,
37
+ username: self.class.slack_user
38
+ }
39
+ ::Slack::Notifier.new Jobly.slack_webhook, opts
40
+ end
41
+
42
+ end
43
+ end
data/lib/jobly/job.rb CHANGED
@@ -2,12 +2,13 @@ module Jobly
2
2
  class Job
3
3
  include Sidekiq::Worker
4
4
  include Sidekiq::Status::Worker
5
- include Jobly::Logging # must come after Sidekiq::Worker
6
5
  include JobExtensions::OptionAccessors
7
6
  include JobExtensions::Actions
8
7
  include JobExtensions::Solo
9
- include JobExtensions::Slack
10
- include JobExtensions::Shell
8
+
9
+ # Helpers must come after Sidekiq::Worker since they both bring logger
10
+ # and our logger is the king of loggers
11
+ include Helpers
11
12
 
12
13
  using KeywordArgs
13
14
  using ToSlug
@@ -0,0 +1,13 @@
1
+ class OtherClass
2
+ # If you have classes that do not inherit from Jobly::Job you can still
3
+ # gain access to the helpers by including them.
4
+
5
+ # Include all helpers
6
+ include Jobly::Helpers
7
+
8
+ # Or, include only what you need
9
+ # include Jobly::Logging
10
+ # include Jobly::Slack
11
+ # include Jobly::Shell
12
+ # include Jobly::Settings
13
+ end
data/lib/jobly/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jobly
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,57 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-24 00:00:00.000000000 Z
11
+ date: 2019-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mister_bin
14
+ name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colsole
28
+ name: pretty_trace
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.5'
41
- - !ruby/object:Gem::Dependency
42
- name: http
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
33
+ version: '0.2'
34
+ - - ">="
46
35
  - !ruby/object:Gem::Version
47
- version: '4.0'
36
+ version: 0.2.3
48
37
  type: :runtime
49
38
  prerelease: false
50
39
  version_requirements: !ruby/object:Gem::Requirement
51
40
  requirements:
52
41
  - - "~>"
53
42
  - !ruby/object:Gem::Version
54
- version: '4.0'
43
+ version: '0.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.3
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: puma
57
49
  requirement: !ruby/object:Gem::Requirement
@@ -164,34 +156,76 @@ dependencies:
164
156
  - - "~>"
165
157
  - !ruby/object:Gem::Version
166
158
  version: '2.0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: slack-notifier
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '2.3'
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '2.3'
173
+ - !ruby/object:Gem::Dependency
174
+ name: sting
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.3'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '0.3'
167
187
  - !ruby/object:Gem::Dependency
168
188
  name: tty-command
169
189
  requirement: !ruby/object:Gem::Requirement
170
190
  requirements:
171
191
  - - "~>"
172
192
  - !ruby/object:Gem::Version
173
- version: '0.8'
193
+ version: '0.9'
174
194
  type: :runtime
175
195
  prerelease: false
176
196
  version_requirements: !ruby/object:Gem::Requirement
177
197
  requirements:
178
198
  - - "~>"
179
199
  - !ruby/object:Gem::Version
180
- version: '0.8'
200
+ version: '0.9'
181
201
  - !ruby/object:Gem::Dependency
182
- name: slack-notifier
202
+ name: colsole
183
203
  requirement: !ruby/object:Gem::Requirement
184
204
  requirements:
185
205
  - - "~>"
186
206
  - !ruby/object:Gem::Version
187
- version: '2.3'
207
+ version: '0.6'
188
208
  type: :runtime
189
209
  prerelease: false
190
210
  version_requirements: !ruby/object:Gem::Requirement
191
211
  requirements:
192
212
  - - "~>"
193
213
  - !ruby/object:Gem::Version
194
- version: '2.3'
214
+ version: '0.6'
215
+ - !ruby/object:Gem::Dependency
216
+ name: mister_bin
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - "~>"
220
+ - !ruby/object:Gem::Version
221
+ version: '0.7'
222
+ type: :runtime
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - "~>"
227
+ - !ruby/object:Gem::Version
228
+ version: '0.7'
195
229
  description: Execute background jobs and build tasks on this sidekiq-based job server
196
230
  email: db@dannyben.com
197
231
  executables:
@@ -215,15 +249,18 @@ files:
215
249
  - lib/jobly/config.ru
216
250
  - lib/jobly/exceptions.rb
217
251
  - lib/jobly/extensions/integer.rb
252
+ - lib/jobly/helpers.rb
253
+ - lib/jobly/helpers/README.md
254
+ - lib/jobly/helpers/logging.rb
255
+ - lib/jobly/helpers/settings.rb
256
+ - lib/jobly/helpers/shell.rb
257
+ - lib/jobly/helpers/slack.rb
218
258
  - lib/jobly/job.rb
219
259
  - lib/jobly/job_extensions/actions.rb
220
260
  - lib/jobly/job_extensions/option_accessors.rb
221
- - lib/jobly/job_extensions/shell.rb
222
- - lib/jobly/job_extensions/slack.rb
223
261
  - lib/jobly/job_extensions/solo.rb
224
262
  - lib/jobly/jobs.rb
225
263
  - lib/jobly/log.rb
226
- - lib/jobly/logging.rb
227
264
  - lib/jobly/module_functions.rb
228
265
  - lib/jobly/polyfills/hash.rb
229
266
  - lib/jobly/refinements/argument_converters.rb
@@ -235,6 +272,7 @@ files:
235
272
  - lib/jobly/templates/full/Gemfile
236
273
  - lib/jobly/templates/full/Procfile
237
274
  - lib/jobly/templates/full/app/job.rb
275
+ - lib/jobly/templates/full/app/other_class.rb
238
276
  - lib/jobly/templates/full/config/jobly.rb
239
277
  - lib/jobly/templates/full/envrc.example
240
278
  - lib/jobly/templates/full/jobs/hello.rb
@@ -1,11 +0,0 @@
1
- require 'tty-command'
2
-
3
- module Jobly
4
- module JobExtensions
5
- module Shell
6
- def shell
7
- @shell ||= TTY::Command.new(output: logger, color: false)
8
- end
9
- end
10
- end
11
- end
@@ -1,45 +0,0 @@
1
- require 'slack-notifier'
2
-
3
- module Jobly
4
- module JobExtensions
5
- module Slack
6
- def self.included(base)
7
- base.extend ClassMethods
8
- end
9
-
10
- module ClassMethods
11
- def slack_channel(channel = nil)
12
- if channel
13
- @slack_channel = channel
14
- else
15
- @slack_channel ||= Jobly.slack_channel
16
- end
17
- end
18
-
19
- def slack_user(user = nil)
20
- if user
21
- @slack_user = user
22
- else
23
- @slack_user ||= Jobly.slack_user
24
- end
25
- end
26
- end
27
-
28
- def slack
29
- @slack ||= slack!
30
- end
31
-
32
- private
33
-
34
- def slack!
35
- raise ArgumentError, "Slack webhook is not set" unless Jobly.slack_webhook
36
- opts = {
37
- channel: self.class.slack_channel,
38
- username: self.class.slack_user
39
- }
40
- ::Slack::Notifier.new Jobly.slack_webhook, opts
41
- end
42
-
43
- end
44
- end
45
- end