yggdrasil 0.0.9 → 0.0.10
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/lib/yggdrasil.rb +2 -2
- data/lib/yggdrasil/check.rb +1 -0
- data/lib/yggdrasil/help.rb +13 -20
- data/lib/yggdrasil/log.rb +18 -7
- data/lib/yggdrasil/version.rb +1 -1
- data/lib/yggdrasil_server.rb +6 -47
- data/lib/yggdrasil_server/help.rb +6 -6
- data/lib/yggdrasil_server/server.rb +43 -0
- data/spec/help_spec.rb +0 -13
- metadata +6 -5
data/lib/yggdrasil.rb
CHANGED
@@ -37,7 +37,7 @@ class Yggdrasil
|
|
37
37
|
new.commit(args[1..-1])
|
38
38
|
when 'diff', 'di'
|
39
39
|
new.diff(args[1..-1])
|
40
|
-
when 'help', '--help', 'h', '?'
|
40
|
+
when 'help', '--help', 'h', '-h', '?'
|
41
41
|
new(false).help(args[1..-1])
|
42
42
|
when 'init'
|
43
43
|
new(false).init(args[1..-1])
|
@@ -51,7 +51,7 @@ class Yggdrasil
|
|
51
51
|
new.status(args[1..-1])
|
52
52
|
when 'update'
|
53
53
|
new.update(args[1..-1])
|
54
|
-
when 'version', '--version'
|
54
|
+
when 'version', '--version', '-v'
|
55
55
|
new(false).version
|
56
56
|
else
|
57
57
|
$stderr .puts "Unknown subcommand: '#{args[0]}'"
|
data/lib/yggdrasil/check.rb
CHANGED
data/lib/yggdrasil/help.rb
CHANGED
@@ -37,7 +37,8 @@ add: Add files to management list (add to subversion)
|
|
37
37
|
usage #@base_cmd add [FILES...]
|
38
38
|
|
39
39
|
EOS
|
40
|
-
|
40
|
+
|
41
|
+
when 'check', 'c' ########################################### check (c)
|
41
42
|
puts <<"EOS"
|
42
43
|
check (c): check updating of managed files and the execution output of a commands.
|
43
44
|
usage: #@base_cmd check [OPTIONS...]
|
@@ -58,7 +59,7 @@ Valid options:
|
|
58
59
|
--non-interactive : do no interactive prompting
|
59
60
|
|
60
61
|
EOS
|
61
|
-
when 'cleanup'
|
62
|
+
when 'cleanup' ################################################ cleanup
|
62
63
|
puts <<"EOS"
|
63
64
|
cleanup: clean up the working copy
|
64
65
|
usage: #@base_cmd cleanup [OPTIONS...]
|
@@ -68,7 +69,7 @@ Valid options:
|
|
68
69
|
--password ARG : specify a password ARG
|
69
70
|
|
70
71
|
EOS
|
71
|
-
when 'commit', 'ci'
|
72
|
+
when 'commit', 'ci' ####################################### commit (ci)
|
72
73
|
puts <<"EOS"
|
73
74
|
commit (ci): Send changes from your local file to the repository.
|
74
75
|
usage: #@base_cmd commit [OPTIONS...] [FILES...]
|
@@ -80,7 +81,7 @@ Valid options:
|
|
80
81
|
--non-interactive : do no interactive prompting
|
81
82
|
|
82
83
|
EOS
|
83
|
-
when 'diff', 'di'
|
84
|
+
when 'diff', 'di' ########################################### diff (di)
|
84
85
|
puts <<"EOS"
|
85
86
|
diff (di): Display the differences between two revisions or paths.
|
86
87
|
usage: #@base_cmd diff [OPTIONS...] [PATH...]
|
@@ -98,13 +99,13 @@ Valid options:
|
|
98
99
|
'PREV' revision just before COMMITTED
|
99
100
|
|
100
101
|
EOS
|
101
|
-
when 'help', '
|
102
|
+
when 'help', '--help', 'h', '-h', '?' ###################### help (?,h)
|
102
103
|
puts <<"EOS"
|
103
104
|
help (?,h): Describe the usage of this program or its subcommands.
|
104
105
|
usage: #@base_cmd help [SUBCOMMAND]
|
105
106
|
|
106
107
|
EOS
|
107
|
-
when 'init'
|
108
|
+
when 'init' ###################################################### init
|
108
109
|
puts <<"EOS"
|
109
110
|
init: Check environment and initialize configuration.
|
110
111
|
usage: #@base_cmd init [OPTIONS...]
|
@@ -122,7 +123,7 @@ Valid options:
|
|
122
123
|
e.g. 192.168.1.35:4000
|
123
124
|
|
124
125
|
EOS
|
125
|
-
when 'list', 'ls'
|
126
|
+
when 'list', 'ls' ########################################### list (ls)
|
126
127
|
puts <<"EOS"
|
127
128
|
list (ls): List directory entries in the repository.
|
128
129
|
usage: #@base_cmd list [OPTIONS...] [PATH...]
|
@@ -141,7 +142,7 @@ Valid options:
|
|
141
142
|
-R [--recursive] : descend recursively
|
142
143
|
|
143
144
|
EOS
|
144
|
-
when 'log'
|
145
|
+
when 'log' ######################################################## log
|
145
146
|
puts <<"EOS"
|
146
147
|
log: Show the log messages for a set of revision(s) and/or file(s).
|
147
148
|
usage: #@base_cmd log [OPTIONS...] [PATH]
|
@@ -159,7 +160,7 @@ Valid options:
|
|
159
160
|
'PREV' revision just before COMMITTED
|
160
161
|
|
161
162
|
EOS
|
162
|
-
when 'revert'
|
163
|
+
when 'revert' ################################################## revert
|
163
164
|
puts <<"EOS"
|
164
165
|
revert: Restore pristine working copy file (undo most local edits).
|
165
166
|
usage: #@base_cmd revert [OPTIONS...] [PATH...]
|
@@ -170,16 +171,8 @@ Valid options:
|
|
170
171
|
--non-interactive : do no interactive prompting
|
171
172
|
|
172
173
|
EOS
|
173
|
-
when 'server'
|
174
|
-
puts <<"EOS"
|
175
|
-
server: receive tcp connection in order to unify the setup and to record check results.
|
176
|
-
usage: #@base_cmd server [OPTIONS...]
|
177
174
|
|
178
|
-
|
179
|
-
--daemon : daemon mode
|
180
|
-
|
181
|
-
EOS
|
182
|
-
when 'status', 'stat', 'st'
|
175
|
+
when 'status', 'stat', 'st' ######################### status (stat, st)
|
183
176
|
puts <<"EOS"
|
184
177
|
status (stat, st): Print the status of managed files and directories.
|
185
178
|
usage: #@base_cmd status [OPTIONS...] [PATH...]
|
@@ -189,7 +182,7 @@ Valid options:
|
|
189
182
|
--password ARG : specify a password ARG
|
190
183
|
|
191
184
|
EOS
|
192
|
-
when 'update'
|
185
|
+
when 'update' ################################################## update
|
193
186
|
puts <<"EOS"
|
194
187
|
update (up): Bring changes from the repository into the local files.
|
195
188
|
usage: #@base_cmd update [OPTIONS...] [PATH...]
|
@@ -208,7 +201,7 @@ Valid options:
|
|
208
201
|
--non-interactive : do no interactive prompting
|
209
202
|
|
210
203
|
EOS
|
211
|
-
when 'version', '--version'
|
204
|
+
when 'version', '--version', '-v' ######################## version (-v)
|
212
205
|
puts <<"EOS"
|
213
206
|
version: See the program version
|
214
207
|
usage: #@base_cmd version
|
data/lib/yggdrasil/log.rb
CHANGED
@@ -7,28 +7,39 @@ class Yggdrasil
|
|
7
7
|
'-r'=>:revision, '--revision'=>:revision})
|
8
8
|
get_user_pass_if_need_to_read_repo
|
9
9
|
|
10
|
-
|
10
|
+
ext_options = Array.new
|
11
|
+
paths = Array.new
|
12
|
+
args.each do |arg|
|
13
|
+
if /^-/ =~ arg
|
14
|
+
ext_options << arg
|
15
|
+
else
|
16
|
+
paths << arg
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if paths.size == 0
|
11
21
|
dir = @mirror_dir + @current_dir
|
12
22
|
error 'current directory is not managed.' unless File.exist?(dir)
|
13
|
-
|
23
|
+
paths << dir
|
14
24
|
else
|
15
|
-
|
16
|
-
if %r{^/} =~
|
17
|
-
@mirror_dir +
|
25
|
+
paths.collect! do |path|
|
26
|
+
if %r{^/} =~ path
|
27
|
+
@mirror_dir + path
|
18
28
|
else
|
19
|
-
@mirror_dir + @current_dir + '/' +
|
29
|
+
@mirror_dir + @current_dir + '/' + path
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
|
24
34
|
cmd_arg = "#@svn log --no-auth-cache --non-interactive"
|
25
35
|
cmd_arg += username_password_options_to_read_repo
|
36
|
+
cmd_arg += ' ' + ext_options.join(' ') if ext_options.size != 0
|
26
37
|
if @options.has_key?(:revision)
|
27
38
|
cmd_arg += " -r #{@options[:revision]}"
|
28
39
|
else
|
29
40
|
cmd_arg += ' -r HEAD:1'
|
30
41
|
end
|
31
|
-
cmd_arg += ' ' +
|
42
|
+
cmd_arg += ' ' + paths.join(' ')
|
32
43
|
puts system3(cmd_arg)
|
33
44
|
end
|
34
45
|
end
|
data/lib/yggdrasil/version.rb
CHANGED
data/lib/yggdrasil_server.rb
CHANGED
@@ -5,6 +5,7 @@ require 'yggdrasil_common'
|
|
5
5
|
require 'yggdrasil_server/version'
|
6
6
|
require 'yggdrasil_server/help'
|
7
7
|
require 'yggdrasil_server/init'
|
8
|
+
require 'yggdrasil_server/server'
|
8
9
|
require 'yggdrasil_server/results'
|
9
10
|
|
10
11
|
require 'yggdrasil_server/get_repo'
|
@@ -28,19 +29,19 @@ class YggdrasilServer
|
|
28
29
|
return
|
29
30
|
end
|
30
31
|
case args[0]
|
31
|
-
when 'daemon'
|
32
|
+
when 'daemon', '-d'
|
32
33
|
Process.daemon
|
33
34
|
YggdrasilServer.new.server(args[1..-1])
|
34
|
-
when 'debug'
|
35
|
+
when 'debug', '--debug'
|
35
36
|
args << '--debug'
|
36
37
|
YggdrasilServer.new.server(args[1..-1])
|
37
|
-
when 'help', '--help', 'h', '?'
|
38
|
+
when 'help', '--help', 'h', '-h', '?'
|
38
39
|
new(false).help(args[1..-1])
|
39
40
|
when 'init'
|
40
41
|
new(false).init_server(args[1..-1])
|
41
|
-
when 'results'
|
42
|
+
when 'results', 'res'
|
42
43
|
YggdrasilServer.new.results(args[1..-1])
|
43
|
-
when 'version', '--version'
|
44
|
+
when 'version', '--version', '-v'
|
44
45
|
new(false).version
|
45
46
|
else
|
46
47
|
$stderr .puts "Unknown subcommand: '#{args[0]}'"
|
@@ -63,48 +64,6 @@ class YggdrasilServer
|
|
63
64
|
@ro_password = configs[:ro_password] if configs.has_key?(:ro_password)
|
64
65
|
end
|
65
66
|
|
66
|
-
def server(args)
|
67
|
-
args = parse_options(args, {'--debug'=>:debug?})
|
68
|
-
if args.size != 0
|
69
|
-
error "invalid arguments: #{args.join(',')}"
|
70
|
-
end
|
71
|
-
|
72
|
-
puts "Start: yggdrasil server (port:#@port)"
|
73
|
-
TCPServer.do_not_reverse_lookup = true
|
74
|
-
s0 = TCPServer.open(@port.to_i)
|
75
|
-
loop do
|
76
|
-
sock = s0.accept
|
77
|
-
msg = sock.gets # first line
|
78
|
-
ctime = Time.now
|
79
|
-
if msg && msg.chomp! != MESSAGE_QUIT
|
80
|
-
msg.chomp!
|
81
|
-
printf "RCV[%04d-%02d-%02d %02d:%02d:%02d.%03d](#{sock.peeraddr[3]}): #{msg}\n",
|
82
|
-
ctime.year, ctime.month, ctime.day, ctime.hour, ctime.min, ctime.sec, (ctime.usec/1000).round
|
83
|
-
msg_parts = msg.split
|
84
|
-
if msg_parts.size != 0
|
85
|
-
msg_cmd = msg_parts[0]
|
86
|
-
part_names = MESSAGES[msg_cmd.to_sym]
|
87
|
-
if (msg_parts.size - 1) == part_names.size
|
88
|
-
# make hash of args
|
89
|
-
msg_arg_hash = Hash.new
|
90
|
-
(0...part_names.size).each do |i|
|
91
|
-
msg_arg_hash[part_names[i]] = msg_parts[i+1]
|
92
|
-
end
|
93
|
-
|
94
|
-
# execute request (msg_cmd == method name)
|
95
|
-
send msg_cmd, sock, msg_arg_hash
|
96
|
-
else
|
97
|
-
puts "fail: number of arguments is mismatch: #{msg}"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
sock.close
|
102
|
-
break if @options.has_key?(:debug?) && msg == MESSAGE_QUIT
|
103
|
-
end
|
104
|
-
s0.close # MESSAGE_QUIT
|
105
|
-
end
|
106
|
-
|
107
67
|
protected
|
108
68
|
include YggdrasilCommon
|
109
69
|
end
|
110
|
-
|
@@ -28,25 +28,25 @@ EOS
|
|
28
28
|
error 'too many arguments.'
|
29
29
|
else
|
30
30
|
case args[0]
|
31
|
-
when 'daemon'
|
31
|
+
when 'daemon', '-d' ####################################### daemon (-d)
|
32
32
|
puts <<"EOS"
|
33
33
|
daemon: launch TCP server by daemon mode.
|
34
34
|
usage: #{File.basename($0)} daemon
|
35
35
|
|
36
36
|
EOS
|
37
|
-
when 'debug'
|
37
|
+
when 'debug', '--debug' ######################################### debug
|
38
38
|
puts <<"EOS"
|
39
39
|
debug: launch TCP server by debug mode.
|
40
40
|
usage: #{File.basename($0)} debug
|
41
41
|
|
42
42
|
EOS
|
43
|
-
when 'help', '
|
43
|
+
when 'help', '--help', 'h', '-h', '?' ###################### help (h,?)
|
44
44
|
puts <<"EOS"
|
45
45
|
help (?,h): Describe the usage of this program or its subcommands.
|
46
46
|
usage: #@base_cmd help [SUBCOMMAND]
|
47
47
|
|
48
48
|
EOS
|
49
|
-
when 'init'
|
49
|
+
when 'init' ###################################################### init
|
50
50
|
puts <<"EOS"
|
51
51
|
init: setup yggdrasil server configuration.
|
52
52
|
usage: #@base_cmd init [OPTIONS...]
|
@@ -62,7 +62,7 @@ Valid options:
|
|
62
62
|
--ro-password ARG : specify a password ARG for read only
|
63
63
|
|
64
64
|
EOS
|
65
|
-
when 'results'
|
65
|
+
when 'results', 'res' ################################### results (res)
|
66
66
|
puts <<"EOS"
|
67
67
|
results: display the result of yggdrasil check command.
|
68
68
|
usage: #@base_cmd results [OPTIONS...]
|
@@ -71,7 +71,7 @@ Valid options:
|
|
71
71
|
--expire ARG : minutes from the final report, to judge the host not be alive
|
72
72
|
|
73
73
|
EOS
|
74
|
-
when 'version', '--version'
|
74
|
+
when 'version', '--version', '-v' ######################## version (-v)
|
75
75
|
puts <<"EOS"
|
76
76
|
version: See the program version
|
77
77
|
usage: #@base_cmd version
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class YggdrasilServer
|
2
|
+
|
3
|
+
def server(args)
|
4
|
+
args = parse_options(args, {'--debug'=>:debug?})
|
5
|
+
if args.size != 0
|
6
|
+
error "invalid arguments: #{args.join(',')}"
|
7
|
+
end
|
8
|
+
|
9
|
+
puts "Start: yggdrasil server (port:#@port)"
|
10
|
+
TCPServer.do_not_reverse_lookup = true
|
11
|
+
s0 = TCPServer.open(@port.to_i)
|
12
|
+
loop do
|
13
|
+
sock = s0.accept
|
14
|
+
msg = sock.gets # first line
|
15
|
+
ctime = Time.now
|
16
|
+
if msg && msg.chomp! != MESSAGE_QUIT
|
17
|
+
msg.chomp!
|
18
|
+
printf "RCV[%04d-%02d-%02d %02d:%02d:%02d.%03d](#{sock.peeraddr[3]}): #{msg}\n",
|
19
|
+
ctime.year, ctime.month, ctime.day, ctime.hour, ctime.min, ctime.sec, (ctime.usec/1000).round
|
20
|
+
msg_parts = msg.split
|
21
|
+
if msg_parts.size != 0
|
22
|
+
msg_cmd = msg_parts[0]
|
23
|
+
part_names = MESSAGES[msg_cmd.to_sym]
|
24
|
+
if (msg_parts.size - 1) == part_names.size
|
25
|
+
# make hash of args
|
26
|
+
msg_arg_hash = Hash.new
|
27
|
+
(0...part_names.size).each do |i|
|
28
|
+
msg_arg_hash[part_names[i]] = msg_parts[i+1]
|
29
|
+
end
|
30
|
+
|
31
|
+
# execute request (msg_cmd == method name)
|
32
|
+
send msg_cmd, sock, msg_arg_hash
|
33
|
+
else
|
34
|
+
puts "fail: number of arguments is mismatch: #{msg}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
sock.close
|
39
|
+
break if @options.has_key?(:debug?) && msg == MESSAGE_QUIT
|
40
|
+
end
|
41
|
+
s0.close # MESSAGE_QUIT
|
42
|
+
end
|
43
|
+
end
|
data/spec/help_spec.rb
CHANGED
@@ -293,19 +293,6 @@ Valid options:
|
|
293
293
|
--password ARG : specify a password ARG
|
294
294
|
--non-interactive : do no interactive prompting
|
295
295
|
|
296
|
-
EOS
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'should show help of server' do
|
300
|
-
puts '---- should show help of server'
|
301
|
-
out = catch_out{Yggdrasil.command %w{help server}}
|
302
|
-
out.should == <<"EOS"
|
303
|
-
server: receive tcp connection in order to unify the setup and to record check results.
|
304
|
-
usage: #{File.basename($0)} server [OPTIONS...]
|
305
|
-
|
306
|
-
Valid options:
|
307
|
-
--daemon : daemon mode
|
308
|
-
|
309
296
|
EOS
|
310
297
|
end
|
311
298
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yggdrasil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
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: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/yggdrasil_server/init.rb
|
84
84
|
- lib/yggdrasil_server/put_result.rb
|
85
85
|
- lib/yggdrasil_server/results.rb
|
86
|
+
- lib/yggdrasil_server/server.rb
|
86
87
|
- lib/yggdrasil_server/version.rb
|
87
88
|
- spec/add_spec.rb
|
88
89
|
- spec/check_spec.rb
|
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
segments:
|
120
121
|
- 0
|
121
|
-
hash:
|
122
|
+
hash: 896107728749250326
|
122
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
124
|
none: false
|
124
125
|
requirements:
|
@@ -127,10 +128,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
version: '0'
|
128
129
|
segments:
|
129
130
|
- 0
|
130
|
-
hash:
|
131
|
+
hash: 896107728749250326
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.8.
|
134
|
+
rubygems_version: 1.8.23
|
134
135
|
signing_key:
|
135
136
|
specification_version: 3
|
136
137
|
summary: Type "ygg help" for usage.
|