delayed_job_progress 0.0.2 → 0.0.3

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +3 -1
  4. data/README.md +28 -8
  5. data/Rakefile +1 -1
  6. data/delayed_job_progress.gemspec +1 -1
  7. data/lib/delayed_job_progress/version.rb +1 -1
  8. data/progress.gif +0 -0
  9. data/test/Gemfile.rails-5.0 +5 -0
  10. data/test/dummy/Rakefile +1 -1
  11. data/test/dummy/app/assets/config/manifest.js +5 -0
  12. data/test/dummy/app/assets/javascripts/application.js +1 -1
  13. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  14. data/test/dummy/app/{mailers → assets/javascripts/channels}/.keep +0 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +3 -3
  16. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  17. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  18. data/test/dummy/app/controllers/application_controller.rb +0 -2
  19. data/test/dummy/app/jobs/application_job.rb +2 -0
  20. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  21. data/test/dummy/app/models/application_record.rb +3 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +9 -9
  23. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  24. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  25. data/test/dummy/bin/rails +1 -1
  26. data/test/dummy/bin/setup +21 -12
  27. data/test/dummy/bin/update +29 -0
  28. data/test/dummy/bin/yarn +11 -0
  29. data/test/dummy/config.ru +2 -1
  30. data/test/dummy/config/application.rb +4 -12
  31. data/test/dummy/config/boot.rb +2 -2
  32. data/test/dummy/config/cable.yml +10 -0
  33. data/test/dummy/config/database.yml +1 -1
  34. data/test/dummy/config/environment.rb +1 -1
  35. data/test/dummy/config/environments/development.rb +24 -11
  36. data/test/dummy/config/environments/production.rb +28 -16
  37. data/test/dummy/config/environments/test.rb +6 -6
  38. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  39. data/test/dummy/config/initializers/assets.rb +6 -3
  40. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  41. data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
  42. data/test/dummy/config/locales/en.yml +10 -0
  43. data/test/dummy/config/puma.rb +56 -0
  44. data/test/dummy/config/routes.rb +0 -1
  45. data/test/dummy/config/secrets.yml +15 -5
  46. data/test/dummy/config/spring.rb +6 -0
  47. data/test/dummy/package.json +5 -0
  48. data/test/dummy/public/404.html +6 -6
  49. data/test/dummy/public/422.html +6 -6
  50. data/test/dummy/public/500.html +6 -6
  51. data/test/dummy/{app/models/.keep → public/apple-touch-icon-precomposed.png} +0 -0
  52. data/test/dummy/public/apple-touch-icon.png +0 -0
  53. data/test/extensions/job_test.rb +3 -3
  54. data/test/extensions/worker_test.rb +2 -2
  55. data/test/jobs_controller_test.rb +7 -7
  56. metadata +68 -44
  57. data/test/dummy/README.rdoc +0 -28
  58. data/test/dummy/config/initializers/session_store.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1fcb2f6b8acf92411aae4dea3bba0ba00726f11
4
- data.tar.gz: f56629937708111fd74b7056ccc6a6778091d1e4
3
+ metadata.gz: 8957004157b1b044edaf822c9c07a9bad7882999
4
+ data.tar.gz: 0704dc3c006e8e3314aedee3eef8d649b23c5742
5
5
  SHA512:
6
- metadata.gz: 72b68f66f84482fa967052cfa3de777db1b22d5429c9a93bf73d5a7c5302013d8ac5759b8633770b48058d848d0afb32fcc21702fa6eb2d54ca91f731446e078
7
- data.tar.gz: 55cec2cf7c63aeee0dd2f8f78951f85b05b8def2c75be84211849a6053a9d9466c5526faf7a1ecac5b1172febd9e0ad55e766686517d031ec783cc40a47aa9f4
6
+ metadata.gz: 9ea429083df722cd60996770be94777992bb154627914366f8ab46f505f2b251f2e89358a4aa07a29a1a8e7e42f914d28fcbb377d328a0aaaa5e92ba57fa8cef
7
+ data.tar.gz: a7003f3000a650c5dd4d8cd0062e578e86ddf0103db9db3315496158d47bf6bc191c08a55a31c6e9b8369be1cf40a2ef4533147a556b0f450d9c326c11e8cf73
data/.gitignore CHANGED
@@ -7,4 +7,5 @@ test/dummy/log/*.log
7
7
  test/dummy/tmp/
8
8
  test/dummy/.sass-cache
9
9
  tmp/
10
- Gemfile.lock
10
+ Gemfile.lock
11
+ .ruby-version
@@ -1,2 +1,4 @@
1
1
  language: ruby
2
- rvm: 2.2.1
2
+ rvm: 2.4.1
3
+ gemfile:
4
+ test/Gemfile.rails-5.0
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # DelayedJobProgress
2
2
  [![Gem Version](https://img.shields.io/gem/v/delayed_job_progress.svg?style=flat)](http://rubygems.org/gems/delayed_job_progress) [![Gem Downloads](https://img.shields.io/gem/dt/delayed_job_progress.svg?style=flat)](http://rubygems.org/gems/delayed_job_progress) [![Build Status](https://img.shields.io/travis/GBH/delayed_job_progress.svg?style=flat)](https://travis-ci.org/GBH/delayed_job_progress)
3
3
 
4
- Extension for [Delayed::Job](https://github.com/collectiveidea/delayed_job) that allows better tracking of jobs!
4
+ Extension for [Delayed::Job](https://github.com/collectiveidea/delayed_job) that allows for better tracking of jobs!
5
+
6
+ ![progress](https://raw.githubusercontent.com/GBH/delayed_job_progress/master/progress.gif)
5
7
 
6
8
  ## Setup
7
9
 
@@ -69,12 +71,14 @@ That job knows about object that spawned it:
69
71
 
70
72
  `Delayed::Job` records now have new attributes:
71
73
  ```
72
- `progress_max` - default is `100`. You can change it to whatever during `enqueue`.
73
- `progress_current` - default is `0`. You can manually increment it while job is running. Will be set to `process_max` when job completes.
74
- `message` - default is `nil`. Optional informational string.
75
- `error_message` - error message without backtrace. Also useful to set your own message.
76
- `completed_at` - when job is done this timestamp is recorded.
77
- `identifier` - you can assign something during `enqueue` so you can fetch that job later for display.
74
+ `progress_max` - Default is `100`. You can change it to whatever during `enqueue`.
75
+ `progress_current` - Default is `0`. You can manually increment it while job is running.
76
+ Will be set to `process_max` when job completes.
77
+ `message` - Default is `nil`. Optional informational string.
78
+ `error_message` - Error message without backtrace. Also useful to set your own message.
79
+ `completed_at` - When job is done this timestamp is recorded.
80
+ `identifier` - You can assign something during `enqueue` so you can fetch that job later for display.
81
+ `status` - Virtual read-only attribute. Can be `queued`, `processing`, `completed` or `failed`
78
82
  ```
79
83
 
80
84
  This extension also introduces worker setting that keeps completed jobs around. This way you can keep list of completed jobs for a while. If you want to remove them, you need to `.destroy(:force)` them.
@@ -84,9 +88,25 @@ Delayed::Worker.destroy_completed_jobs = false
84
88
 
85
89
  ## Jobs Controller
86
90
 
91
+ You may mount jobs controller in your routes by adding:
92
+
93
+ ```ruby
94
+ mount DelayedJobProgress::Engine => '/delayed'
87
95
  ```
88
- GET /jobs - List all jobs. Can filter based on associated record via `record_type` and `record_id` parameters. `identifier` parameter can be used as well
96
+
97
+ Following JSON serving end-points will become available:
98
+
99
+ ```
100
+ GET /jobs - List all jobs. Can filter based on associated record via `record_type` and `record_id`
101
+ parameters. `identifier` parameter can be used as well
89
102
  GET /jobs/<id> - Status of a job. Will see all the Delayed::Job attributes including things like progress
90
103
  DELETE /jobs/<id>` - If job is stuck/failed, we can remove it
91
104
  POST /jobs/<id>/reload` - Restart failed job
92
105
  ```
106
+
107
+ ## Front-end
108
+ This gem doesn't have a front-end component to show fancy progress bar. Common way to accomplish that would be to create a javascript poller that would periodically hit `/jobs/<id>` enpoint and update progress bar with progress data + messages.
109
+
110
+ ---
111
+
112
+ Copyright 2016 Oleg Khabarov
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Rake::TestTask.new(:test) do |t|
18
18
  t.libs << 'test'
19
19
  t.pattern = 'test/**/*_test.rb'
20
20
  t.verbose = false
21
+ t.warning = false
21
22
  end
22
23
 
23
-
24
24
  task default: :test
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = Dir["test/**/*"]
19
19
 
20
- s.add_dependency 'rails', '>= 4.0.0', '< 5'
20
+ s.add_dependency 'rails', '>= 4.0.0'
21
21
  s.add_dependency 'delayed_job', '>= 4.0'
22
22
  s.add_dependency 'delayed_job_active_record', '>= 4.0'
23
23
 
@@ -1,3 +1,3 @@
1
1
  module DelayedJobProgress
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
Binary file
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", ">= 5"
4
+
5
+ gemspec path: "../"
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
6
  Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
5
+ //= link delayed_job_progress_manifest.js
@@ -5,7 +5,7 @@
5
5
  // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
9
  //
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -6,9 +6,9 @@
6
6
  * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
8
  * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -1,5 +1,3 @@
1
1
  class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
2
  protect_from_forgery with: :exception
5
3
  end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,14 +1,14 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
10
6
 
11
- <%= yield %>
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
+ </head>
12
10
 
13
- </body>
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
14
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
3
  require_relative '../config/boot'
4
4
  require 'rails/commands'
@@ -1,29 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
3
5
 
4
6
  # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
8
 
7
- Dir.chdir APP_ROOT do
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
8
14
  # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
10
23
 
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
14
24
 
15
25
  # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
26
+ # unless File.exist?('config/database.yml')
27
+ # cp 'config/database.yml.sample', 'config/database.yml'
18
28
  # end
19
29
 
20
30
  puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
31
+ system! 'bin/rails db:setup'
22
32
 
23
33
  puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
34
+ system! 'bin/rails log:clear tmp:clear'
26
35
 
27
36
  puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
37
+ system! 'bin/rails restart'
29
38
  end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -1,4 +1,5 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require_relative 'config/environment'
4
+
4
5
  run Rails.application
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
2
2
 
3
3
  require 'rails/all'
4
4
 
@@ -7,20 +7,12 @@ require "delayed_job_progress"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
+ # Initialize configuration defaults for originally generated Rails version.
11
+ # config.load_defaults 5.1
12
+
10
13
  # Settings in config/environments/* take precedence over those specified here.
11
14
  # Application configuration should go into files in config/initializers
12
15
  # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
16
  end
25
17
  end
26
18
 
@@ -1,5 +1,5 @@
1
1
  # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
3
 
4
4
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
10
+ channel_prefix: dummy_production
@@ -6,7 +6,7 @@
6
6
  #
7
7
  default: &default
8
8
  adapter: sqlite3
9
- pool: 5
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
10
  timeout: 5000
11
11
 
12
12
  development:
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require_relative 'application'
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -9,13 +9,28 @@ Rails.application.configure do
9
9
  # Do not eager load code on boot.
10
10
  config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
25
+
26
+ config.cache_store = :null_store
27
+ end
15
28
 
16
29
  # Don't care if the mailer can't send.
17
30
  config.action_mailer.raise_delivery_errors = false
18
31
 
32
+ config.action_mailer.perform_caching = false
33
+
19
34
  # Print deprecation notices to the Rails logger.
20
35
  config.active_support.deprecation = :log
21
36
 
@@ -27,15 +42,13 @@ Rails.application.configure do
27
42
  # number of complex assets.
28
43
  config.assets.debug = true
29
44
 
30
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
- # yet still be able to expire them through the digest params.
32
- config.assets.digest = true
33
-
34
- # Adds additional error checking when serving assets at runtime.
35
- # Checks for improperly declared sprockets dependencies.
36
- # Raises helpful error messages.
37
- config.assets.raise_runtime_errors = true
45
+ # Suppress logger output for asset requests.
46
+ config.assets.quiet = true
38
47
 
39
48
  # Raises error for missing translations
40
49
  # config.action_view.raise_on_missing_translations = true
50
+
51
+ # Use an evented file watcher to asynchronously detect changes in source code,
52
+ # routes, locales, etc. This feature depends on the listen gem.
53
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
41
54
  end