command_timer 0.0.11 → 0.1.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.
- data/README.md +25 -12
- data/lib/command_timer/command.rb +4 -4
- data/lib/command_timer/runner.rb +5 -4
- data/lib/command_timer/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,21 +1,34 @@
|
|
1
1
|
# CommandTimer
|
2
2
|
|
3
|
-
|
3
|
+
Simple tool to execute commands on schedule. Designed for maintain web applications.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'command_timer'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
7
|
$ gem install command_timer
|
18
8
|
|
19
9
|
## Usage
|
20
10
|
|
21
|
-
|
11
|
+
$ cmdtimer command_config_file
|
12
|
+
|
13
|
+
## Command Config File Sample (YAML)
|
14
|
+
|
15
|
+
command1:
|
16
|
+
description: "stop unicorn"
|
17
|
+
burn_time: "14:00:00"
|
18
|
+
content: |
|
19
|
+
cd /path/to/app/
|
20
|
+
cap unicorn:stop
|
21
|
+
command2:
|
22
|
+
desciption: "deploy"
|
23
|
+
burn_time:
|
24
|
+
content: |
|
25
|
+
cd /path/to/app/
|
26
|
+
cap deploy
|
27
|
+
observer: |
|
28
|
+
cd /path/to/app/
|
29
|
+
cap invoke COMMAND="tail -f /path/to/log/file"
|
30
|
+
|
31
|
+
* burn_time:
|
32
|
+
1. HH:mm:ss - execute commands on time.
|
33
|
+
2. blank - execute commands by user input.
|
34
|
+
3. auto - execute commands after previous command ended.
|
@@ -22,17 +22,17 @@ module CommandTimer
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def echo_command
|
25
|
+
def echo_command(prefix = '')
|
26
26
|
@content.split(';').each do |line|
|
27
|
-
puts ">> #{line.strip.gsub('\\', '')}"
|
27
|
+
puts "#{prefix}>> #{line.strip.gsub('\\', '')}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def run_observer
|
32
|
-
puts "
|
32
|
+
puts "========================================"
|
33
33
|
puts "= Start observer, press <Ctrl-C> to stop it."
|
34
34
|
puts "= #{@observer}"
|
35
|
-
puts "
|
35
|
+
puts "========================================"
|
36
36
|
system @observer
|
37
37
|
puts "Observer stopped."
|
38
38
|
end
|
data/lib/command_timer/runner.rb
CHANGED
@@ -9,10 +9,11 @@ module CommandTimer
|
|
9
9
|
|
10
10
|
def start
|
11
11
|
@commands.each_with_index do |command, index|
|
12
|
-
puts "
|
12
|
+
puts "########################################"
|
13
13
|
puts "# Next: Command#{index + 1}"
|
14
14
|
puts "# #{command.description}" if command.description
|
15
|
-
|
15
|
+
command.echo_command("# ")
|
16
|
+
puts "########################################"
|
16
17
|
if command.burn_time
|
17
18
|
if ['auto', 'Auto'].include?(command.burn_time)
|
18
19
|
command.exec
|
@@ -75,7 +76,7 @@ module CommandTimer
|
|
75
76
|
|
76
77
|
def echo_commands
|
77
78
|
@commands.each_with_index do |command, index|
|
78
|
-
puts "
|
79
|
+
puts "----------------------------------------"
|
79
80
|
puts "Command #{index + 1}"
|
80
81
|
puts command.description if command.description
|
81
82
|
if command.burn_time
|
@@ -86,7 +87,7 @@ module CommandTimer
|
|
86
87
|
command.echo_command
|
87
88
|
puts "Observer: #{command.observer}" if command.observer
|
88
89
|
end
|
89
|
-
puts "
|
90
|
+
puts "----------------------------------------"
|
90
91
|
puts ""
|
91
92
|
end
|
92
93
|
end
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Simple tool to execute commands on schedule
|
15
15
|
email:
|