thor_tasks 0.0.3 → 0.0.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.
- data/README.rdoc +14 -2
- data/lib/tasks/mongo.thor +39 -0
- data/lib/thor_tasks/version.rb +1 -1
- data/spec/tasks/mongo.thor_spec.rb +7 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -41,5 +41,17 @@ spec files. For the spec:view task, you can specify a controller, and an action.
|
|
41
41
|
If you specify a controller without an action, all the actions for that view
|
42
42
|
will run.
|
43
43
|
|
44
|
-
|
45
|
-
bundle
|
44
|
+
To run your specs with `bundle exec', use the bundle option. For example:
|
45
|
+
thor spec:all --bundle
|
46
|
+
or, you can use the abbreviated option:
|
47
|
+
thor spec:all -b
|
48
|
+
|
49
|
+
== Mongo tasks
|
50
|
+
|
51
|
+
These tasks allow you to start, stop, and restart MongoDB as a background
|
52
|
+
process on a Linux box. It might work on OS X, but hasn't been tested, yet.
|
53
|
+
|
54
|
+
The tasks are:
|
55
|
+
thor mongo:start
|
56
|
+
thor mongo:restart
|
57
|
+
thor mongo:stop
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Mongo < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
desc "start", "starts mongodb"
|
5
|
+
def start
|
6
|
+
if mongod_pid.nil?
|
7
|
+
puts "Starting MongoDB . . ."
|
8
|
+
run 'sudo mongod --dbpath /var/lib/mongodb --fork --logpath /var/log/mongodb.log --logappend'
|
9
|
+
else
|
10
|
+
puts "MongoDB is already running!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "stop", "stops mongodb"
|
15
|
+
def stop
|
16
|
+
if mongod_pid.nil?
|
17
|
+
puts "Could not find MongoDB process id. Is it running?"
|
18
|
+
else
|
19
|
+
puts "Stopping MongoDB . . ."
|
20
|
+
Process.kill(:TERM, mongod_pid.to_i)
|
21
|
+
sleep(0.5)
|
22
|
+
puts mongod_pid.nil? ? "Done." : "Could not end MongoDB process!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "restart", "restarts mongodb"
|
27
|
+
def restart
|
28
|
+
invoke :stop
|
29
|
+
sleep(0.5) # allow a little time for process to end
|
30
|
+
invoke :start
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def mongod_pid
|
36
|
+
`pidof mongod`.split("\n").first
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/thor_tasks/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Haynes
|
@@ -32,11 +32,13 @@ files:
|
|
32
32
|
- Gemfile
|
33
33
|
- README.rdoc
|
34
34
|
- Rakefile
|
35
|
+
- lib/tasks/mongo.thor
|
35
36
|
- lib/tasks/spec.thor
|
36
37
|
- lib/tasks/spork.thor
|
37
38
|
- lib/thor_tasks.rb
|
38
39
|
- lib/thor_tasks/version.rb
|
39
40
|
- spec/spec_helper.rb
|
41
|
+
- spec/tasks/mongo.thor_spec.rb
|
40
42
|
- spec/tasks/spec.thor_spec.rb
|
41
43
|
- spec/tasks/spork.thor_spec.rb
|
42
44
|
- thor_tasks.gemspec
|