resque-aliasing 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c16298e883736fa3c4315f45f950db05a403f059
4
+ data.tar.gz: c91e96b0c536e0dd63c3598fcfc61101ec4ddbf5
5
+ SHA512:
6
+ metadata.gz: bc3df9811a38cad2ec01248fdb328b9913035154c3d011c27812dfc4571c81c8eac8741c1ccf72ca0da1eb893649b137ed21217dfe0adbf836dc1a9bf533597e
7
+ data.tar.gz: 639ce61e28aed3b1ce3a8ed649c857642edc91d2e02dd850229fa5029d1ab8ecf4f5145809b32c8283316d7c8f0eea52920ad28c0ac056f757fb950460661114
data/.gitignore ADDED
@@ -0,0 +1,45 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /db/*.sqlite3-journal
8
+ /public/system
9
+ /coverage/
10
+ /spec/tmp
11
+ **.orig
12
+ rerun.txt
13
+ pickle-email-*.html
14
+
15
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
+ config/initializers/secret_token.rb
17
+ config/secrets.yml
18
+
19
+ ## Environment normalization:
20
+ /.bundle
21
+ /vendor/bundle
22
+
23
+ # these should all be checked in to normalize the environment:
24
+ # Gemfile.lock, .ruby-version, .ruby-gemset
25
+
26
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
27
+ .rvmrc
28
+
29
+ # if using bower-rails ignore default bower_components path bower.json files
30
+ /vendor/assets/bower_components
31
+ *.bowerrc
32
+ bower.json
33
+
34
+ # Ignore pow environment settings
35
+ .powenv
36
+
37
+ /.bundle/
38
+ /.yardoc
39
+ /Gemfile.lock
40
+ /_yardoc/
41
+ /coverage/
42
+ /doc/
43
+ /pkg/
44
+ /spec/reports/
45
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in resque-aliasing.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Misha Conway
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Resque::Aliasing
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/resque/aliasing`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'resque-aliasing'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install resque-aliasing
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/resque-aliasing.
36
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "resque/aliasing"
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/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require 'resque/plugins/aliasing'
2
+ require "resque/plugins/aliasing/version"
3
+ require "resque/plugins/aliasing/aliased_job"
@@ -0,0 +1,22 @@
1
+ module Resque
2
+ module Plugins
3
+ module Aliasing
4
+ module AliasedJob
5
+ module ClassMethods
6
+ def before_enqueue *args
7
+ Resque.enqueue @destination, *args
8
+ false
9
+ end
10
+
11
+ def perform *args
12
+ Resque.enqueue @destination, *args
13
+ end
14
+ end
15
+
16
+ def self.included(base)
17
+ base.extend ClassMethods
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module Resque
2
+ module Plugins
3
+ module Aliasing
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ module Resque
2
+ module Plugins
3
+ module Aliasing
4
+ def alias_job klass_name
5
+ klass = ensure_klass klass_name
6
+
7
+ unless aliased_jobs[klass.name]
8
+ aliased_jobs[klass.name] = 1
9
+ klass.instance_variable_set :@queue, instance_variable_get(:@queue)
10
+ klass.instance_variable_set :@destination, self
11
+ klass.include AliasedJob
12
+ end
13
+ end
14
+
15
+ def aliased_jobs
16
+ @aliased_jobs ||= {}
17
+ end
18
+
19
+
20
+ def ensure_klass klass_name
21
+ segments = klass_name.split '::'
22
+ demodulized_klass_name = segments.pop
23
+
24
+ parent_module = Object
25
+ while segments.size > 0
26
+ parent_module = ensure_const parent_module, segments.shift, Module
27
+ end
28
+
29
+ ensure_const parent_module, demodulized_klass_name, Class
30
+ end
31
+
32
+ def ensure_const parent, const_name, klass
33
+ if parent.const_defined? const_name
34
+ const = parent.const_get const_name
35
+ raise "expected #{const.name} to be a #{klass.name}" unless const.kind_of? Module
36
+ const
37
+ else
38
+ parent.const_set const_name, klass.new
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'resque/plugins/aliasing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "resque-aliasing"
8
+ spec.version = Resque::Plugins::Aliasing::VERSION
9
+ spec.authors = ["Misha Conway"]
10
+ spec.email = ["mishaAconway@gmail.com"]
11
+
12
+ spec.summary = %q{Alias old or removed resque jobs to existing ones.}
13
+ spec.description = %q{Alias old or removed resque jobs to existing ones.}
14
+ spec.homepage = "https://github.com/MishaConway/resque-aliasing."
15
+
16
+ spec.licenses = ["MIT"]
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-aliasing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Misha Conway
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-25 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: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Alias old or removed resque jobs to existing ones.
42
+ email:
43
+ - mishaAconway@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - lib/resque/aliasing.rb
57
+ - lib/resque/plugins/aliasing.rb
58
+ - lib/resque/plugins/aliasing/aliased_job.rb
59
+ - lib/resque/plugins/aliasing/version.rb
60
+ - resque-aliasing.gemspec
61
+ homepage: https://github.com/MishaConway/resque-aliasing.
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.5
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Alias old or removed resque jobs to existing ones.
85
+ test_files: []
86
+ has_rdoc: