zfben_rails_rake 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -14
- data/lib/zfben_rails_rake/tasks/git.rb +11 -1
- data/lib/zfben_rails_rake/tasks/helper.rb +1 -0
- data/lib/zfben_rails_rake/tasks/unicorn.rb +16 -4
- data/lib/zfben_rails_rake/version.rb +1 -1
- data/lib/zfben_rails_rake.rb +7 -1
- metadata +2 -4
- data/lib/zfben_rails_rake/railtie.rb +0 -13
- data/lib/zfben_rails_rake/tasks/clear.rb +0 -24
data/README.rdoc
CHANGED
@@ -2,21 +2,18 @@
|
|
2
2
|
|
3
3
|
This is plugin to add some useful tasks to rails.
|
4
4
|
|
5
|
-
rake clear
|
6
|
-
rake
|
7
|
-
rake
|
8
|
-
rake
|
9
|
-
|
10
|
-
|
11
|
-
rake
|
12
|
-
rake
|
13
|
-
rake
|
14
|
-
|
15
|
-
rake unicorn:restart[env,config] # restart server
|
16
|
-
rake unicorn:start[env,config] # start server
|
17
|
-
rake unicorn:stop # stop server
|
5
|
+
rake git:clear # clear files in .gitignore
|
6
|
+
rake git:commit[comment] # git commit with your comment
|
7
|
+
rake git:pull # git pull
|
8
|
+
rake git:push[comment] # git push with your comment
|
9
|
+
rake git:copy # copy .gitignore to rails root path
|
10
|
+
|
11
|
+
rake unicorn:copy[processes,port] # copy unicorn.rb to root path
|
12
|
+
rake unicorn:restart[env,config] # restart server
|
13
|
+
rake unicorn:start[env,config] # start server
|
14
|
+
rake unicorn:stop # stop server
|
18
15
|
|
19
|
-
rake log:analytics
|
16
|
+
rake log:analytics # analytics log file
|
20
17
|
|
21
18
|
== Getting Started
|
22
19
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
namespace
|
1
|
+
namespace :git do
|
2
2
|
desc 'git pull'
|
3
3
|
task :pull do
|
4
4
|
sys 'git pull'
|
@@ -21,4 +21,14 @@ namespace 'git' do
|
|
21
21
|
task :copy do
|
22
22
|
sys 'cp ' << File.join(ZfbenRailsRakePath, 'static', '.gitignore') << ' ' << Rails.root.to_s
|
23
23
|
end
|
24
|
+
|
25
|
+
desc 'clear files in .gitignore'
|
26
|
+
task :clear do
|
27
|
+
path = File.join(Rails.root, '.gitignore')
|
28
|
+
unless File.exists? path
|
29
|
+
err '.gitignore is not exists! Please run `rake git:copy` first'
|
30
|
+
else
|
31
|
+
sys 'git clean -dfX'
|
32
|
+
end
|
33
|
+
end
|
24
34
|
end
|
@@ -1,18 +1,30 @@
|
|
1
|
-
namespace
|
1
|
+
namespace :unicorn do
|
2
2
|
desc 'start server'
|
3
3
|
task :start, [:env, :config] do |task, args|
|
4
4
|
args = { :env => 'development', :config => 'unicorn.rb' }.merge args.to_hash
|
5
5
|
cmd = 'unicorn_rails'
|
6
|
-
cmd << ' -c ' << args[:config] if
|
7
|
-
cmd << ' -E ' << args[:env]
|
6
|
+
cmd << ' -c ' << args[:config] if File.exists?(File.join(Rails.root, args[:config]))
|
7
|
+
cmd << ' -E ' << args[:env]
|
8
8
|
sys cmd << ' -D'
|
9
9
|
end
|
10
10
|
|
11
11
|
desc 'stop server'
|
12
12
|
task :stop do
|
13
|
-
sys 'kill -QUIT `cat tmp/unicorn.pid`' if File.exists? File.join(Rails.root, 'tmp
|
13
|
+
sys 'kill -QUIT `cat tmp/unicorn.pid`' if File.exists? File.join(Rails.root, 'tmp', 'unicorn.pid')
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'restart server'
|
17
17
|
task :restart, [:env, :config] => [:stop, :start]
|
18
|
+
|
19
|
+
desc 'copy unicorn.rb to root path'
|
20
|
+
task :copy, [:processes, :port] do |task, args|
|
21
|
+
path = File.join(Rails.root, 'unicorn.rb')
|
22
|
+
if File.exists? path
|
23
|
+
err 'unicorn.rb is exists! Please remove it and run again.'
|
24
|
+
else
|
25
|
+
args = { :processes => 1, :port => 8080 }.merge args.to_hash
|
26
|
+
p file = "# Added by zfben_rails_rake\nworker_processes #{args[:processes]}\nlisten #{args[:port]}, :tcp_nopush => true, :tcp_nodelay => true\npid 'tmp/unicorn.pid'\n# End zfben_rails_rake"
|
27
|
+
File.open(path, 'w'){ |f| f.write file }
|
28
|
+
end
|
29
|
+
end
|
18
30
|
end
|
data/lib/zfben_rails_rake.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
ZfbenRailsRakePath = File.join File.dirname(__FILE__), 'zfben_rails_rake'
|
2
2
|
|
3
3
|
module ZfbenRailsRake
|
4
|
-
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
railtie_name :zfben_rails_rake
|
6
|
+
|
7
|
+
rake_tasks do
|
8
|
+
Dir[File.join(ZfbenRailsRakePath, 'tasks', '*')].each{ |f| load f }
|
9
|
+
end
|
10
|
+
end
|
5
11
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: zfben_rails_rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-09 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|
@@ -60,9 +60,7 @@ files:
|
|
60
60
|
- README.rdoc
|
61
61
|
- Rakefile
|
62
62
|
- lib/zfben_rails_rake.rb
|
63
|
-
- lib/zfben_rails_rake/railtie.rb
|
64
63
|
- lib/zfben_rails_rake/static/.gitignore
|
65
|
-
- lib/zfben_rails_rake/tasks/clear.rb
|
66
64
|
- lib/zfben_rails_rake/tasks/git.rb
|
67
65
|
- lib/zfben_rails_rake/tasks/helper.rb
|
68
66
|
- lib/zfben_rails_rake/tasks/log.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'zfben_rails_rake'
|
3
|
-
require 'rails'
|
4
|
-
require 'rainbow'
|
5
|
-
module ZfbenRailsRake
|
6
|
-
class Railtie < Rails::Railtie
|
7
|
-
railtie_name :zfben_rails_rake
|
8
|
-
|
9
|
-
rake_tasks do
|
10
|
-
Dir[File.join(ZfbenRailsRakePath, 'tasks', '*')].each{ |f| load f }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
namespace :clear do
|
2
|
-
desc 'clear log folder'
|
3
|
-
task :log do
|
4
|
-
path = File.join(Rails.root, 'log', '*')
|
5
|
-
sys 'rm -r ' << path if Dir[path].length > 0
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'clear tmp folder'
|
9
|
-
task :tmp do
|
10
|
-
path = File.join(Rails.root, 'tmp', '*')
|
11
|
-
sys 'rm -r ' << path if Dir[path].length > 0
|
12
|
-
end
|
13
|
-
|
14
|
-
desc 'clear public folder'
|
15
|
-
task :public do
|
16
|
-
['assets', 'caches'].each do |f|
|
17
|
-
path = File.join(Rails.root, 'public', f)
|
18
|
-
sys 'rm -r ' << path if File.exists? path
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
desc 'clear all'
|
23
|
-
task :all => [:log, :tmp, :public]
|
24
|
-
end
|