croner 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4ee7d165e363c332bd9ffeee30909defbc313e5
4
- data.tar.gz: 9ff96e3cfb03d55457e843099131323a58c585d0
3
+ metadata.gz: 9d7450c7f6c94d41f65897bbd9491d1ab909e40c
4
+ data.tar.gz: 17a15b5b8ea604e50a81c66d9060462db8885692
5
5
  SHA512:
6
- metadata.gz: e52e11c08554aac34bf2240ba1009bab7389feccf7babf175dfb7873416826399615c28161af99d2be3967634a70238cc6e960aff37f04e5d7d0e3a3893eeb3d
7
- data.tar.gz: 10f437b63132f964e2d6ab1bc16487443b005de61a369e7fe520d4a0bb954c6ff0f9805203a01f830777a80e47d20e0e5c4500d473d6674f98e11d59fd40cb8d
6
+ metadata.gz: a06ebef4e8c31bfb8b6fea9f8da6d34a00e7fcd7ab255e08492caf618ab22cf5a5bcd4ab24f6c281d34de99bf037a203442fea7dce505ae08c028d73c21d1b2b
7
+ data.tar.gz: 156c0dc859b84e6582ecbcf6153456cf4ce276a1cfd69a9bd12246173e693ccc191a9dc3f137de4743100131e3e69166db9f40b770b3aaf9a968f2ba4cded7f3
data/README.md CHANGED
@@ -15,9 +15,32 @@ And then execute:
15
15
  $ bundle
16
16
  ```
17
17
 
18
+ And then run initial settings:
19
+ ```bash
20
+ $ rails g croner:install
21
+ ```
22
+
23
+ ## Configure
24
+ Edit the `/config/initializers/croner.rb` file and customize following settings.
25
+ #### enable_backup
26
+ Settings that save backup file.
27
+ #### backup_path
28
+ Backup file's path.
29
+
18
30
  ## Usage
19
31
  Make `config/croner/hosts/[hostname]` and run task `croner:update`.
20
32
 
33
+ ## Capistrano integration
34
+ In your `config/deploy.rb` or `Capfile` file:
35
+ ```rb
36
+ require "croner/capistrano"
37
+ ```
38
+
39
+ And if you want to change role, append your `config/deploy.rb` file:
40
+ ```rb
41
+ croner_roles %w(web db)
42
+ ```
43
+
21
44
  ## License
22
45
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
23
46
 
@@ -0,0 +1,6 @@
1
+ module Croner
2
+ class Config
3
+ # Variables detail is writen in lib/generators/templates/croner.rb.
4
+ attr_accessor :backup_path
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ require 'croner/config'
2
+
3
+ module Croner
4
+ def self.config
5
+ @config ||= Croner::Config.new
6
+ end
7
+
8
+ def self.configure(&block)
9
+ yield(config) if block_given?
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Croner
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/croner.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'croner/engine'
1
2
  require 'croner/railtie'
2
3
 
3
4
  module Croner
@@ -10,7 +11,13 @@ module Croner
10
11
  insert_rows = File.read(Rails.root.join('config', 'croner', 'hosts', `hostname`.delete("\n"))).split("\n")
11
12
 
12
13
  # backup current cron contents
13
- `crontab -l > cron_#{Time.current.strftime('%Y%m%d%H%M%S')}.bak`
14
+ if Croner.config.enable_backup
15
+ if Croner.config.backup_path.blank?
16
+ `crontab -l > ./cron_#{Time.current.strftime('%Y%m%d%H%M%S')}.bak`
17
+ else
18
+ `crontab -l > ./#{Croner.config.backup_path}/cron_#{Time.current.strftime('%Y%m%d%H%M%S')}.bak`
19
+ end
20
+ end
14
21
 
15
22
  # get current cron contents
16
23
  cron_rows = `crontab -l`.split("\n")
@@ -0,0 +1,13 @@
1
+ module Croner
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates a Croner initializer to your application."
7
+
8
+ def copy_initializer
9
+ template "croner.rb", "config/initializers/croner.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ Croner.configure do |config|
2
+ # enable Backup
3
+ config.enable_backup = true
4
+
5
+ # Backup path
6
+ config.backup_path = ""
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: croner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ykogure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2017-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 3.2.22
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 3.2.22
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -51,8 +51,12 @@ files:
51
51
  - lib/croner.rb
52
52
  - lib/croner/capistrano.rb
53
53
  - lib/croner/capistrano/croner.rake
54
+ - lib/croner/config.rb
55
+ - lib/croner/engine.rb
54
56
  - lib/croner/railtie.rb
55
57
  - lib/croner/version.rb
58
+ - lib/generators/croner/install_generator.rb
59
+ - lib/generators/templates/croner.rb
56
60
  - lib/tasks/croner_tasks.rake
57
61
  homepage: https://github.com/ZIGExN/croner
58
62
  licenses: