ro_rmt 0.0.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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +91 -0
  3. data/conf/ro_rmt.rb +203 -0
  4. data/conf/rsync/exclude_patterns +4 -0
  5. data/conf/rsync/include_patterns +10 -0
  6. data/lib/ro_cell/rmt.rb +254 -0
  7. data/lib/ro_cell/rmt/dir.rb +55 -0
  8. data/lib/ro_cell/rmt/file.rb +96 -0
  9. data/lib/ro_cell/rmt/opts.rb +21 -0
  10. data/lib/ro_cell/rmt/se_mgr.rb +51 -0
  11. data/lib/ro_cell/tmp/ro.log +49 -0
  12. data/lib/ro_cmd/ci.rb +32 -0
  13. data/lib/ro_cmd/rmt_base.rb +132 -0
  14. data/lib/ro_cmd/rmt_rspec.rb +26 -0
  15. data/lib/ro_helper/dp.rb +20 -0
  16. data/lib/ro_helper/rmt/basic.rb +441 -0
  17. data/lib/ro_helper/rmt/compress.rb +31 -0
  18. data/lib/ro_helper/rmt/determinations.rb +25 -0
  19. data/lib/ro_helper/rmt/dir.rb +11 -0
  20. data/lib/ro_helper/rmt/file.rb +13 -0
  21. data/lib/ro_helper/rmt/file_dir.rb +60 -0
  22. data/lib/ro_helper/rmt/process.rb +46 -0
  23. data/lib/ro_helper/rmt/rb.rb +131 -0
  24. data/lib/ro_helper/rmt/scp.rb +117 -0
  25. data/lib/ro_helper/rmt/se_attrs.rb +28 -0
  26. data/lib/ro_rmt.rb +9 -0
  27. data/lib/ro_rmt_ro_cmds_bin.rb +4 -0
  28. data/lib/ro_rspec_helper/rmt_rspec_helper.rb +82 -0
  29. data/lib/ro_script/kill_port.rb +49 -0
  30. data/lib/ro_script/pgrep.rb +44 -0
  31. data/lib/ro_script/pkill.rb +51 -0
  32. data/lib/ro_script/try.rb +0 -0
  33. data/lib/tts/nginx.conf.erb +148 -0
  34. data/spec/fixtures/ro_bin_helper/Gemfile +2 -0
  35. data/spec/fixtures/ro_bin_helper/gem1/lib/ro_cmd/cmd1.rb +0 -0
  36. data/spec/fixtures/ro_bin_helper/gem1/lib/ro_cmd/cmd2.rb +0 -0
  37. data/spec/fixtures/ro_bin_helper/gem2/lib/ro_cmd/cmd1.rb +0 -0
  38. data/spec/fixtures/ro_bin_helper/gem2/lib/ro_cmd/cmd2.rb +0 -0
  39. data/spec/fixtures/scp/log/scp_rspec_err.log +216 -0
  40. data/spec/fixtures/scp/tmp/ro.log +110 -0
  41. data/spec/fixtures/scp/tmp/ro_cell__pl__sv__st_event.log +7 -0
  42. data/spec/fixtures/scp/tmp/roroco/at/localhost/home/roroco/try/try_ro_rmt.rb +1 -0
  43. data/spec/fixtures/se_mgr/log/se_mgr_rspec_err.log +207 -0
  44. data/spec/fixtures/se_mgr/tmp/ro.log +1194 -0
  45. data/spec/fixtures/se_mgr/tmp/ro_cell__pl__sv__st_event.log +7 -0
  46. data/spec/helpers/articles_helper_spec.rb +15 -0
  47. data/spec/lib/ro_cell/rmt/dir_spec.rb +22 -0
  48. data/spec/lib/ro_cell/rmt/file_spec.rb +32 -0
  49. data/spec/lib/ro_cell/rmt/se_mgr_spec.rb +33 -0
  50. data/spec/lib/ro_cell/rmt_spec.rb +113 -0
  51. data/spec/lib/ro_dp/cap_spec.rb +34 -0
  52. data/spec/lib/ro_dp/rbenv_spec.rb +10 -0
  53. data/spec/lib/ro_dp/system_spec.rb +31 -0
  54. data/spec/lib/ro_helper/rmt/basic_spec.rb +41 -0
  55. data/spec/lib/ro_helper/rmt/cf_spec.rb +17 -0
  56. data/spec/lib/ro_helper/rmt/determinations_spec.rb +11 -0
  57. data/spec/lib/ro_helper/rmt/dir_spec.rb +15 -0
  58. data/spec/lib/ro_helper/rmt/file_dir_helper_spec.rb +11 -0
  59. data/spec/lib/ro_helper/rmt/file_spec.rb +23 -0
  60. data/spec/lib/ro_helper/rmt/process_spec.rb +29 -0
  61. data/spec/lib/ro_helper/rmt/rb_spec.rb +13 -0
  62. data/spec/lib/ro_helper/rmt/scp_spec.rb +21 -0
  63. data/spec/lib/ro_script/pgrep_spec.rb +18 -0
  64. data/spec/lib/ro_sv_try/1.rb +0 -0
  65. data/spec/lib/ro_sv_try/2.rb +0 -0
  66. data/spec/lib/ro_sv_try/3.rb +0 -0
  67. data/spec/lib/ro_sv_try/tmp/rspec_guard_result +9 -0
  68. data/spec/rails_helper.rb +1 -0
  69. data/spec/spec_helper.rb +35 -0
  70. data/spec/wio_spork.rb +10 -0
  71. metadata +177 -0
@@ -0,0 +1,7 @@
1
+ 2014-12-15 22:21:15 - kill 30236 at 2014-12-15 22:21:15 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
2
+ 2014-12-15 22:24:38 - kill 32221 at 2014-12-15 22:24:38 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
3
+ 2014-12-15 22:26:06 - kill 1432 at 2014-12-15 22:26:06 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
4
+ 2014-12-15 22:40:00 - kill 9039 at 2014-12-15 22:40:00 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
5
+ 2014-12-15 22:52:20 - kill 15791 at 2014-12-15 22:52:20 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
6
+ 2014-12-15 22:57:53 - kill 21780 at 2014-12-15 22:57:53 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
7
+ 2014-12-15 22:59:33 - kill 27040 at 2014-12-15 22:59:33 +0800(logged from /home/roroco/Dropbox/rbs/ro_pl/lib/ro_cell/pl/sv.rb:92 in `st')
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ # spec in this file have access to a helper object that includes
4
+ # the ArticlesHelper. For example:
5
+ #
6
+ # describe ArticlesHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # expect(helper.concat_strings("this","that")).to eq("this that")
10
+ # end
11
+ # end
12
+ # end
13
+ describe ArticlesHelper do
14
+ pending "add some examples to (or delete) #{__FILE__}"
15
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt.new" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it "RoCell::Rmt::Dir.new" do
9
+ RoCell::Rmt::Dir.new(try_dir, se: rmt.se)
10
+ end
11
+
12
+ it :ls_dir do
13
+ result = o.send(:ls_dir, try_dir)
14
+ end
15
+
16
+ it :files do
17
+ create_try_files
18
+ result = o.dir(try_dir).files
19
+ expect(result).to have_val
20
+ Out.out result
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt.new" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it "RoCell::RmtFile.new" do
9
+ RoCell::Rmt::File.new
10
+ end
11
+
12
+ it "file_exist just match file not dir" do
13
+ result = o.send(:exist_file?, try_file)
14
+ expect(result).to eq(true)
15
+ result = o.send(:exist_file?, try_dir)
16
+ expect(result).to eq(false)
17
+ end
18
+
19
+ describe "#append" do
20
+ it 'case' do
21
+ result = o.send(:file_append, try_file, Time.now)
22
+ end
23
+
24
+ it "ignore same ctn" do
25
+ ctn = "a ctn"
26
+ result = o.send(:file_append, try_file, ctn)
27
+ result = o.send(:file_append, try_file, ignore_if_match: %r{#{ctn}})
28
+ result = o.send(:file_read, try_file )
29
+ Out.out result
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt::SeMgr" do
4
+ let(:o) do
5
+ RoCell::Rmt::SeMgr
6
+ end
7
+
8
+ before do
9
+ cdfix "se_mgr"
10
+ o.clear
11
+ end
12
+
13
+ it :clear do
14
+ result = o.send(:clear)
15
+ expect(o.se_coll.len).to eq(0)
16
+ end
17
+
18
+ it :registered? do
19
+ o.register(rmt.se)
20
+ result = o.send(:registered?, rmt.se)
21
+ expect(result).to eq(true)
22
+ result = o.se_coll.len
23
+ expect(result).to eq(1)
24
+ end
25
+
26
+ it :se do
27
+ registered_obj = openstruct(user_at_host: user_at_host)
28
+ o.register(registered_obj)
29
+ result = o.send(:se, user_at_host: user_at_host)
30
+ expect(result).to eq(registered_obj)
31
+ end
32
+ end
33
+
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ describe "::RoCell::Rmt" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it :exist_file? do
9
+ o.exist_file?("/var/www")
10
+ end
11
+
12
+ it :exist_dir? do
13
+ result = o.send(:exist_dir?, '~')
14
+ expect(result).to eq(true)
15
+ end
16
+
17
+ def try_script(*args, &blk)
18
+ "Time.now"
19
+ end
20
+
21
+ it :create_lc_script do
22
+ result = o.send(:create_lc_script, try_script)
23
+ Out.out result
24
+ end
25
+
26
+ it :eval do
27
+ result = o.send(:eval, try_script)
28
+ end
29
+
30
+ it :process do
31
+ expect(o.process('init')).to match /\d+/
32
+ end
33
+
34
+ it :file_blank do
35
+ o.cmd "rm -f #{try_file}"
36
+ o.cmd "touch #{try_file}"
37
+ result = o.file_blank?(try_file)
38
+ expect(result).to eq(true)
39
+ end
40
+
41
+ it :write do
42
+ result = o.send(:write, try_file, 'smth')
43
+ result = o.send(:read, try_file)
44
+ expect(result).to have_val()
45
+ end
46
+
47
+ context "when bin not exist" do
48
+
49
+ it :bin? do
50
+ result = o.send(:"bin?", "not_exist_bin")
51
+ expect(result).to eq(false)
52
+ end
53
+
54
+ context "when bin exist" do
55
+ it :bin? do
56
+ result = o.send(:bin?, "ls")
57
+ expect(result).to have_val
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "::RoCell::Rmt.new", if: RunIn.my_pc? do
64
+ let(:o) do
65
+ rmt
66
+ end
67
+
68
+ describe :cat do
69
+ it "c1" do
70
+ r = o.cat __FILE__
71
+ end
72
+
73
+ it "c2" do
74
+ begin
75
+ o.bash "err_cmd"
76
+ rescue ::RoErr::RmtErr => e
77
+ o.cat __FILE__
78
+ end
79
+ end
80
+ end
81
+
82
+ describe :bash do
83
+ it "case" do
84
+ result = o.send(:bash, 'ls')
85
+ end
86
+
87
+ it "cat a wrong file will raise err" do
88
+ expect do
89
+ begin
90
+ result = o.send(:bash, 'cat /a/wrong/file')
91
+ rescue ::RoErr::RmtErr => e
92
+ expect(e.to_s).to match("cat: /a/wrong/file")
93
+ raise e
94
+ end
95
+ end.to raise_error(::RoErr::RmtErr)
96
+ end
97
+ end
98
+
99
+ it :cmd do
100
+ expect do
101
+ result = o.send(:cmd, 'wwklfjwfklj')
102
+ end.to raise_error(::RoErr::RmtErr)
103
+ end
104
+
105
+ it :capture do
106
+ result = o.send(:capture, 'ls')
107
+ end
108
+
109
+ it :chdir do
110
+ result = o.send(:chdir, ::RoRmt.home, "ls -al")
111
+ end
112
+ end
113
+
@@ -0,0 +1,34 @@
1
+ #require 'spec_helper'
2
+ #
3
+ #describe 'Cap' do
4
+ # describe 'require' do
5
+ # it 'before install' do
6
+ # require 'ro_rmt/cap'
7
+ # end
8
+ #
9
+ # it 'after install' do
10
+ # r = bash \
11
+ # "cd #{Envs::Pj.pj_rt}",
12
+ # "rake install",
13
+ # "cd #{File.join $fixtures, 'ro_deploy_try'}",
14
+ # "cap -vT"
15
+ # end
16
+ # end
17
+ #
18
+ # it 'multi_exec' do
19
+ # pending
20
+ # end
21
+ #
22
+ # it 'conf' do
23
+ # pending
24
+ # end
25
+ #
26
+ # it 'Envs::Project.rt' do
27
+ # pending
28
+ # end
29
+ #
30
+ # it 'multi_exec' do
31
+ # pending
32
+ # end
33
+ #
34
+ #end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rbenv' do
4
+
5
+ it 'install' do
6
+ pending("something else getting finished")
7
+ fail
8
+ end
9
+
10
+ end
@@ -0,0 +1,31 @@
1
+ #require 'spec_helper'
2
+ #
3
+ #describe 'System' do
4
+ #
5
+ # let(:s) { System.new }
6
+ # it 'ls' do
7
+ # s.ls(File.join ENV['HOME'])
8
+ # end
9
+ #
10
+ # describe 'process.rb' do
11
+ # it '' do
12
+ # s.process.rb(sort_by: 'pcpu')
13
+ # end
14
+ #
15
+ # it '' do
16
+ # s.process.rb(sort_by: 'pcpu', last: 10)
17
+ # end
18
+ #
19
+ # it '' do
20
+ # s.process.rb(sort_by: 'pmem', last: 10)
21
+ # end
22
+ # end
23
+ #it 'initialize' do
24
+ # pending
25
+ #end
26
+ #
27
+ #it 'process.rb' do
28
+ # pending
29
+ #end
30
+ #
31
+ #end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "rmt" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ describe :bash do
9
+ it 'first' do
10
+ result = o.send(:bash, "echo 'try'")
11
+ end
12
+
13
+ it "case2" do
14
+ expect do
15
+ result = o.send(:bash, "ruby -e \"raise 'err'\"")
16
+ end.to raise_error(RoErr::RmtErr)
17
+ end
18
+ end
19
+
20
+
21
+ it :file do
22
+ result = o.send(:file, __FILE__).read
23
+ expect(result).to have_val
24
+ end
25
+
26
+ # it :stage do
27
+ # result = o.send(:stage)
28
+ # result = o.stage
29
+ # expect(result).to eq(user_at_host)
30
+ # end
31
+
32
+ it :format_path do
33
+ result = o.send(:format_path, '~///path/to')
34
+ expect(result).to eq(o.home("path/to"))
35
+ end
36
+
37
+ it :eval do
38
+ ctn = "Time.now"
39
+ result = o.send(:eval, ctn)
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt.new" do
4
+ let(:o) do
5
+ RoCell::Rmt.new
6
+ end
7
+
8
+ it :user do
9
+ result = o.send(:user)
10
+ expect(result).to have_val
11
+ end
12
+
13
+ it :host do
14
+ result = o.send(:"
15
+ expect(result).to have_value
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt.new" do
4
+ let(:o) do
5
+ RoCell::Rmt.new("root@localhost")
6
+ end
7
+
8
+ it :lc? do
9
+ result = o.send(:lc?)
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt::Dir" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it :ls_dir do
9
+ result = o.send(:ls_dir, Pathname.new(__FILE__).parent.to_s)
10
+ end
11
+
12
+ it "respond to dir_create" do
13
+ expect(o).to respond_to :dir_create
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt.new" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it :file_read do
9
+ result = o.send(:file_read, __FILE__)
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RoCell::Rmt3.new" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it :read do
9
+ result = o.read(try_file)
10
+ end
11
+
12
+ it :exist_file? do
13
+ result = o.send(:exist_file?, try_file)
14
+ expect(result).to eq(true)
15
+ RoFile.rm try_dir
16
+ result = o.send(:exist_file?, try_dir)
17
+ expect(result).to eq(false)
18
+ end
19
+
20
+ it :create_file do
21
+ result = o.send(:create_file, try_file)
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'rails_helper'
2
+
3
+ describe "rmt" do
4
+ let(:o) do
5
+ rmt
6
+ end
7
+
8
+ it :pgrep do
9
+ r = o.pgrep("nginx")
10
+ expect(r).to be_kind_of Array
11
+ end
12
+
13
+ it :kill_port do
14
+ port = 7787
15
+ Bash.kill_port port
16
+ pid = fork do
17
+ sv = TCPServer.new("localhost", port)
18
+ loop do
19
+ s = sv.accept
20
+ end
21
+ end
22
+
23
+ ro_try(10, until: lamb("#{port} is listened") do
24
+ Bash.port_is_listened? port
25
+ end)
26
+
27
+ result = o.send(:kill_port, port)
28
+ end
29
+ end