resque-helpers 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ *.swo
21
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rvmrc ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@resque-helpers"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.15.1 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in resque-helpers.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'resque'
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ resque-helpers (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ multi_json (1.5.0)
11
+ rack (1.5.0)
12
+ rack-protection (1.3.2)
13
+ rack
14
+ redis (3.0.2)
15
+ redis-namespace (1.2.1)
16
+ redis (~> 3.0.0)
17
+ resque (1.23.0)
18
+ multi_json (~> 1.0)
19
+ redis-namespace (~> 1.0)
20
+ sinatra (>= 0.9.2)
21
+ vegas (~> 0.1.2)
22
+ rspec (2.12.0)
23
+ rspec-core (~> 2.12.0)
24
+ rspec-expectations (~> 2.12.0)
25
+ rspec-mocks (~> 2.12.0)
26
+ rspec-core (2.12.2)
27
+ rspec-expectations (2.12.1)
28
+ diff-lcs (~> 1.1.3)
29
+ rspec-mocks (2.12.1)
30
+ sinatra (1.3.3)
31
+ rack (~> 1.3, >= 1.3.6)
32
+ rack-protection (~> 1.2)
33
+ tilt (~> 1.3, >= 1.3.3)
34
+ tilt (1.3.3)
35
+ vegas (0.1.11)
36
+ rack (>= 1.0.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ resque
43
+ resque-helpers!
44
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ Copyright (c) 2013 John Hinnegan
2
+
3
+ This software is not free to use.
4
+ Unauthorized use or copy is not permitted.
5
+
6
+ johnh@telenav.com
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Resque::Helpers
2
+
3
+ This gem contains helpers for Resque. Tested with rails 3.2.11 and resque 1.23.0
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'resque-helpers'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install resque-helpers
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ ## License
24
+
25
+ This gem is not free to use. It is property of Telenav.
26
+
27
+ ### Contributors
28
+
29
+ * John Hinnegan (johnh@telenav.com)
30
+
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,19 @@
1
+ module Resque
2
+ module Helpers
3
+ module LoggedJob
4
+ def around_perform_log_job(*args)
5
+ clazz = self.name
6
+ Rails.logger.info "#{clazz} starting up with: #{args.join(", ")}"
7
+ begin
8
+ run_time = Benchmark.realtime do
9
+ yield *args
10
+ end
11
+ rescue => e
12
+ Rails.logger.info "#{clazz} completed unsuccessfully in #{run_time.try(:round)} seconds with #{e.class}:#{e.message}"
13
+ raise
14
+ end
15
+ Rails.logger.info "#{clazz} completed successfully in #{run_time.try(:round)} seconds"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Resque
2
+ module Helpers
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "resque-helpers/version"
2
+
3
+ module Resque
4
+ module Helpers
5
+ # Your code goes here...
6
+ module LoggedJob
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/resque-helpers/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["John Hinnegan"]
6
+ gem.email = ["johnh@telenav.com"]
7
+ gem.description = %q{Contains helpers / extensions for Resque workers}
8
+ gem.summary = %q{Contains helpers / extensions for Resque workers}
9
+ gem.homepage = "http://github.com/thinknear/resque-helpers"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "resque-helpers"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Resque::Helpers::VERSION
17
+
18
+ #gem.add_development_dependency "rspec"
19
+ #gem.add_development_dependency "resque"
20
+
21
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ class LoggedDummy
4
+ extend Resque::Helpers::LoggedJob
5
+
6
+ class << self
7
+ def perform(a, b, c)
8
+ end
9
+ end
10
+ end
11
+
12
+ class DummyExcepion < RuntimeError
13
+ end
14
+
15
+ module Reesque
16
+ module Helpers
17
+
18
+
19
+ describe Resque::Helpers::LoggedJob do
20
+ def do_job
21
+ Resque::Job.new(:jobs, {'class' => "LoggedDummy", 'args' => [1, 2, 3]}).perform
22
+ end
23
+ it "should call the nested perform method" do
24
+ LoggedDummy.should_receive(:perform).with(1, 2, 3)
25
+ do_job
26
+ end
27
+ context "when an error occurs" do
28
+ it "should not swallow the error" do
29
+ LoggedDummy.stub(:perform).and_raise(DummyExcepion.new)
30
+ lambda {
31
+ do_job
32
+ }.should raise_error(DummyExcepion)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'rubygems'
8
+ require 'bundler/setup'
9
+ require 'resque-helpers'
10
+ require 'resque'
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Hinnegan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Contains helpers / extensions for Resque workers
15
+ email:
16
+ - johnh@telenav.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rspec
23
+ - .rvmrc
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - lib/resque-helpers.rb
30
+ - lib/resque-helpers/version.rb
31
+ - lib/resque/helpers/logged_job.rb
32
+ - resque-helpers.gemspec
33
+ - spec/logged_job_spec.rb
34
+ - spec/spec_helper.rb
35
+ homepage: http://github.com/thinknear/resque-helpers
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.24
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Contains helpers / extensions for Resque workers
59
+ test_files:
60
+ - spec/logged_job_spec.rb
61
+ - spec/spec_helper.rb