thecore_background_jobs 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee01019e2607dbaff7a4a46a87b61ee683fe8f8a9c4d5df41c2b470b4b034db0
4
- data.tar.gz: e4635d0e13829866e0346f94216b252a656f45ad69f88a2c9510a4cc6cb0901e
3
+ metadata.gz: 9160676e1874d6706c018c62552548313751564e520aaead9dfe8619cb2b5de1
4
+ data.tar.gz: 0407032be2d0e001faf6e5210fb63fbc5db968be9f35b3a2ceafe6a65aee896f
5
5
  SHA512:
6
- metadata.gz: c3c1fd37a029cef7107cd6a362a079661a2f2ef1f9abca2847d652afb6b6908ace2c2df7e8f78233c87cd109193446f7de31e0ac734d06da6e68b83311c5a934
7
- data.tar.gz: f13d71b0a66a81abc7a5f0512415aaec231bc44cee147e6186cf062bad9d34963603ed3df6d35926c7d85e56f521adf8863558b384b82bb867d55c7a717b536b
6
+ metadata.gz: e8f5a4e6450526b7108cc56a49e935e25be98e8e2df6981f5c4930c2a9709c52a2ed5b16984b41c160ebe2cc9a2bfc1dd709742a13884fc6405dc2b815befcbc
7
+ data.tar.gz: f9836b96dd73edf7a79067f092bf23a8002bdf8ebf92d19c6e3c5550b68b3366efa3aa9190e5b42aeeabf852d983332188a1a8c05185ef21aceb560969c921fc
data/README.md CHANGED
@@ -1,64 +1,28 @@
1
- Dependencies
2
- ------------
1
+ # ThecoreBackgroundJobs
2
+ Short description and motivation.
3
3
 
4
- This gem depends on tiny\_tds, which depends on some debian packages to
5
- be installed:
4
+ ## Usage
5
+ How to use my plugin.
6
6
 
7
- sudo apt install freetds-dev redis-server
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
8
9
 
9
- Sidekiq setup
10
- -------------
10
+ ```ruby
11
+ gem "thecore_background_jobs"
12
+ ```
11
13
 
12
- The following script asks for the installation directory of the main Thecore App and from that it retrieves the needed information.
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
13
18
 
14
- echo "Please provide the path to the app:";read APPPATH
15
- APPNAME=$(basename "$APPPATH")
16
- CURDIR=$(pwd)
17
- cd $APPPATH
18
- BUNDLEBIN=$(which bundle)
19
- cd $CURDIR
20
- cat <<EOM | sudo tee "/lib/systemd/system/sidekiq-$APPNAME.service"
21
- [Unit]
22
- Description=sidekiq-$APPNAME
23
- After=syslog.target network.target redis-server.service
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install thecore_background_jobs
22
+ ```
24
23
 
25
- [Service]
26
- WorkingDirectory=$APPPATH
27
- ExecStart=$BUNDLEBIN exec "sidekiq -e production"
28
- User=${SUDO_USER:-$(whoami)}
29
- Type=simple
30
- RestartSec=1
31
- Restart=on-failure
24
+ ## Contributing
25
+ Contribution directions go here.
32
26
 
33
- # output goes to /var/log/syslog
34
- StandardOutput=syslog
35
- StandardError=syslog
36
- SyslogIdentifier=sidekiq-$APPNAME
37
-
38
- [Install]
39
- WantedBy=multi-user.target
40
- EOM
41
-
42
- Then enable it:
43
-
44
- sudo systemctl enable sidekiq-$APPNAME
45
-
46
- and start:
47
-
48
- sudo service sidekiq-$APPNAME start
49
-
50
- Now you can access the web ui, i.e.
51
-
52
- https://yourtld/sidekiq
53
-
54
- And you can manually test it in rails console:
55
-
56
- RAILS_ENV=production rails runner ImportFromFtpWorker.perform_async
57
-
58
- If you'd like to have the scheduled job run repeatedly, then add
59
- **config/sidekiq.yml** with content like:
60
-
61
- schedule:
62
- hello_world:
63
- cron: '0 * * * * *' # Runs once per minute
64
- class: HelloWorld
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,36 +1,3 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/setup"
6
2
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'ThecoreBackgroundJobs'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
- load 'rails/tasks/statistics.rake'
22
-
23
-
24
-
25
- require 'bundler/gem_tasks'
26
-
27
- require 'rake/testtask'
28
-
29
- Rake::TestTask.new(:test) do |t|
30
- t.libs << 'test'
31
- t.pattern = 'test/**/*_test.rb'
32
- t.verbose = false
33
- end
34
-
35
-
36
- task default: :test
3
+ require "bundler/gem_tasks"
@@ -1,8 +1,8 @@
1
1
  class DemoWorker
2
- include Sidekiq::Worker
3
- sidekiq_options retry: false, queue: "#{ENV["COMPOSE_PROJECT_NAME"]}_default"
4
-
5
- def perform(*args)
6
- puts "Worker is working"
7
- end
2
+ include Sidekiq::Worker
3
+ sidekiq_options retry: false, queue: "#{ENV["COMPOSE_PROJECT_NAME"]}_default"
4
+
5
+ def perform(*args)
6
+ puts "Worker is working"
7
+ end
8
8
  end
@@ -0,0 +1,14 @@
1
+ module Abilities
2
+ class ThecoreBackgroundJobs
3
+ include CanCan::Ability
4
+ def initialize user
5
+ # Main abilities file for Thecore applications
6
+ if user.present?
7
+ # Users' abilities
8
+ if user.admin?
9
+ # Admins' abilities
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ Rails.application.config.paths['db/migrate'] << File.expand_path("../../db/migrate", __dir__)
@@ -0,0 +1,6 @@
1
+ Rails.application.configure do
2
+ config.after_initialize do
3
+ ThecoreBackgroundJobs.update_cron_schedules
4
+ ThecoreSettings::Setting.send(:include, ThecoreBackgroundSettingsConcern)
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ puts "Settings Concern from ThecoreBackgroundJobs"
2
+ require 'active_support/concern'
3
+
4
+ module ThecoreBackgroundSettingsConcern
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ after_save :reload_schedules, if: :saved_change_to_raw?
8
+
9
+ def reload_schedules
10
+ # Reload changes to schedule
11
+ ThecoreBackgroundJobs.update_cron_schedules if self.ns == "schedules" && !self.raw.blank?
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,3 @@
1
- # require 'sidekiq'
2
-
3
- # current_db = rand(1..15)
4
-
5
- # Sidekiq.configure_server do |config|
6
- # config.redis = { :namespace => "#{ENV['COMPOSE_PROJECT_NAME'] || 'notset'}", :url => "#{ENV['REDIS_URL']}/#{current_db}" }
7
- # end
8
- # Sidekiq.configure_client do |config|
9
- # config.redis = { :namespace => "#{ENV['COMPOSE_PROJECT_NAME'] || 'notset'}", :url => "#{ENV['REDIS_URL']}/#{current_db}" }
10
- # end
11
-
12
1
  # Set the default queue name for the analysis job to the queue adapter default.
13
2
  Rails.application.config.active_storage.queues.analysis = "#{ENV['COMPOSE_PROJECT_NAME'] || 'notset'}_storage_analysis"
14
3
 
data/config/routes.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  Rails.application.routes.draw do
2
- require 'sidekiq/web'
3
- require 'sidekiq-scheduler/web'
4
-
5
- # Allow any authenticated User with admin capability
6
- authenticate :user, lambda { |u| u.admin? } do
7
- mount Sidekiq::Web => '/sidekiq'
8
- end
2
+ require 'sidekiq/web'
3
+ require 'sidekiq-scheduler/web'
4
+
5
+ # Allow any authenticated User with admin capability
6
+ authenticate :user, lambda { |u| u.admin? } do
7
+ mount Sidekiq::Web => '/sidekiq'
8
+ end
9
9
  end
@@ -1,15 +1,4 @@
1
- require 'thecore_backend_commons'
2
1
  module ThecoreBackgroundJobs
3
2
  class Engine < ::Rails::Engine
4
-
5
- initializer 'thecore_background_jobs.add_to_migrations' do |app|
6
- unless app.root.to_s.match root.to_s
7
- # APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
8
- config.paths['db/migrate'].expanded.each do |expanded_path|
9
- app.config.paths['db/migrate'] << expanded_path
10
- end
11
- end
12
- end
13
-
14
3
  end
15
4
  end
@@ -1,8 +1,7 @@
1
- require 'thecore_backend_commons'
2
1
  require 'redis-namespace'
3
2
  require 'sidekiq'
4
- require "sidekiq-scheduler"
5
- require "sidekiq-failures"
3
+ require 'sidekiq-scheduler'
4
+ require 'sidekiq-failures'
6
5
  require "thecore_background_jobs/engine"
7
6
 
8
7
  module ThecoreBackgroundJobs
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_background_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: thecore_backend_commons
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: redis-namespace
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +44,14 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '4.0'
47
+ version: '5.0'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '4.0'
54
+ version: '5.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: sidekiq-failures
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,30 +66,33 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '1.0'
83
- description: Thecorized thecore_background_jobs full description.
69
+ description: Adds Background workers functionality and management to Thecore.
84
70
  email:
85
- - gabriele.tassoni@gmail.com
71
+ - g.tassoni@bancolini.com
86
72
  executables: []
87
73
  extensions: []
88
74
  extra_rdoc_files: []
89
75
  files:
90
- - MIT-LICENSE
91
76
  - README.md
92
77
  - Rakefile
93
78
  - app/workers/demo_worker.rb
94
- - config/initializers/after_initialize_for_thecore_backgrond_commons.rb
95
- - config/initializers/sidekiq-thecore.rb
96
- - config/initializers/thecore_background_settings_concern.rb
79
+ - config/initializers/abilities.rb
80
+ - config/initializers/add_to_db_migrations.rb
81
+ - config/initializers/after_initialize.rb
82
+ - config/initializers/concern_thecore_settings.rb
83
+ - config/initializers/queues_config.rb
97
84
  - config/routes.rb
98
- - lib/admin_constraint.rb
99
85
  - lib/tasks/thecore_background_jobs_tasks.rake
100
86
  - lib/thecore_background_jobs.rb
101
87
  - lib/thecore_background_jobs/engine.rb
102
88
  - lib/thecore_background_jobs/version.rb
103
- homepage: https://www.taris.it
104
- licenses:
105
- - MIT
106
- metadata: {}
89
+ homepage: https://github.com/gabrieletassoni/thecore_background_jobs
90
+ licenses: []
91
+ metadata:
92
+ allowed_push_host: https://rubygems.org
93
+ homepage_uri: https://github.com/gabrieletassoni/thecore_background_jobs
94
+ source_code_uri: https://github.com/gabrieletassoni/thecore_background_jobs
95
+ changelog_uri: https://github.com/gabrieletassoni/thecore_background_jobs/blob/master/CHANGELOG.md
107
96
  post_install_message:
108
97
  rdoc_options: []
109
98
  require_paths:
@@ -122,5 +111,5 @@ requirements: []
122
111
  rubygems_version: 3.3.26
123
112
  signing_key:
124
113
  specification_version: 4
125
- summary: Thecorized thecore_background_jobs
114
+ summary: Background workers for Thecore
126
115
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2017 Gabriele Tassoni
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +0,0 @@
1
- Rails.application.configure do
2
- config.after_initialize do
3
- ThecoreBackgroundJobs.update_cron_schedules
4
- # Good place for sending concerns about modules
5
- # i.e.
6
- # ModelName.send(:include, ModelNameConcern)
7
- # - ModelNameConcern can be defined in config/initializers folder in order to be sure it's automatically loaded during engine bootstrap
8
- ThecoreSettings::Setting.send(:include, ThecoreBackgroundSettingsConcern)
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module ThecoreBackgroundSettingsConcern
4
- extend ActiveSupport::Concern
5
- included do
6
- after_save :reload_schedules, if: :saved_change_to_raw?
7
-
8
- def reload_schedules
9
- # Reload changes to schedule
10
- ThecoreBackgroundJobs.update_cron_schedules if self.ns == "schedules" && !self.raw.blank?
11
- end
12
- end
13
- end
@@ -1,7 +0,0 @@
1
- class AdminConstraint
2
- def matches?(request)
3
- return false unless request.session[:user_id]
4
- user = User.find request.session[:user_id]
5
- user && user.admin?
6
- end
7
- end