active_job_log 0.2.0 → 2.0.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +104 -0
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.rubocop.yml +65 -600
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +25 -0
  7. data/Gemfile.lock +170 -154
  8. data/LICENSE.txt +1 -1
  9. data/README.md +15 -4
  10. data/active_job_log.gemspec +7 -5
  11. data/db/migrate/20180511184635_create_active_job_log_jobs.rb +1 -1
  12. data/lib/active_job_log/engine.rb +1 -0
  13. data/lib/active_job_log/log_ext.rb +1 -1
  14. data/lib/active_job_log/loggeable.rb +75 -0
  15. data/lib/active_job_log/version.rb +1 -1
  16. data/lib/generators/active_job_log/install/install_generator.rb +4 -0
  17. data/lib/generators/active_job_log/install/templates/job_model.rb +5 -0
  18. data/spec/dummy/Rakefile +1 -1
  19. data/spec/dummy/app/assets/config/manifest.js +0 -2
  20. data/spec/dummy/app/controllers/application_controller.rb +0 -1
  21. data/spec/dummy/app/{assets/javascripts → javascript/packs}/application.js +2 -0
  22. data/spec/dummy/app/jobs/application_job.rb +5 -0
  23. data/spec/dummy/app/models/active_job_log/job.rb +5 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +3 -2
  25. data/spec/dummy/bin/rails +2 -2
  26. data/spec/dummy/bin/rake +2 -2
  27. data/spec/dummy/bin/setup +7 -12
  28. data/spec/dummy/config.ru +2 -1
  29. data/spec/dummy/config/application.rb +12 -17
  30. data/spec/dummy/config/boot.rb +1 -1
  31. data/spec/dummy/config/cable.yml +2 -2
  32. data/spec/dummy/config/database.yml +1 -1
  33. data/spec/dummy/config/environment.rb +1 -1
  34. data/spec/dummy/config/environments/development.rb +28 -6
  35. data/spec/dummy/config/environments/production.rb +45 -16
  36. data/spec/dummy/config/environments/test.rb +24 -7
  37. data/spec/dummy/config/initializers/assets.rb +0 -2
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -3
  39. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  40. data/spec/dummy/config/initializers/filter_parameter_logging.rb +3 -1
  41. data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
  42. data/spec/dummy/config/locales/en.yml +1 -1
  43. data/spec/dummy/config/puma.rb +14 -27
  44. data/spec/dummy/config/storage.yml +34 -0
  45. data/spec/dummy/db/schema.rb +1 -1
  46. data/spec/factories/active_job_log_jobs.rb +2 -2
  47. data/spec/lib/active_job_log/log_ext_spec.rb +3 -6
  48. metadata +54 -31
  49. data/.hound.yml +0 -4
  50. data/.travis.yml +0 -15
  51. data/Guardfile +0 -15
  52. data/app/models/active_job_log/job.rb +0 -72
  53. data/spec/dummy/app/assets/javascripts/cable.js +0 -13
  54. data/spec/dummy/bin/bundle +0 -3
  55. data/spec/dummy/bin/update +0 -29
  56. data/spec/dummy/bin/yarn +0 -11
  57. data/spec/dummy/config/secrets.yml +0 -32
  58. data/spec/dummy/config/spring.rb +0 -6
data/.hound.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- ruby:
3
- enabled: true
4
- config_file: ".rubocop.yml"
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.1
5
- script:
6
- - RAILS_ENV=test bundle exec rake db:create db:migrate
7
- - bundle exec rspec spec
8
- deploy:
9
- provider: rubygems
10
- api_key:
11
- secure: jdniKr5kUszQJ1fATVM/1ChmvMMlYQovbPlrUZwxrKxV856qD6pvajhRCT7hJF9KIK7UIi5VEdFdjNKZhsztBIwpYwzmt4IsxiSOgXjDar2kH7Qer213Jx3tgWnu3NsbjBQy2l+QgefLnaxJEtxg3EFNNnD2/XInPhWrV8SRgn5YFPsyRNCXwLYAIMrZgeummKcpp3MeGXLt385sAJzgmQLaZjg2yyC7fbQ1Hh0ib/oU+6amfJV4aDRREWOdboxH+/c/FvNhT/P5lcZvNi/EGbkkG9OLWUguwcchE/vRBDosKWhx2mUqaBYwDet0eEbyNYfYMcaFB5/SjWLI+u0+ZKZ3oKQ+DKwQrWTPVBV6rPPpDrOOeEwQ0CnSpuoTCPJTCGPZCd0kk9O9k509+xQ479+Zo3BdkCREpk4fMKiH/2nNqU1o+lpzYNnnzeWjC5SLuJhxuUxuGEAhHyYK3rX3lL/ldxUp3TrcDfQ0fXMi5y7GM9QjYG6Z6gWP2S2e2J8tbjN3JfJM2iy3oHgFnoIHduu+phZYRsfMuN4vzFVJ8MN+Y651He6FHXq/pX9JXIbR/lZMPPITi+Tk2Rsmn+KFSYRpd1Ne2g8ZwGYPKeQt5xGcitGwpKPpLQlINpbqwDDaFo22tO68gVCBdiVboELz0pvexvzPOllKsPFDh4JhFhg=
12
- gem: active_job_log
13
- on:
14
- tags: true
15
- repo: platanus/active_job_log
data/Guardfile DELETED
@@ -1,15 +0,0 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
2
- spec_dic = "spec/dummy/spec"
3
- # RSpec files
4
- watch("spec/spec_helper.rb") { spec_dic }
5
- watch("spec/rails_helper.rb") { spec_dic }
6
- watch(%r{^spec\/dummy\/spec\/support\/(.+)\.rb$}) { spec_dic }
7
- watch(%r{^spec\/dummy\/spec\/.+_spec\.rb$})
8
- # Engine files
9
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/dummy/spec/lib/#{m[1]}_spec.rb" }
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/dummy/spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb)$}) { |m| "spec/dummy/spec/#{m[1]}#{m[2]}_spec.rb" }
12
- # Dummy app files
13
- watch(%r{^spec\/dummy\/app/(.+)\.rb$}) { |m| "spec/dummy/spec/#{m[1]}_spec.rb" }
14
- watch(%r{^spec\/dummy\/app/(.*)(\.erb)$}) { |m| "spec/dummy/spec/#{m[1]}#{m[2]}_spec.rb" }
15
- end
@@ -1,72 +0,0 @@
1
- module ActiveJobLog
2
- class Job < ApplicationRecord
3
- extend Enumerize
4
-
5
- STATUSES = %i{queued pending finished failed}
6
-
7
- validates :job_id, presence: true
8
-
9
- enumerize :status, in: STATUSES, scope: true
10
-
11
- serialize :params, Array
12
- serialize :stack_trace, Array
13
-
14
- before_save :set_queued_duration
15
- before_save :set_execution_duration
16
- before_save :set_total_duration
17
-
18
- def self.update_job!(job_id, status, params = {})
19
- params.merge!(status_to_params(status))
20
- job = find_or_create_job(job_id)
21
- job.update_attributes!(params)
22
- job
23
- end
24
-
25
- class << self
26
- private
27
-
28
- def find_or_create_job(job_id)
29
- Job.where(job_id: job_id).where.not(status: :failed).last || Job.create(job_id: job_id)
30
- end
31
-
32
- def status_to_params(status)
33
- time_attr = infer_duration_attr_from_status(status)
34
- {
35
- time_attr => DateTime.current,
36
- status: status
37
- }
38
- end
39
-
40
- def infer_duration_attr_from_status(status)
41
- case status
42
- when :queued
43
- :queued_at
44
- when :pending
45
- :started_at
46
- when :finished, :failed
47
- :ended_at
48
- else
49
- fail "invalid status"
50
- end
51
- end
52
- end
53
-
54
- private
55
-
56
- def set_queued_duration
57
- return if queued_at.blank? || started_at.blank?
58
- self.queued_duration = (started_at.to_f - queued_at.to_f).to_i
59
- end
60
-
61
- def set_execution_duration
62
- return if started_at.blank? || ended_at.blank?
63
- self.execution_duration = (ended_at.to_f - started_at.to_f).to_i
64
- end
65
-
66
- def set_total_duration
67
- from = queued_at || started_at
68
- return if from.blank? || ended_at.blank?
69
- self.total_duration = (ended_at.to_f - from.to_f).to_i
70
- end
71
- end
72
- end
@@ -1,13 +0,0 @@
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);
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
@@ -1,29 +0,0 @@
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
data/spec/dummy/bin/yarn DELETED
@@ -1,11 +0,0 @@
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,32 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rails secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- # Shared secrets are available across all environments.
14
-
15
- # shared:
16
- # api_key: a1B2c3D4e5F6
17
-
18
- # Environmental secrets are only available for that specific environment.
19
-
20
- development:
21
- secret_key_base: c867a79e6f64110df1a01c88c47dc3befd72e8500c8a9046099ff6cef38833d86db8aec82fcd159b92b59e0375f58c25ca5dd0cadb48200ddcaa075e29c0b123
22
-
23
- test:
24
- secret_key_base: aeee55447e9d40371d6ca771089900debcb02c51f2b7f5e1d7392ca1954991f23e3e7ee0c1f2314cc7d6d424c03eeb2fdd3698cae64f8c92ca9cef3315a2ed70
25
-
26
- # Do not keep production secrets in the unencrypted secrets file.
27
- # Instead, either read values from the environment.
28
- # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29
- # and move the `production:` environment over there.
30
-
31
- production:
32
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -1,6 +0,0 @@
1
- %w(
2
- .ruby-version
3
- .rbenv-vars
4
- tmp/restart.txt
5
- tmp/caching-dev.txt
6
- ).each { |path| Spring.watch(path) }