ro_rmt 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +91 -0
- data/conf/ro_rmt.rb +203 -0
- data/conf/rsync/exclude_patterns +4 -0
- data/conf/rsync/include_patterns +10 -0
- data/lib/ro_cell/rmt.rb +254 -0
- data/lib/ro_cell/rmt/dir.rb +55 -0
- data/lib/ro_cell/rmt/file.rb +96 -0
- data/lib/ro_cell/rmt/opts.rb +21 -0
- data/lib/ro_cell/rmt/se_mgr.rb +51 -0
- data/lib/ro_cell/tmp/ro.log +49 -0
- data/lib/ro_cmd/ci.rb +32 -0
- data/lib/ro_cmd/rmt_base.rb +132 -0
- data/lib/ro_cmd/rmt_rspec.rb +26 -0
- data/lib/ro_helper/dp.rb +20 -0
- data/lib/ro_helper/rmt/basic.rb +441 -0
- data/lib/ro_helper/rmt/compress.rb +31 -0
- data/lib/ro_helper/rmt/determinations.rb +25 -0
- data/lib/ro_helper/rmt/dir.rb +11 -0
- data/lib/ro_helper/rmt/file.rb +13 -0
- data/lib/ro_helper/rmt/file_dir.rb +60 -0
- data/lib/ro_helper/rmt/process.rb +46 -0
- data/lib/ro_helper/rmt/rb.rb +131 -0
- data/lib/ro_helper/rmt/scp.rb +117 -0
- data/lib/ro_helper/rmt/se_attrs.rb +28 -0
- data/lib/ro_rmt.rb +9 -0
- data/lib/ro_rmt_ro_cmds_bin.rb +4 -0
- data/lib/ro_rspec_helper/rmt_rspec_helper.rb +82 -0
- data/lib/ro_script/kill_port.rb +49 -0
- data/lib/ro_script/pgrep.rb +44 -0
- data/lib/ro_script/pkill.rb +51 -0
- data/lib/ro_script/try.rb +0 -0
- data/lib/tts/nginx.conf.erb +148 -0
- data/spec/fixtures/ro_bin_helper/Gemfile +2 -0
- data/spec/fixtures/ro_bin_helper/gem1/lib/ro_cmd/cmd1.rb +0 -0
- data/spec/fixtures/ro_bin_helper/gem1/lib/ro_cmd/cmd2.rb +0 -0
- data/spec/fixtures/ro_bin_helper/gem2/lib/ro_cmd/cmd1.rb +0 -0
- data/spec/fixtures/ro_bin_helper/gem2/lib/ro_cmd/cmd2.rb +0 -0
- data/spec/fixtures/scp/log/scp_rspec_err.log +216 -0
- data/spec/fixtures/scp/tmp/ro.log +110 -0
- data/spec/fixtures/scp/tmp/ro_cell__pl__sv__st_event.log +7 -0
- data/spec/fixtures/scp/tmp/roroco/at/localhost/home/roroco/try/try_ro_rmt.rb +1 -0
- data/spec/fixtures/se_mgr/log/se_mgr_rspec_err.log +207 -0
- data/spec/fixtures/se_mgr/tmp/ro.log +1194 -0
- data/spec/fixtures/se_mgr/tmp/ro_cell__pl__sv__st_event.log +7 -0
- data/spec/helpers/articles_helper_spec.rb +15 -0
- data/spec/lib/ro_cell/rmt/dir_spec.rb +22 -0
- data/spec/lib/ro_cell/rmt/file_spec.rb +32 -0
- data/spec/lib/ro_cell/rmt/se_mgr_spec.rb +33 -0
- data/spec/lib/ro_cell/rmt_spec.rb +113 -0
- data/spec/lib/ro_dp/cap_spec.rb +34 -0
- data/spec/lib/ro_dp/rbenv_spec.rb +10 -0
- data/spec/lib/ro_dp/system_spec.rb +31 -0
- data/spec/lib/ro_helper/rmt/basic_spec.rb +41 -0
- data/spec/lib/ro_helper/rmt/cf_spec.rb +17 -0
- data/spec/lib/ro_helper/rmt/determinations_spec.rb +11 -0
- data/spec/lib/ro_helper/rmt/dir_spec.rb +15 -0
- data/spec/lib/ro_helper/rmt/file_dir_helper_spec.rb +11 -0
- data/spec/lib/ro_helper/rmt/file_spec.rb +23 -0
- data/spec/lib/ro_helper/rmt/process_spec.rb +29 -0
- data/spec/lib/ro_helper/rmt/rb_spec.rb +13 -0
- data/spec/lib/ro_helper/rmt/scp_spec.rb +21 -0
- data/spec/lib/ro_script/pgrep_spec.rb +18 -0
- data/spec/lib/ro_sv_try/1.rb +0 -0
- data/spec/lib/ro_sv_try/2.rb +0 -0
- data/spec/lib/ro_sv_try/3.rb +0 -0
- data/spec/lib/ro_sv_try/tmp/rspec_guard_result +9 -0
- data/spec/rails_helper.rb +1 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/wio_spork.rb +10 -0
- metadata +177 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path("../../../../conf/ro_rmt", __FILE__)
|
2
|
+
require_relative 'file'
|
3
|
+
require 'out'
|
4
|
+
|
5
|
+
module RoCell
|
6
|
+
class Rmt
|
7
|
+
class Dir < File
|
8
|
+
def type(*args, &blk)
|
9
|
+
"dir"
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(*args, &blk)
|
13
|
+
eval <<-CONTENT
|
14
|
+
unless test(?d, '#{path}')
|
15
|
+
system 'mkdir -p #{path}'
|
16
|
+
end
|
17
|
+
CONTENT
|
18
|
+
end
|
19
|
+
|
20
|
+
def files(*args, &blk)
|
21
|
+
file_paths = eval "Dir['#{path}/**']"
|
22
|
+
fs = file_paths.map do |file_path|
|
23
|
+
::RoCell::Rmt::File.new(file_path)
|
24
|
+
end
|
25
|
+
fs
|
26
|
+
end
|
27
|
+
|
28
|
+
def exist?(*args, &blk)
|
29
|
+
eval <<-CONTENT
|
30
|
+
|
31
|
+
test(?d, '#{path}')
|
32
|
+
CONTENT
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def rm(*args, &blk)
|
37
|
+
args, opts = args.ro_opts
|
38
|
+
if opts[:force]
|
39
|
+
eval "FileUtils.rm_rf '#{path}'"
|
40
|
+
else
|
41
|
+
eval <<-CONTENT
|
42
|
+
if test(?d, '#{path}')
|
43
|
+
FileUtils.rm_r '#{path}'
|
44
|
+
end
|
45
|
+
CONTENT
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def ls(*args, &blk)
|
50
|
+
files = eval "Dir[File.join('#{path}','**')]"
|
51
|
+
Out.out files
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.expand_path("../../../../conf/ro_rmt", __FILE__)
|
2
|
+
require 'ro_helper/misc'
|
3
|
+
require 'ro_helper/rmt/basic'
|
4
|
+
require 'ro_core_ext/array'
|
5
|
+
require 'ro_core_ext/kernel'
|
6
|
+
require 'ro_file'
|
7
|
+
require 'ro_helper/rmt/se_attrs'
|
8
|
+
require 'ro_file'
|
9
|
+
|
10
|
+
module RoCell
|
11
|
+
class Rmt
|
12
|
+
class File
|
13
|
+
attr_accessor :path
|
14
|
+
|
15
|
+
include ::RoHelper::Rmt::Basic
|
16
|
+
|
17
|
+
def initialize(*args, &blk)
|
18
|
+
args, opts = args.ro_opts
|
19
|
+
@se = opts[:se] || se_mgr.cur_se
|
20
|
+
path = RoFile.join *args, &blk
|
21
|
+
@path = format_path(path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def append(ctn, *args, &blk)
|
25
|
+
tmply_down(path) do |to_local_tmp_path|
|
26
|
+
RoFile.append(to_local_tmp_path, ctn)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(*args, &blk)
|
31
|
+
up lc_tmp, path
|
32
|
+
end
|
33
|
+
|
34
|
+
def lc_tmp(*args, &blk)
|
35
|
+
super(path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def cp(to, *args, &blk)
|
39
|
+
pd = RoFile.parent(to)
|
40
|
+
bash "mkdir -p #{pd}; cp -r #{path} #{to}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def rm(*args, &blk)
|
44
|
+
args, opts = args.ro_opts
|
45
|
+
if opts[:force]
|
46
|
+
eval "FileUtils.rm_f '#{path}'"
|
47
|
+
else
|
48
|
+
eval "FileUtils.rm '#{path}'"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def read(*args, &blk)
|
53
|
+
if exist?(path)
|
54
|
+
RoFile.read down_to_tmp(path)
|
55
|
+
else
|
56
|
+
raise ::RoErr::NotExist, "#{user_at_host}:#{path} is not exist"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def type(*args, &blk)
|
61
|
+
"file"
|
62
|
+
end
|
63
|
+
|
64
|
+
def exist?(*args, &blk)
|
65
|
+
eval "test(?f, '#{path}')"
|
66
|
+
end
|
67
|
+
|
68
|
+
def write(ctn=nil, *args, &blk)
|
69
|
+
ctn ||= ''
|
70
|
+
RoFile.write(lc_tmp, ctn)
|
71
|
+
up lc_tmp, path
|
72
|
+
end
|
73
|
+
|
74
|
+
def blank?
|
75
|
+
read.blank?
|
76
|
+
end
|
77
|
+
|
78
|
+
def has_ctn?(*args, &blk)
|
79
|
+
if args.empty?
|
80
|
+
!blank?
|
81
|
+
else
|
82
|
+
read.match(*args, &blk)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def replace(from, to, *args, &blk)
|
87
|
+
ctn = read(path).gsub(from, to)
|
88
|
+
write(ctn)
|
89
|
+
end
|
90
|
+
|
91
|
+
def size?
|
92
|
+
!blank?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ro_helper/misc'
|
2
|
+
module RoCell
|
3
|
+
class Rmt
|
4
|
+
class Opts
|
5
|
+
class << self
|
6
|
+
include ::RoHelper::Misc
|
7
|
+
|
8
|
+
def shutup
|
9
|
+
@shutup ||= nil
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_writer :ignore_err
|
13
|
+
|
14
|
+
def ignore_err
|
15
|
+
@ignore_err ||= nil
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path("../../../../conf/ro_rmt", __FILE__)
|
2
|
+
require 'ro_core_ext/array'
|
3
|
+
require 'ro_cell/abstract_coll_mgr'
|
4
|
+
module RoCell
|
5
|
+
class Rmt
|
6
|
+
class SeMgr < AbstractCollMgr
|
7
|
+
class << self
|
8
|
+
def register(se, *args, &blk)
|
9
|
+
se_coll.add(se, *args, &blk)
|
10
|
+
@cur_se = se
|
11
|
+
end
|
12
|
+
|
13
|
+
def se_coll
|
14
|
+
@all_se ||= openstructs do |_all_se|
|
15
|
+
_all_se.ro_uniq do |se, another_se|
|
16
|
+
[:user_at_host, :inited_at].all? do |meth_name|
|
17
|
+
se.send(:"#{meth_name}") == another_se.send(:"#{meth_name}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
_all_se.hits
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear(*args, &blk)
|
25
|
+
se_coll.each do |se|
|
26
|
+
unless se.closed?
|
27
|
+
se.close
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
se_coll.clear
|
32
|
+
end
|
33
|
+
|
34
|
+
def registered?(_user_at_host, *args, &blk)
|
35
|
+
se_coll.include?(_user_at_host)
|
36
|
+
end
|
37
|
+
|
38
|
+
def se(*args, &blk)
|
39
|
+
r = se_coll.get(*args, &blk).first.val
|
40
|
+
r
|
41
|
+
end
|
42
|
+
|
43
|
+
def cur_se
|
44
|
+
@cur_se ||= lambda do
|
45
|
+
raise ::RoErr::NotSet, "#{self}.#{__method__} is not set, please use `RoCell::Rmt.new('username@hostname')` at least once"
|
46
|
+
end.call
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
2014-07-09 12:09:59 - 12:09:59: [32m[1mRequiring [0m[0m [34m[1mhelper in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb[0m[0m
|
2
|
+
2014-07-09 12:09:59 - 12:09:59: [32m[1mRequiring [0m[0m [34m[1mins_vars in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb[0m[0m
|
3
|
+
2014-07-09 12:09:59 - 12:09:59: [32m[1mRequiring [0m[0m [34m[1mhelp in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb[0m[0m
|
4
|
+
2014-07-09 12:22:42 - 12:22:42: [32m[1mRequiring [0m[0m [34m[1mhelper in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb[0m[0m
|
5
|
+
2014-07-09 12:22:42 - 12:22:42: [32m[1mRequiring [0m[0m [34m[1mins_vars in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb[0m[0m
|
6
|
+
2014-07-09 12:22:42 - 12:22:42: [32m[1mRequiring [0m[0m [34m[1mhelp in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb[0m[0m
|
7
|
+
2014-07-09 12:22:47 - 12:22:47: [32m[1mRequiring [0m[0m [34m[1mhelper in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb[0m[0m
|
8
|
+
2014-07-09 12:22:47 - 12:22:47: [32m[1mRequiring [0m[0m [34m[1mins_vars in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb[0m[0m
|
9
|
+
2014-07-09 12:22:47 - 12:22:47: [32m[1mRequiring [0m[0m [34m[1mhelp in /home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb[0m[0m
|
10
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
11
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb file:require_autoload_helper.rb line:61[0m[0m
|
12
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/path_helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
13
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb file:require_autoload_helper.rb line:61[0m[0m
|
14
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/status.rb file:require_autoload_helper.rb line:61[0m[0m
|
15
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/process.rb file:require_autoload_helper.rb line:61[0m[0m
|
16
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/config.rb file:require_autoload_helper.rb line:61[0m[0m
|
17
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/basic.rb file:require_autoload_helper.rb line:61[0m[0m
|
18
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
19
|
+
2014-07-26 21:51:00 - 21:51:00: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
20
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
21
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb file:require_autoload_helper.rb line:61[0m[0m
|
22
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/path_helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
23
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb file:require_autoload_helper.rb line:61[0m[0m
|
24
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/status.rb file:require_autoload_helper.rb line:61[0m[0m
|
25
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/process.rb file:require_autoload_helper.rb line:61[0m[0m
|
26
|
+
2014-07-26 21:51:04 - 21:51:04: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/config.rb file:require_autoload_helper.rb line:61[0m[0m
|
27
|
+
2014-07-26 21:51:05 - 21:51:05: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/basic.rb file:require_autoload_helper.rb line:61[0m[0m
|
28
|
+
2014-07-26 21:51:05 - 21:51:05: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
29
|
+
2014-07-26 21:51:05 - 21:51:05: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
30
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
31
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb file:require_autoload_helper.rb line:61[0m[0m
|
32
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/path_helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
33
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb file:require_autoload_helper.rb line:61[0m[0m
|
34
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/status.rb file:require_autoload_helper.rb line:61[0m[0m
|
35
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/process.rb file:require_autoload_helper.rb line:61[0m[0m
|
36
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/config.rb file:require_autoload_helper.rb line:61[0m[0m
|
37
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/basic.rb file:require_autoload_helper.rb line:61[0m[0m
|
38
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
39
|
+
2014-07-26 21:52:18 - 21:52:18: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
40
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
41
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/ins_vars.rb file:require_autoload_helper.rb line:61[0m[0m
|
42
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/path_helper.rb file:require_autoload_helper.rb line:61[0m[0m
|
43
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/ins_helper/help.rb file:require_autoload_helper.rb line:61[0m[0m
|
44
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/status.rb file:require_autoload_helper.rb line:61[0m[0m
|
45
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_commands/lib/ro_helpers/bash_helper/process.rb file:require_autoload_helper.rb line:61[0m[0m
|
46
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/config.rb file:require_autoload_helper.rb line:61[0m[0m
|
47
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/basic.rb file:require_autoload_helper.rb line:61[0m[0m
|
48
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
49
|
+
2014-07-26 21:53:27 - 21:53:27: [32m[1mRequire [0m[0m [34m[1m/home/roroco/Dropbox/ruby-projects/ro_deploy/lib/ro_helpers/remote/file.rb file:require_autoload_helper.rb line:61[0m[0m
|
data/lib/ro_cmd/ci.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module ::RoCmd
|
4
|
+
class Ci < RmtBase
|
5
|
+
usg 'run'
|
6
|
+
|
7
|
+
def before_script(*args, &blk)
|
8
|
+
i "db:create"
|
9
|
+
end
|
10
|
+
|
11
|
+
def invoke(*args, &blk)
|
12
|
+
app.invoke *args, &blk
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :i, :invoke
|
16
|
+
|
17
|
+
def rake(*args, &blk)
|
18
|
+
i(*args, &blk)
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :rk, :rake
|
22
|
+
|
23
|
+
def app
|
24
|
+
@app ||= lambda do
|
25
|
+
app = ::Rake.application
|
26
|
+
app.init
|
27
|
+
app.load_rakefile
|
28
|
+
app
|
29
|
+
end.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require File.expand_path('../../../conf/ro_rmt', __FILE__)
|
2
|
+
require 'ro_cell/rmt'
|
3
|
+
|
4
|
+
|
5
|
+
module RoRmt
|
6
|
+
# require_all_capistrano
|
7
|
+
autoload_all "ro_cell"
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'ro_file'
|
11
|
+
require 'ro_core_exts'
|
12
|
+
require 'ro_cmd/base'
|
13
|
+
|
14
|
+
module ::RoCmd
|
15
|
+
module DpBaseHelper
|
16
|
+
class << self
|
17
|
+
include ::RoHelper::Misc
|
18
|
+
|
19
|
+
def meths
|
20
|
+
def_arr :meths
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
unless meths.include?('before_meth')
|
25
|
+
meths << 'before_meth'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class RmtBase < Base
|
30
|
+
|
31
|
+
class << self
|
32
|
+
|
33
|
+
def ignored_meth?(meth)
|
34
|
+
meth_name = meth.to_s
|
35
|
+
meth_name.match(%r{before_meth|after_meth|new|origin}) or ro_dp_meths.include? meth_name or private_method_defined? meth or
|
36
|
+
protected_method_defined? meth
|
37
|
+
end
|
38
|
+
|
39
|
+
# def method_added(meth)
|
40
|
+
# super if defined? super
|
41
|
+
#
|
42
|
+
# meth_name = meth.to_s
|
43
|
+
# new_meth_name = "new_#{meth_name}"
|
44
|
+
#
|
45
|
+
# if RoDeployBaseHelper.meths.include?(meth_name)
|
46
|
+
# return
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# RoDeployBaseHelper.meths << meth_name
|
50
|
+
# RoDeployBaseHelper.meths << new_meth_name
|
51
|
+
# # unless is_ignored_meth?(meth_name)
|
52
|
+
# # ro_deploy_meths << meth_name
|
53
|
+
#
|
54
|
+
#
|
55
|
+
# # define_private_method(origin_meth) do |*args|
|
56
|
+
# # send(meth, *args, &blk)
|
57
|
+
# # end
|
58
|
+
#
|
59
|
+
# ub_meth = instance_method(:"#{meth_name}")
|
60
|
+
#
|
61
|
+
# define_method(:"#{new_meth_name}") do |*args, &blk|
|
62
|
+
# before_meth
|
63
|
+
# # Out.status("Running", "#{self}.#{meth_name}")
|
64
|
+
# ub_meth.bind(self).call(*args, &blk)
|
65
|
+
# # send(origin_meth, *args, &blk)
|
66
|
+
# # after_meth
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# # alias_method origin_meth, meth
|
70
|
+
# alias_method meth_name, new_meth_name
|
71
|
+
# end
|
72
|
+
end
|
73
|
+
|
74
|
+
def ro_dp_meths
|
75
|
+
def_arr :ro_dp_meths
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def unicorn_st
|
81
|
+
"cd #{::RoRmt.rmt_rt} && sudo rm -f tmp/pids/unicorn.pid && bundle exec unicorn_rails -E production -d -c #{::RoRmt.rmt_r}/conf/unicorn.rb -D"
|
82
|
+
end
|
83
|
+
|
84
|
+
def unicorn_stop
|
85
|
+
"pkill -9 -f \"#{::RoRmt.rmt_rt}/conf/unicorn.rb -D\""
|
86
|
+
end
|
87
|
+
|
88
|
+
def before_meth
|
89
|
+
r = record("ro_deploy_stage") || ro_opts[:stage]
|
90
|
+
if r == 'production'
|
91
|
+
::RoRmt.cur_role = ::RoRmt.rmt_role
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def after_meth
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
def tt(from_file, to_file=nil)
|
100
|
+
from = File.expand_path(File.join(Dir.pwd, "conf/tts/#{from_file}"), __FILE__)
|
101
|
+
from = from.suffix(".erb")
|
102
|
+
|
103
|
+
unless File.exist?(from)
|
104
|
+
raise "please add #{from}"
|
105
|
+
end
|
106
|
+
|
107
|
+
ctn = ::RoFile.read(from)
|
108
|
+
result = ERB.new(ctn).result(binding)
|
109
|
+
to_file ||= lambda do
|
110
|
+
basename = File.basename(from).gsub(%r{\.erb$}, "")
|
111
|
+
end.call
|
112
|
+
|
113
|
+
::RoFile.write(to_file, result)
|
114
|
+
to_file
|
115
|
+
end
|
116
|
+
|
117
|
+
def ro_dp_gem_rt
|
118
|
+
@ro_deploy_gem_rt ||= File.expand_path("../../..", __FILE__)
|
119
|
+
end
|
120
|
+
|
121
|
+
def rmt
|
122
|
+
@rmt ||= ::RoCell::Rmt.new("root@localhost")
|
123
|
+
end
|
124
|
+
|
125
|
+
def flow(&blk)
|
126
|
+
if block_given?
|
127
|
+
rmt.flow &blk
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path("../../../conf/ro_rmt", __FILE__)
|
2
|
+
require 'ro_cmd/abstract_rspec'
|
3
|
+
|
4
|
+
module RoCmd
|
5
|
+
class RmtRspec < AbstractRspec
|
6
|
+
def cf(*args, &blk)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def order_rules(*args, &blk)
|
11
|
+
[
|
12
|
+
%r{.*}
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def ignoring_rules(*args, &blk)
|
17
|
+
[
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def selection_rules(*args, &blk)
|
22
|
+
[
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|