tomo-plugin-cron 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ce0e8e3cee317a6f7e4d6d4f004f096a3e11ddc2187cf83b52f1dce14c690eb
4
+ data.tar.gz: b12c9fb55f60b54b805eaba56aea2f1587763d49b10c547eee44e4f46993594b
5
+ SHA512:
6
+ metadata.gz: 5b4b8387407daf654e28b6740f01c48bdcaf5b10fc2588b9c13842f377b347bf245b1439c4dfcb24b43196d6262f2cc513fc4fda66f01c65fa8917a672c2b617
7
+ data.tar.gz: 619d83c42272b5a539f783a795a8350e1b91fa17fa2d0839cac8ab2ed03d9e9f5e3676d91db1a73b95c7eea59ba73fb142dee5efd0d5cc65c66fa0be8359b396
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Muhammad Usman
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,82 @@
1
+ # tomo-plugin-cron
2
+
3
+ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/uxxman/tomo-plugin-cron/CI)](https://github.com/uxxman/tomo-plugin-cron/actions?query=workflow%3ACI)
4
+ [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/uxxman/tomo-plugin-cron)](https://codeclimate.com/github/uxxman/tomo-plugin-cron)
5
+ [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/uxxman/tomo-plugin-cron)](https://codeclimate.com/github/uxxman/tomo-plugin-cron)
6
+ [![Gem](https://img.shields.io/gem/v/tomo-plugin-cron)](https://rubygems.org/gems/tomo-plugin-cron)
7
+
8
+ This is a [tomo](https://github.com/mattbrictson/tomo) plugin that provides tasks for managing cron jobs using ruby DSL provided by the awesome [whenever](https://github.com/javan/whenever) gem.
9
+
10
+ ## Installation
11
+
12
+ Run:
13
+
14
+ ```
15
+ $ gem install tomo-plugin-cron
16
+ ```
17
+
18
+ Or add it to your Gemfile:
19
+
20
+ ```ruby
21
+ gem "tomo-plugin-cron"
22
+ ```
23
+
24
+ Then add the following to `.tomo/config.rb`:
25
+
26
+ ```ruby
27
+ plugin "cron"
28
+ ```
29
+
30
+ Now, create a file **schedule.rb** alongside your tomo config file and start writing cron jobs in ruby.
31
+
32
+ ```ruby
33
+ # .tomo/schedule.rb
34
+
35
+ every 3.hours do
36
+ rake "my:rake:task"
37
+ runner "MyModel.some_process"
38
+ command "/usr/bin/my_great_command"
39
+ end
40
+
41
+ every 1.day, at: '4:30 am' do
42
+ runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
43
+ end
44
+ ```
45
+ For more examples, checkout out [whenever](https://github.com/javan/whenever#example-schedulerb-file) gem readme.
46
+
47
+
48
+ ## Settings
49
+
50
+ | Name | Required | Purpose | Default |
51
+ | --------------------- | -------- | ------- | ------- |
52
+ | `cron_schedule_path` | No | Schedule file location | `.tomo/schedule.rb` |
53
+
54
+ ## Tasks
55
+
56
+ ### cron:show
57
+
58
+ Print out current content of crontab.
59
+
60
+ ### cron:install
61
+
62
+ Translate schedules defined inside your **schedule.rb** file into cron syntax and write them to your host's crontab.
63
+
64
+ ### cron:uninstall
65
+
66
+ Delete host's crontab.
67
+
68
+ ## Support
69
+
70
+ If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/uxxman/tomo-plugin-cron/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
71
+
72
+ ## License
73
+
74
+ The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
75
+
76
+ ## Code of conduct
77
+
78
+ Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
79
+
80
+ ## Contribution guide
81
+
82
+ Pull requests are welcome!
@@ -0,0 +1,15 @@
1
+ require "tomo"
2
+ require_relative "cron/tasks"
3
+ require_relative "cron/version"
4
+
5
+ module Tomo
6
+ module Plugin
7
+ module Cron
8
+ extend Tomo::PluginDSL
9
+
10
+ defaults cron_schedule_path: ".tomo/schedule.rb"
11
+
12
+ tasks Tomo::Plugin::Cron::Tasks
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ require "whenever"
2
+
3
+ module Tomo::Plugin::Cron
4
+ class Tasks < Tomo::TaskLibrary
5
+ def show
6
+ remote.run "crontab -l", raise_on_error: false
7
+ end
8
+
9
+ def install
10
+ require_setting :cron_schedule_path
11
+
12
+ crontab = Whenever.cron(whenever_options)
13
+
14
+ remote.run "echo #{crontab.shellescape} | crontab -"
15
+ end
16
+
17
+ def uninstall
18
+ remote.run "crontab -r"
19
+ end
20
+
21
+ private
22
+
23
+ def whenever_options
24
+ {}.tap do |options|
25
+ options[:file] = settings[:cron_schedule_path]
26
+ options[:set] = "path=#{paths.current}"
27
+ options[:set] += "&environment=#{settings.dig(:env_vars, :RAILS_ENV) || 'production'}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module Tomo
2
+ module Plugin
3
+ module Cron
4
+ VERSION = "0.1.0".freeze
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tomo-plugin-cron
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Muhammad Usman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tomo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: whenever
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description:
42
+ email:
43
+ - uxman.sherwani@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - lib/tomo/plugin/cron.rb
51
+ - lib/tomo/plugin/cron/tasks.rb
52
+ - lib/tomo/plugin/cron/version.rb
53
+ homepage: https://github.com/uxxman/tomo-plugin-cron
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ bug_tracker_uri: https://github.com/uxxman/tomo-plugin-cron/issues
58
+ changelog_uri: https://github.com/uxxman/tomo-plugin-cron/releases
59
+ source_code_uri: https://github.com/uxxman/tomo-plugin-cron
60
+ homepage_uri: https://github.com/uxxman/tomo-plugin-cron
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.5.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.1.4
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: cron tasks for tomo
80
+ test_files: []