background_worker 0.3.0 → 0.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: 92739c3cd6034d467914e25cacf4a240e38c046b6e388cec4f9af9679b97d9a6
4
- data.tar.gz: 89f898f9989bcf29e5db58bf9bd23f189aa9e87702d145309c072a3a501ff2a1
3
+ metadata.gz: 6e2f1d5ad9dc6f2f79dfcd55838f8b7d9ded9c7518fc77f90ecea89fe537539c
4
+ data.tar.gz: 1e05a4e548ebdfea30e6bcf9ecc20dd7aaa3edc75966a2433f1f8ca016eb879c
5
5
  SHA512:
6
- metadata.gz: ce83fb384503d92765da69f1daec6f11eeff92fc8c9792ed5e4a8e770aa67224e0fd63ad7783d02b692ba38c75b7623785e2df22457ab58b5ae5fa8d4ca3b78b
7
- data.tar.gz: '091732c22801dc033d91957cba5a3d4a84776414ca4f09d5f09dd02205b8c54ef243d462f7e2092e3249554c4f58e6ff00996efaa1c6bf1a50794737fa5a00e0'
6
+ metadata.gz: c98bc9599be6db3a4a5f5dd6b8dc699a9209dcf6889553ae786ee7c780198d4af3c37198fdf486477f5a150288c1ab818632eeefb655bf7453c5372806ba4871
7
+ data.tar.gz: 19d317689204f81a81f782c6a8697087c13d5616341abd6258a0284249804fd216c389cf07e738993b522ec1346c517224a040531a574428233e0170502eb506
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_PATH: "vendor"
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -0,0 +1,59 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ name: Build
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ bundler-cache: true
18
+ - run: bundle exec rake
19
+
20
+ release:
21
+ needs: build
22
+ name: Release
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - name: Checkout
26
+ uses: actions/checkout@v2
27
+
28
+ - name: Generate Changelog
29
+ run: |
30
+ # Get version from github ref (remove 'refs/tags/' and prefix 'v')
31
+ version="${GITHUB_REF#refs/tags/v}"
32
+ npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
33
+
34
+ - name: Release
35
+ uses: softprops/action-gh-release@v1
36
+ with:
37
+ body_path: ${{ github.workflow }}-CHANGELOG.txt
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+
41
+ publish:
42
+ needs: [build, release]
43
+ name: Publish
44
+ runs-on: ubuntu-latest
45
+
46
+ steps:
47
+ - uses: actions/checkout@v2
48
+ - uses: ruby/setup-ruby@v1
49
+
50
+ - name: Publish to RubyGems
51
+ run: |
52
+ mkdir -p $HOME/.gem
53
+ touch $HOME/.gem/credentials
54
+ chmod 0600 $HOME/.gem/credentials
55
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
56
+ gem build *.gemspec
57
+ gem push *.gem
58
+ env:
59
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,19 @@
1
+ name: Build and Test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ gemfile: [rails60, rails61]
9
+ ruby: ["2.6", "2.7", "3.0"]
10
+ runs-on: ubuntu-latest
11
+ env:
12
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler-cache: true
19
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  Gemfile.lock
2
2
  coverage
3
+ vendor
4
+ tmp
@@ -1 +1 @@
1
- 2.6.5
1
+ 3.0.0
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
5
5
 
6
+ ## 0.4.0
7
+
8
+ - [TT-8623] Update to build with github actions / ruby 3.0 / rails 6.1
9
+
6
10
  ## 0.3.0
7
11
 
8
12
  - [TT-6292] Support Rails 5.2 built-in redis cache, remove legacy supports
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
- Background Worker
2
- =================
1
+ # Background Worker
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/background_worker.svg)](http://badge.fury.io/rb/background_worker)
4
+ [![Build Status](https://github.com/sealink/background_worker/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/background_worker/actions)
3
5
 
4
6
  Provides a worker abstraction with an additional status channel.
5
7
 
6
8
  Start by making a worker class which extends from BackgroundWorker::Base
7
9
 
10
+ ```ruby
8
11
  class MyWorker < BackgroundWorker::Base
9
12
  def my_task(options={})
10
13
  report_progress('Starting')
@@ -17,22 +20,27 @@ Start by making a worker class which extends from BackgroundWorker::Base
17
20
  {original_message: message}
18
21
  end
19
22
  end
23
+ ```
20
24
 
21
25
  Then, when you want to perform a task in the background, use
22
26
  klass#perform_in_background which exists in Base:
23
27
 
28
+ ```ruby
24
29
  worker_id = MyWorker.perform_in_background(:my_task, message: "hello!")
30
+ ```
25
31
 
26
32
  # Backgrounded
27
33
 
28
34
  By default this will call your instance method in the foreground -- you have to
29
35
  provide an #enqueue_with configuration like so:
30
36
 
37
+ ```ruby
31
38
  BackgroundWorker.configure(
32
39
  enqueue_with: -> klass, method_name, options {
33
40
  Resque.enqueue(klass, method_name, options)
34
41
  }
35
42
  )
43
+ ```
36
44
 
37
45
  This is independent of the status reporting which (currently) always uses Redis.
38
46
 
@@ -41,23 +49,40 @@ This is independent of the status reporting which (currently) always uses Redis.
41
49
  The worker_id you are returned can be used to get the status and
42
50
  whether the worker has finished successfully, failed, or is still in progress:
43
51
 
52
+ ```ruby
44
53
  state = BackgroundWorker.get_state_of(worker_id)
54
+ ```
45
55
 
46
56
  The state is represented by a hash with the following keys:
47
57
 
48
- message: Reported message
49
- detailed_message: Detailed version of above when provided
50
- status: :successful, :failed, or null if still processing
51
- completed: True if report_failed, report_successful called (or worker
52
- finished without exception -- which calls report_successful)
53
- data: Arbitrary data returned by worker method on success or report_failed
58
+ | key | description |
59
+ | ------------------------------------------------------------ | -------------------------------------------------------------------- |
60
+ | message | Reported message |
61
+ | detailed_message | Detailed version of above when provided |
62
+ | status | :successful, :failed, or null if still processing |
63
+ | completed | True if report_failed, report_successful called (or worker |
64
+ | finished without exception -- which calls report_successful) |
65
+ | data | Arbitrary data returned by worker method on success or report_failed |
54
66
 
55
67
  If an exception is raised, the worker will call #report_failed with the
56
68
  details. You can provide a callback with #after_exception in the config.
57
69
 
58
- # INSTALLATION
70
+ # Installation
59
71
 
60
72
  Add to your Gemfile:
61
73
 
74
+ ```ruby
62
75
  gem 'background_worker'
76
+ ```
77
+
78
+ # Release
79
+
80
+ To publish a new version of this gem the following steps must be taken.
63
81
 
82
+ - Update the version in the following files
83
+ ```
84
+ CHANGELOG.md
85
+ lib/background_worker/version.rb
86
+ ```
87
+ - Create a tag using the format v0.1.0
88
+ - Follow build progress in GitHub actions
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
20
20
  spec.test_files = spec.files.grep(/^(test|spec|features)\//)
21
21
  spec.require_paths = ['lib']
22
+ spec.required_ruby_version = '>= 2.6'
22
23
 
23
24
  spec.add_development_dependency 'activesupport'
24
25
  spec.add_development_dependency 'bundler'
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec path: '../'
5
+
6
+ group :development, :test do
7
+ gem 'activerecord', '~> 6.0'
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec path: '../'
5
+
6
+ group :development, :test do
7
+ gem 'activerecord', '~> 6.1'
8
+ end
@@ -1,3 +1,3 @@
1
1
  module BackgroundWorker
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: background_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-11-20 00:00:00.000000000 Z
13
+ date: 2021-01-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -161,17 +161,21 @@ executables: []
161
161
  extensions: []
162
162
  extra_rdoc_files: []
163
163
  files:
164
+ - ".bundle/config"
165
+ - ".github/dependabot.yml"
166
+ - ".github/workflows/release.yml"
167
+ - ".github/workflows/ruby.yml"
164
168
  - ".gitignore"
165
169
  - ".rubocop.yml"
166
170
  - ".ruby-version"
167
- - ".travis.yml"
168
171
  - CHANGELOG.md
169
172
  - Gemfile
170
173
  - LICENSE.txt
171
174
  - README.md
172
175
  - Rakefile
173
176
  - background_worker.gemspec
174
- - gemfiles/rails5_2.gemfile
177
+ - gemfiles/rails60.gemfile
178
+ - gemfiles/rails61.gemfile
175
179
  - lib/background_worker.rb
176
180
  - lib/background_worker/base.rb
177
181
  - lib/background_worker/config.rb
@@ -196,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
200
  requirements:
197
201
  - - ">="
198
202
  - !ruby/object:Gem::Version
199
- version: '0'
203
+ version: '2.6'
200
204
  required_rubygems_version: !ruby/object:Gem::Requirement
201
205
  requirements:
202
206
  - - ">="
203
207
  - !ruby/object:Gem::Version
204
208
  version: '0'
205
209
  requirements: []
206
- rubygems_version: 3.0.3
210
+ rubygems_version: 3.2.3
207
211
  signing_key:
208
212
  specification_version: 4
209
213
  summary: Background worker abstraction with status updates
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6.5
4
- script: bundle exec rake spec
5
- gemfile:
6
- - gemfiles/rails5_2.gemfile
7
- notifications:
8
- email:
9
- - support@travellink.com.au
10
- sudo: false
11
- cache: bundler
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec :path => '../'
3
-
4
- group :development, :test do
5
- gem 'activerecord', '~> 5.2.0'
6
- end