command_timer 0.1.1 → 0.1.2
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.
- data/README.md +11 -2
- data/Rakefile +12 -2
- data/bin/cmdtimer +8 -6
- data/lib/command_timer/command.rb +0 -1
- data/lib/command_timer/runner.rb +3 -7
- data/lib/command_timer/version.rb +1 -1
- metadata +35 -3
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# CommandTimer
|
2
2
|
|
3
|
+
[](https://travis-ci.org/cctiger36/command_timer) [](http://badge.fury.io/rb/command_timer) [](https://coveralls.io/r/cctiger36/command_timer) [](https://codeclimate.com/github/cctiger36/command_timer)
|
4
|
+
|
3
5
|
Simple tool to execute commands on schedule. Designed for maintain web applications.
|
4
6
|
|
5
7
|
## Installation
|
@@ -8,7 +10,14 @@ Simple tool to execute commands on schedule. Designed for maintain web applicati
|
|
8
10
|
|
9
11
|
## Usage
|
10
12
|
|
11
|
-
$ cmdtimer
|
13
|
+
$ cmdtimer [options] COMMANDS_CONFIG_FILE
|
14
|
+
|
15
|
+
### Options
|
16
|
+
|
17
|
+
<table>
|
18
|
+
<tr><td>-c, --count-down</td><td>Assign the seconds to count down. (default 30s)</td></tr>
|
19
|
+
<tr><td>-s, --ntp-server</td><td>Assign the NTP server. (only ntp installed)</td></tr>
|
20
|
+
</table>
|
12
21
|
|
13
22
|
## Config File Sample (YAML)
|
14
23
|
|
@@ -19,7 +28,7 @@ Simple tool to execute commands on schedule. Designed for maintain web applicati
|
|
19
28
|
cd /path/to/app/
|
20
29
|
cap unicorn:stop
|
21
30
|
command2:
|
22
|
-
|
31
|
+
description: "deploy"
|
23
32
|
burn_time:
|
24
33
|
content: |
|
25
34
|
cd /path/to/app/
|
data/Rakefile
CHANGED
@@ -1,2 +1,12 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
desc 'Default: run specs'
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
RSpec::Core::RakeTask.new do |t|
|
9
|
+
t.pattern = "spec/**/*_spec.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
Bundler::GemHelper.install_tasks
|
data/bin/cmdtimer
CHANGED
@@ -7,18 +7,20 @@ require "command_timer"
|
|
7
7
|
|
8
8
|
options = {}
|
9
9
|
opts = OptionParser.new do |opts|
|
10
|
-
opts.
|
11
|
-
puts "command_timer " + CommandTimer::VERSION
|
12
|
-
exit 0
|
13
|
-
end
|
10
|
+
opts.banner = "Usage: cmdtimer [options] COMMANDS_CONFIG_FILE"
|
14
11
|
|
15
|
-
opts.on("-c
|
12
|
+
opts.on("-c", "--count-down", "Assign the seconds to count down. (default 30s)") do |count_down|
|
16
13
|
options['count_down'] = count_down.to_i
|
17
14
|
end
|
18
15
|
|
19
|
-
opts.on("-s
|
16
|
+
opts.on("-s", "--ntp-server", "Assign the NTP server. (only ntp installed)") do |ntp_server|
|
20
17
|
options['ntp_server'] = ntp_server
|
21
18
|
end
|
19
|
+
|
20
|
+
opts.on("-v", "--version", "Display the current version") do
|
21
|
+
puts "command_timer " + CommandTimer::VERSION
|
22
|
+
exit 0
|
23
|
+
end
|
22
24
|
end
|
23
25
|
opts.parse!
|
24
26
|
|
data/lib/command_timer/runner.rb
CHANGED
@@ -15,7 +15,7 @@ module CommandTimer
|
|
15
15
|
command.echo_command("# ")
|
16
16
|
puts "########################################"
|
17
17
|
if command.burn_time
|
18
|
-
if
|
18
|
+
if command.burn_time =~ /^auto$/i
|
19
19
|
command.exec
|
20
20
|
else
|
21
21
|
count_down_and_burn_command(command)
|
@@ -37,15 +37,11 @@ module CommandTimer
|
|
37
37
|
return
|
38
38
|
end
|
39
39
|
loop do
|
40
|
-
|
41
|
-
|
42
|
-
left_sec = command.burn_time.to_i - current_time.to_i
|
43
|
-
puts "Time resynced."
|
44
|
-
else
|
40
|
+
puts "[#{current_time}] Next command will be executed at [#{command.burn_time}] (#{left_sec} seconds left)."
|
41
|
+
if left_sec <= @count_down
|
45
42
|
current_time += 1
|
46
43
|
left_sec -= 1
|
47
44
|
end
|
48
|
-
puts "[#{current_time}] Next command will be executed at [#{command.burn_time}] (#{left_sec} seconds left)."
|
49
45
|
if left_sec < 1
|
50
46
|
break
|
51
47
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-06-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
description: Simple tool to execute commands on schedule. Designed for maintain web
|
15
47
|
applications.
|
16
48
|
email:
|