active_model_jobs 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +3 -0
- data/.codeclimate.yml +3 -0
- data/.env +1 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +19 -0
- data/.ruby-version +1 -0
- data/.travis.yml +25 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +92 -0
- data/Rakefile +20 -0
- data/active_model_jobs.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/ruby-parse +29 -0
- data/bin/ruby-rewrite +29 -0
- data/bin/setup +7 -0
- data/bin/yard +29 -0
- data/bin/yardoc +29 -0
- data/bin/yri +29 -0
- data/lib/active_model/jobs/engine.rb +10 -0
- data/lib/active_model/jobs/performer.rb +71 -0
- data/lib/active_model/jobs/version.rb +7 -0
- data/lib/active_model/jobs.rb +45 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f45912ed69143a659a4f549b0324cb5e46a7d74b
|
4
|
+
data.tar.gz: bf47d5d940ff43438e7bad79db0dd948a821988c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c0f3e14db842962bda4b337a6e194d2a96671cd99e045b46cf2179ab8beb49b667f898da97e3d67b2a9ff24d67b3d0ab54e1d29cc3aa2d07d3b2f073643cff5
|
7
|
+
data.tar.gz: eeae0f59463f7496ff4440ed24b2b15052300143a245e46435a05bccc099fabd1aa52cf008725af96b50615065fa7732c7d5fd4a3d8ade2059d9a10135305fe6
|
data/.bundle/config
ADDED
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Exclude vendored and generated code from Rubocop
|
2
|
+
AllCops:
|
3
|
+
Exclude:
|
4
|
+
- vendor/**/*
|
5
|
+
- bin/*
|
6
|
+
- lib/active_model/jobs/version.rb
|
7
|
+
|
8
|
+
# Don't require documentation for mocks
|
9
|
+
Style/Documentation:
|
10
|
+
Exclude:
|
11
|
+
- spec/**/*
|
12
|
+
|
13
|
+
# Allow any kind of string literal
|
14
|
+
Style/StringLiterals:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- spec/**/*
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2
|
4
|
+
- 2.3
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
- 2.6
|
8
|
+
cache: bundler
|
9
|
+
before_script:
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
11
|
+
- chmod +x ./cc-test-reporter
|
12
|
+
- "./cc-test-reporter before-build"
|
13
|
+
after_script:
|
14
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
15
|
+
deploy:
|
16
|
+
provider: rubygems
|
17
|
+
api_key:
|
18
|
+
secure: JQWmjd5/4zPBjt33e+ZF5+lmz7nsek6X6Q5Er06q/Qbaeak/uxCd/7hW8mP6mesh6p/OOBIYlRBOxN/GHf7/TWd+n5LrmCye18iyqGQlgwrB3ULoDqSh/GBBLp4u4zI6oBZJA3GoC5mDyDg5Mdf5ye0yVBhbfT3D9+VUyq53xrKI3B3pKztTgvZ/KzF4Gsb3UrN5R0E9Q4NZLrkIlApM517BXKnDTpk1DYZGe12FYZtgZMCkSPtiohZ5qizHDq6HK8ZgPPZ970QEu1jIFUs4luF0qKOCYhO9Yq9UWL1m+eRwa/s/j8Vyww9dPg2x9yReDWcIf0gZMKPBMgVQrnfT/YER5L0cee2XbxI6LdPwkvrx7EQwb5e2z/bzVr7IuiZrewWUTNaO7v9NnKSnS3smfbtu9gK5AYzf0X1z42vWCnCwJNYGAJd2sD1dw80zBtWf0YlonrRnXTUTdapSV3FAZBLFNHL9YNldZ9bjT3cPLhZv/ajk9eL7wOWGVRzghfUTYkTdIGQtH1nasVj99b9cuENj8HEJbnh7r8CgkpyuyZ5YjyZt+VCwCxeImPYv7uJbUlChFipdhC5NTvfIkcsDuXWWP+Va67MTchCnf+chCFD4oRLKuc9atkpSdawpvQ4T5tYiqa5nhscLm79bE2Md/VYqdgWo+JzbPOHq4MqAg4Q=
|
19
|
+
gem: active_model_jobs
|
20
|
+
on:
|
21
|
+
tags: true
|
22
|
+
repo: tubbo/active_model_jobs
|
23
|
+
env:
|
24
|
+
global:
|
25
|
+
secure: CP6t3YPR9xPYjbvKLpr+I0esOLdurqDeGCffWV0hga1CH+y3U6+S/+ui+F3APQKO9ct8XSZ6pYvZJVUow6o/VJ++e4hFadR3TbToWvjBv6EOUjnREQ6w78eS4JmhpXgSvrZB5SLFNZLUpXoJcxhVRTcA1qBR5oOc5PocuSMvOHGWK0znOqupp1K/46UEouBdwRmty8eKC2UgIxE/jyuBhnkyiUNiLUD13lbnQLnM25MikYd5sPmZPFDWRqwqvWD8j3ZPJjA/WH/+1fkhZbA7HPFCkBWn8lnSO/z8GzGwq/OeEFQvACdiCVBezC5ut0ais9ztIvZloAJL1Dk8AF5eSZLM0gXhhjV9ikWHq5EzM/FVK+haQhF09zRInEYjTEt3XERVmH6geE4qCPm/8sWH9K+sD6norPRoIwdI0cGIfmbzSQmWZXH3afJh3qn1iOuOqKh6F/LrEbmJSArs1FFfxbKjxppAqgi4drmdkgDbNTpEwfMlv9Q7V7ECrCgdXJyG9rVUEGGonWkuHSsDuwiJgEzSdp+KpWvasM5OP1/qBsUV8qqO9uRbh9OtOiMWlxk1j1c2j6oQfTQpPr27iQtD3QwDyhndFv0oY8ksgtDbfJwTCzJzeYtCH+A6Jtrb90PcJpGu6dDFl0B09jnR/8rT38Osnmti7Ghv1lpgJz3Fgvc=
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Tom Scott
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# ActiveModel::Jobs
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/tubbo/active_model_jobs.svg?branch=master)](https://travis-ci.org/tubbo/active_model_jobs)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/tubbo/active_model-jobs/badges/gpa.svg)](https://codeclimate.com/github/tubbo/active_model-jobs)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/tubbo/active_model-jobs/badges/coverage.svg)](https://codeclimate.com/github/tubbo/active_model-jobs/coverage)
|
6
|
+
[![Inline docs](http://inch-ci.org/github/tubbo/active_model-jobs.svg?branch=master)](http://inch-ci.org/github/tubbo/active_model-jobs)
|
7
|
+
|
8
|
+
A model-level interface for kicking off background jobs using ActiveJob.
|
9
|
+
Most useful inside a Rails application, it enables you to enqueue
|
10
|
+
ActiveJob jobs with a dynamically-generated instance method inside your
|
11
|
+
ActiveRecord (or ActiveModel-compatible) model class.
|
12
|
+
|
13
|
+
[Documentation](http://www.rubydoc.info/github/tubbo/active_model-jobs/master)
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'active_model-jobs'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ bundle
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
Given we already have a model called **Track**, generate a job
|
32
|
+
called `UploadTrackJob`:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'aws/s3'
|
36
|
+
|
37
|
+
class UploadTrackJob < ActiveRecord::Base
|
38
|
+
queue_as :default
|
39
|
+
|
40
|
+
def perform(track)
|
41
|
+
s3.put_object(track.file.data, track.file.attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def s3
|
47
|
+
AWS::S3.new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Now, you can kick off that job by calling its "action method" on your
|
53
|
+
model:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class Track < ActiveRecord::Base
|
57
|
+
attachment :file
|
58
|
+
|
59
|
+
after_create :upload!
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
Since this is just an instance method, you can call `track.upload!` to
|
64
|
+
kick off the job at any time outside of the callback lifecycle.
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
69
|
+
Then, run `bin/console` for an interactive prompt that will allow you
|
70
|
+
to experiment.
|
71
|
+
|
72
|
+
We follow a [semantic versioning](http://semver.org) guideline when
|
73
|
+
releasing new versions. Documentation updates do not get a new version,
|
74
|
+
it is just merged into 'master' and updated on http://rubydoc.info.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/tubbo/active_model-jobs/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
83
|
+
|
84
|
+
All contributions must be made in a pull request and include accompanying tests.
|
85
|
+
Pull requests will not be merged until they pass the CI build for all supported
|
86
|
+
Ruby and Rails versions. To install this gem onto your local machine, run
|
87
|
+
`bundle exec rake install`. To release a new version, update the version number
|
88
|
+
in `version.rb`, and then run `bundle exec rake release` to create a git
|
89
|
+
tag for the version, push git commits and tags, and push the `.gem` file
|
90
|
+
to [rubygems.org](https://rubygems.org).
|
91
|
+
|
92
|
+
Also see our [Code of Conduct](https://github.com/tubbo/active_model-jobs/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "rubocop/rake_task"
|
4
|
+
require "yard"
|
5
|
+
require "active_model/jobs"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new :test
|
8
|
+
|
9
|
+
RuboCop::RakeTask.new :lint
|
10
|
+
|
11
|
+
YARD::Rake::YardocTask.new :doc
|
12
|
+
|
13
|
+
desc "Create tag and push tags to GitHub"
|
14
|
+
task :release do
|
15
|
+
sh "git tag v#{ActiveModel::Jobs::VERSION}"
|
16
|
+
sh "git push --tags"
|
17
|
+
end
|
18
|
+
|
19
|
+
# CI task.
|
20
|
+
task default: :test
|
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'active_model/jobs/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "active_model_jobs"
|
7
|
+
spec.version = ActiveModel::Jobs::VERSION
|
8
|
+
spec.authors = ["Tom Scott"]
|
9
|
+
spec.email = ["tscott@weblinc.com"]
|
10
|
+
|
11
|
+
spec.summary = "Enqueue ActiveJobs in your ActiveModel."
|
12
|
+
spec.description = "#{spec.summary} Helps you call background jobs."
|
13
|
+
spec.homepage = "http://github.com/tubbo/active_model-jobs"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(spec)/})
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "rubocop", ">= 0.49.0"
|
28
|
+
spec.add_development_dependency "simplecov"
|
29
|
+
spec.add_development_dependency "yard", ">= 0.9.20"
|
30
|
+
|
31
|
+
spec.add_dependency "activejob", ">= 5.0.0"
|
32
|
+
spec.add_dependency "activemodel", ">= 5.0.0"
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "active_model/jobs"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/ruby-parse
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("parser", "ruby-parse")
|
data/bin/ruby-rewrite
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
data/bin/setup
ADDED
data/bin/yard
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yard' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yard")
|
data/bin/yardoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yardoc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yardoc")
|
data/bin/yri
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'yri' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("yard", "yri")
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module ActiveModel
|
2
|
+
module Jobs
|
3
|
+
# A support class for finding the +ActiveJob::Base+ that corresponds
|
4
|
+
# to a given action method on a given model. When the job class is
|
5
|
+
# found, the action method fires off a new instance of the job.
|
6
|
+
#
|
7
|
+
# @private
|
8
|
+
class Performer
|
9
|
+
# The method name given to the class as a String.
|
10
|
+
#
|
11
|
+
# @attr_reader [String]
|
12
|
+
attr_reader :method_name
|
13
|
+
|
14
|
+
# The model name given to the class by +ActiveModel::Naming+.
|
15
|
+
#
|
16
|
+
# @attr_reader [String]
|
17
|
+
# @see http://api.rubyonrails.org/classes/ActiveModel/Naming.html
|
18
|
+
attr_reader :model_name
|
19
|
+
|
20
|
+
# @param [String] method_name A method corresponding to a job.
|
21
|
+
# @param [String] model_name The model we are calling this from.
|
22
|
+
def initialize(method_name, model_name)
|
23
|
+
@method_name = method_name.to_s
|
24
|
+
@model_name = model_name.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
# Tests whether this method name corresponds to a job class in the
|
28
|
+
# application.
|
29
|
+
#
|
30
|
+
# @return [Boolean] whether this job exists or not
|
31
|
+
def job?
|
32
|
+
job_class.present?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attempts to find the job class for this method and return it,
|
36
|
+
# otherwise it returns +nil+ when encountering a +NameError+.
|
37
|
+
#
|
38
|
+
# @return [ActiveJob::Base] a job class or nil
|
39
|
+
def job_class
|
40
|
+
job_name.classify.constantize
|
41
|
+
rescue NameError
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
# Build the conventional job name from the given method and model.
|
46
|
+
# Suffix with +job+ and separate with underscores.
|
47
|
+
#
|
48
|
+
# @return [String] the underscored job class name
|
49
|
+
def job_name
|
50
|
+
"#{action_name}_#{model_name}_job"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Strip the '!' off of the end of the method.
|
54
|
+
#
|
55
|
+
# @return [String] '!'-stripped version of the method name.
|
56
|
+
def action_name
|
57
|
+
method_name.gsub ACTION_SUFFIX, ''
|
58
|
+
end
|
59
|
+
|
60
|
+
# Perform this action on the given model.
|
61
|
+
#
|
62
|
+
# @param [ActiveModel::Model] model The model object we are
|
63
|
+
# performing the job on
|
64
|
+
# @return [TrueClass, FalseClass] whether the job succeeded to
|
65
|
+
# enqueue.
|
66
|
+
def call(model)
|
67
|
+
job_class.perform_later model
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
require "active_model"
|
3
|
+
require "active_model/jobs/version"
|
4
|
+
require "active_model/jobs/performer"
|
5
|
+
require "active_model/jobs/engine" if defined? Rails
|
6
|
+
|
7
|
+
module ActiveModel
|
8
|
+
# Include this module into your model to take advantage of
|
9
|
+
# automatically-generated +:job_name!+ action methods for any
|
10
|
+
# matching ActiveJob classes.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# class MyModel < ActiveRecord::Base
|
14
|
+
# include ActiveModel::Jobs
|
15
|
+
#
|
16
|
+
# after_commit :deploy!
|
17
|
+
# end
|
18
|
+
module Jobs
|
19
|
+
# Method suffix for actions.
|
20
|
+
ACTION_SUFFIX = '!'.freeze
|
21
|
+
|
22
|
+
# Call +perform_later+ on an ActiveJob class corresponding to an
|
23
|
+
# undefined action method name. Most of the work here is done in the
|
24
|
+
# +Performer+ class, which takes care of discoevering whether the
|
25
|
+
# method passed in corresponds to a given job or whether we should
|
26
|
+
# just delegate back to +ActiveRecord::Base+. This method will
|
27
|
+
# prevent a new +Perfomer+ class from being instantiated for every
|
28
|
+
# method call by using a guard clause to check whether the method is
|
29
|
+
# an action method before proceeding on further checks.
|
30
|
+
#
|
31
|
+
# @throws NoMethodError if no job matches the action method
|
32
|
+
def method_missing(method, *arguments)
|
33
|
+
performer = Performer.new method, model_name
|
34
|
+
return super unless respond_to?(method) && performer.job?
|
35
|
+
|
36
|
+
performer.call self
|
37
|
+
end
|
38
|
+
|
39
|
+
# Allow the model to respond to all "action" methods (methods
|
40
|
+
# suffixed by +!+)
|
41
|
+
def respond_to_missing?(method, include_private = true)
|
42
|
+
method.to_s.end_with?(ACTION_SUFFIX) || super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_model_jobs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.49.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.49.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.20
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.20
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activejob
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 5.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 5.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activemodel
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 5.0.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 5.0.0
|
125
|
+
description: Enqueue ActiveJobs in your ActiveModel. Helps you call background jobs.
|
126
|
+
email:
|
127
|
+
- tscott@weblinc.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".bundle/config"
|
133
|
+
- ".codeclimate.yml"
|
134
|
+
- ".env"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".rubocop.yml"
|
138
|
+
- ".ruby-version"
|
139
|
+
- ".travis.yml"
|
140
|
+
- CODE_OF_CONDUCT.md
|
141
|
+
- Gemfile
|
142
|
+
- LICENSE.txt
|
143
|
+
- README.md
|
144
|
+
- Rakefile
|
145
|
+
- active_model_jobs.gemspec
|
146
|
+
- bin/console
|
147
|
+
- bin/htmldiff
|
148
|
+
- bin/ldiff
|
149
|
+
- bin/rake
|
150
|
+
- bin/rspec
|
151
|
+
- bin/rubocop
|
152
|
+
- bin/ruby-parse
|
153
|
+
- bin/ruby-rewrite
|
154
|
+
- bin/setup
|
155
|
+
- bin/yard
|
156
|
+
- bin/yardoc
|
157
|
+
- bin/yri
|
158
|
+
- lib/active_model/jobs.rb
|
159
|
+
- lib/active_model/jobs/engine.rb
|
160
|
+
- lib/active_model/jobs/performer.rb
|
161
|
+
- lib/active_model/jobs/version.rb
|
162
|
+
homepage: http://github.com/tubbo/active_model-jobs
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
metadata: {}
|
166
|
+
post_install_message:
|
167
|
+
rdoc_options: []
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
requirements: []
|
181
|
+
rubyforge_project:
|
182
|
+
rubygems_version: 2.4.5
|
183
|
+
signing_key:
|
184
|
+
specification_version: 4
|
185
|
+
summary: Enqueue ActiveJobs in your ActiveModel.
|
186
|
+
test_files: []
|