yggdrasil 0.0.7 → 0.0.8

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.
@@ -11,29 +11,29 @@ class YggdrasilServer
11
11
  end
12
12
 
13
13
  if !@options.has_key?(:ro_username) && @options.has_key?(:ro_password)
14
- error "--ro-password option need --ro-username, too."
14
+ error '--ro-password option need --ro-username, too.'
15
15
  end
16
16
 
17
17
  until @options.has_key?(:port)
18
- print "Input tcp port number: "
18
+ print 'Input tcp port number: '
19
19
  input = $stdin.gets
20
- error "can not input tcp port number" unless input
20
+ error 'can not input tcp port number' unless input
21
21
 
22
22
  input.chomp!
23
23
  unless %r{\d+} =~ input && input.to_i < 0x10000
24
- puts "ERROR: Invalid port number."
24
+ puts 'ERROR: Invalid port number.'
25
25
  redo
26
26
  end
27
27
  @options[:port] = input # string
28
28
  end
29
29
 
30
30
  until @options.has_key?(:repo)
31
- print "Input svn repo URL: "
31
+ print 'Input svn repo URL: '
32
32
  input = $stdin.gets
33
- error "can not input svn repo URL." unless input
33
+ error 'can not input svn repo URL.' unless input
34
34
 
35
35
  unless %r{^(http://|https://|file://|svn://)} =~ input
36
- puts "ERROR: Invalid URL."
36
+ puts 'ERROR: Invalid URL.'
37
37
  redo
38
38
  end
39
39
  @options[:repo] = input
@@ -42,14 +42,14 @@ class YggdrasilServer
42
42
  @options[:repo].chomp!('/')
43
43
 
44
44
  unless @options.has_key?(:ro_password)
45
- puts "Input read-only username/password (clients use this to read repo)."
46
- puts "ATTENTION! username/password are stored to disk unencrypted!"
45
+ puts 'Input read-only username/password (clients use this to read repo).'
46
+ puts 'ATTENTION! username/password are stored to disk unencrypted!'
47
47
  input_user_pass
48
48
  end
49
49
 
50
50
  # make config file
51
51
  Dir.mkdir @config_dir, 0755 unless File.exist?(@config_dir)
52
- File.open(@server_config_file, "w") do |f|
52
+ File.open(@server_config_file, 'w') do |f|
53
53
  f.write "port=#{@options[:port]}\n"\
54
54
  "repo=#{@options[:repo]}\n"
55
55
  if @options.has_key?(:ro_password)
@@ -1,6 +1,6 @@
1
1
  class YggdrasilServer
2
2
  def put_result(sock, arg_hash = {})
3
- result_string = ""
3
+ result_string = ''
4
4
  while (line=sock.gets)
5
5
  result_string << line
6
6
  end
@@ -8,7 +8,7 @@ class YggdrasilServer
8
8
  Dir.mkdir @results_dir, 0755 unless File.exist?(@results_dir)
9
9
  result_file = "#@results_dir/#{arg_hash[:hostname]}_#{sock.peeraddr[3]}"
10
10
  File.delete result_file if File.exist?(result_file)
11
- File.open(result_file, "w") do |f|
11
+ File.open(result_file, 'w') do |f|
12
12
  f.write result_string
13
13
  end
14
14
  arg_hash
@@ -2,7 +2,7 @@ class YggdrasilServer
2
2
 
3
3
  # @param [Array] args
4
4
  def results(args)
5
- args = parse_options(args, {'--limit'=>:limit})
5
+ args = parse_options(args, {'--expire'=>:expire})
6
6
 
7
7
  if args.size != 0
8
8
  error "invalid arguments: #{args.join(',')}"
@@ -14,9 +14,9 @@ class YggdrasilServer
14
14
  files.each do |file|
15
15
  next if /^\./ =~ file
16
16
  absolute = "#@results_dir/#{file}"
17
- if @options.has_key?(:limit)
17
+ if @options.has_key?(:expire)
18
18
  stat = File.stat(absolute)
19
- if stat.mtime < (Time.now - @options[:limit].to_i * 60)
19
+ if stat.mtime < (Time.now - @options[:expire].to_i * 60)
20
20
  alert = true
21
21
  puts "######## #{file}: last check is too old: #{stat.mtime.to_s}"
22
22
  next
@@ -0,0 +1,14 @@
1
+ require 'yggdrasil'
2
+
3
+ class YggdrasilServer
4
+
5
+ def version
6
+ puts <<"EOS"
7
+ #@base_cmd, version #{Yggdrasil::VERSION}
8
+
9
+ Copyright (C) 2012-2013 Tomohisa Kusukawa.
10
+ Yggdrasil is open source software, see https://github.com/tkusukawa/yggdrasil/
11
+
12
+ EOS
13
+ end
14
+ end
@@ -1,13 +1,15 @@
1
1
  require 'socket'
2
2
 
3
- require "yggdrasil_common"
3
+ require 'yggdrasil_common'
4
4
 
5
- require "yggdrasil_server/init_server"
6
- require "yggdrasil_server/results"
5
+ require 'yggdrasil_server/version'
6
+ require 'yggdrasil_server/help'
7
+ require 'yggdrasil_server/init'
8
+ require 'yggdrasil_server/results'
7
9
 
8
- require "yggdrasil_server/get_repo"
9
- require "yggdrasil_server/get_ro_id_pw"
10
- require "yggdrasil_server/put_result"
10
+ require 'yggdrasil_server/get_repo'
11
+ require 'yggdrasil_server/get_ro_id_pw'
12
+ require 'yggdrasil_server/put_result'
11
13
 
12
14
  class YggdrasilServer
13
15
  MESSAGE_QUIT = 'quit'
@@ -17,17 +19,46 @@ class YggdrasilServer
17
19
  :put_result => [:hostname],
18
20
  }
19
21
 
22
+ def YggdrasilServer.command(args, input = nil)
23
+ $stdin = StringIO.new(input) if input != nil
24
+ ENV['LANG'] = 'en_US.UTF-8'
25
+
26
+ if args.size == 0
27
+ new(false).help([])
28
+ return
29
+ end
30
+ case args[0]
31
+ when 'daemon'
32
+ Process.daemon
33
+ YggdrasilServer.new.server(args[1..-1])
34
+ when 'debug'
35
+ args << '--debug'
36
+ YggdrasilServer.new.server(args[1..-1])
37
+ when 'help', '--help', 'h', '?'
38
+ new(false).help(args[1..-1])
39
+ when 'init'
40
+ new(false).init_server(args[1..-1])
41
+ when 'results'
42
+ YggdrasilServer.new.results(args[1..-1])
43
+ when 'version', '--version'
44
+ new(false).version
45
+ else
46
+ $stderr .puts "Unknown subcommand: '#{args[0]}'"
47
+ exit 1
48
+ end
49
+ end
50
+
20
51
  def initialize(exist_config = true)
21
52
  @base_cmd = File::basename($0)
22
53
  @current_dir = `readlink -f .`.chomp
23
- @config_dir = "#{ENV["HOME"]}/.yggdrasil"
54
+ @config_dir = "#{ENV['HOME']}/.yggdrasil"
24
55
  @server_config_file = "#@config_dir/server_config"
25
56
  @results_dir = "#@config_dir/results"
26
57
 
27
58
  return unless exist_config
28
59
  configs = read_config(@server_config_file)
29
- error "need 'port' in config file" unless (@port = configs[:port])
30
- error "need 'repo' in config file" unless (@repo = configs[:repo])
60
+ error 'need "port" in config file' unless (@port = configs[:port])
61
+ error 'need "repo" in config file' unless (@repo = configs[:repo])
31
62
  @ro_username = configs[:ro_username] if configs.has_key?(:ro_username)
32
63
  @ro_password = configs[:ro_password] if configs.has_key?(:ro_password)
33
64
  end
@@ -44,9 +75,11 @@ class YggdrasilServer
44
75
  loop do
45
76
  sock = s0.accept
46
77
  msg = sock.gets # first line
78
+ ctime = Time.now
47
79
  if msg && msg.chomp! != MESSAGE_QUIT
48
80
  msg.chomp!
49
- puts "RCV: #{msg}"
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
50
83
  msg_parts = msg.split
51
84
  if msg_parts.size != 0
52
85
  msg_cmd = msg_parts[0]
data/spec/add_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "add" do
3
+ describe Yggdrasil, 'add' do
4
4
  it '-------- add' do
5
5
  puts '-------- add'
6
6
  prepare_environment
data/spec/check_spec.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'yggdrasil_server'
2
3
 
3
- describe Yggdrasil, "check" do
4
- it '-------- check' do
4
+ describe Yggdrasil, 'check' do
5
+ before(:all) do
5
6
  puts '-------- check'
6
7
  prepare_environment
7
8
  init_yggdrasil
@@ -79,22 +80,22 @@ EOS
79
80
 
80
81
  sock = 0
81
82
  begin
82
- sock = TCPSocket.open("localhost", 4000)
83
+ sock = TCPSocket.open('localhost', 4000)
83
84
  rescue
84
- puts "OK. no server"
85
+ puts 'OK. no server'
85
86
  else
86
- puts "NG. zombie server. try quit"
87
- sock.puts("quit")
87
+ puts 'NG. zombie server. try quit'
88
+ sock.puts('quit')
88
89
  sock.close
89
90
  end
90
91
 
91
- Yggdrasil.command %w{init-server} +
92
+ YggdrasilServer.command %w{init} +
92
93
  %w{--port 4000} +
93
94
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/}+
94
95
  %w{--ro-username hoge --ro-password foo},
95
96
  "\n\n"
96
97
  fork do
97
- Yggdrasil.command %w{server --debug}
98
+ YggdrasilServer.command %w{debug}
98
99
  end
99
100
 
100
101
  sleep 1
@@ -105,8 +106,8 @@ EOS
105
106
  Yggdrasil.command %w{check}
106
107
 
107
108
  sleep 1
108
- File.exist?("/tmp/yggdrasil-test/.yggdrasil/results").should be_true
109
- files = Dir.entries("/tmp/yggdrasil-test/.yggdrasil/results")
109
+ File.exist?('/tmp/yggdrasil-test/.yggdrasil/results').should be_true
110
+ files = Dir.entries('/tmp/yggdrasil-test/.yggdrasil/results')
110
111
  result_files = files.select{|file| %r{^#{Socket.gethostname}} =~ file}
111
112
  result_files.size.should == 1
112
113
  `cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`.should == <<"EOS"
@@ -137,8 +138,8 @@ Index: tmp/yggdrasil-test/A
137
138
  +foo
138
139
  EOS
139
140
 
140
- sock = TCPSocket.open("localhost", 4000)
141
- sock.puts("quit")
141
+ sock = TCPSocket.open('localhost', 4000)
142
+ sock.puts('quit')
142
143
  sock.close
143
144
  Process.waitall
144
145
  end
data/spec/cleanup_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "cleanup" do
3
+ describe Yggdrasil, 'cleanup' do
4
4
  it '-------- cleanup' do
5
5
  puts '-------- cleanup'
6
6
  prepare_environment
@@ -8,15 +8,15 @@ describe Yggdrasil, "cleanup" do
8
8
  end
9
9
 
10
10
  it 'should success cleanup' do
11
- puts "---- should success cleanup"
12
- puts "-- rm .svn"
11
+ puts '---- should success cleanup'
12
+ puts '-- rm .svn'
13
13
  `rm -rf /tmp/yggdrasil-test/.yggdrasil/mirror/.svn`
14
14
 
15
- puts "-- cleanup"
15
+ puts '-- cleanup'
16
16
  Yggdrasil.command %w{cleanup --username hoge --password foo}
17
17
 
18
- puts "-- check .svn"
19
- res = File.exist?("/tmp/yggdrasil-test/.yggdrasil/mirror/.svn")
18
+ puts '-- check .svn'
19
+ res = File.exist?('/tmp/yggdrasil-test/.yggdrasil/mirror/.svn')
20
20
  p res
21
21
  res.should == true
22
22
  end
data/spec/commit_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "commit" do
3
+ describe Yggdrasil, 'commit' do
4
4
  it '-------- commit' do
5
5
  puts '-------- commit'
6
6
  prepare_environment
@@ -15,12 +15,12 @@ describe Yggdrasil, "commit" do
15
15
  puts '---- should commit added files'
16
16
  `echo hoge > /tmp/yggdrasil-test/A`
17
17
  `echo foo > /tmp/yggdrasil-test/B`
18
- FileUtils.cd "/tmp/yggdrasil-test" do
18
+ FileUtils.cd '/tmp/yggdrasil-test' do
19
19
  puts '-- add'
20
20
  Yggdrasil.command %w{add A /tmp/yggdrasil-test/B}
21
21
  end
22
22
 
23
- puts "-- commit"
23
+ puts '-- commit'
24
24
  FileUtils.cd '/tmp/yggdrasil-test' do
25
25
  Yggdrasil.command %w{commit --username hoge --password foo},
26
26
  "0\nY\nadd A and B\n"
@@ -38,11 +38,11 @@ describe Yggdrasil, "commit" do
38
38
  end
39
39
 
40
40
  it 'should commit modified file' do
41
- puts "---- should commit modified file"
42
- puts "-- modify"
41
+ puts '---- should commit modified file'
42
+ puts '-- modify'
43
43
  `echo hoge >> /tmp/yggdrasil-test/A`
44
44
 
45
- puts "-- commit"
45
+ puts '-- commit'
46
46
  Yggdrasil.command %w{commit / --username hoge --password foo},
47
47
  "0\nY\nmodify A\n"
48
48
 
@@ -53,11 +53,11 @@ describe Yggdrasil, "commit" do
53
53
  end
54
54
 
55
55
  it 'should commit with multi line comment' do
56
- puts "---- should commit with multi line comment"
57
- puts "-- modify"
56
+ puts '---- should commit with multi line comment'
57
+ puts '-- modify'
58
58
  `echo foo >> /tmp/yggdrasil-test/B`
59
59
 
60
- puts "-- commit"
60
+ puts '-- commit'
61
61
  Yggdrasil.command %w{commit / --username hoge --password foo},
62
62
  "Y\ntest commit\\\nmodify B\n"
63
63
 
@@ -69,7 +69,7 @@ describe Yggdrasil, "commit" do
69
69
  end
70
70
 
71
71
  it 'should accept password interactive' do
72
- puts "---- should accept password interactive"
72
+ puts '---- should accept password interactive'
73
73
  `echo A >> /tmp/yggdrasil-test/A`
74
74
 
75
75
  Yggdrasil.command %w{commit /tmp --username hoge},
@@ -82,7 +82,7 @@ describe Yggdrasil, "commit" do
82
82
  end
83
83
 
84
84
  it 'should commit specified file only' do
85
- puts "---- should commit specified file only"
85
+ puts '---- should commit specified file only'
86
86
  `echo A >> /tmp/yggdrasil-test/A`
87
87
  `echo B >> /tmp/yggdrasil-test/B`
88
88
 
@@ -97,7 +97,7 @@ describe Yggdrasil, "commit" do
97
97
  end
98
98
 
99
99
  it 'should not commit deleted file' do
100
- puts "---- should not commit deleted file"
100
+ puts '---- should not commit deleted file'
101
101
  `rm -f /tmp/yggdrasil-test/A`
102
102
 
103
103
  Yggdrasil.command %w{commit --username hoge --password foo -m delete},
@@ -109,7 +109,7 @@ describe Yggdrasil, "commit" do
109
109
  end
110
110
 
111
111
  it 'should commit deleted file' do
112
- puts "---- should commit deleted file"
112
+ puts '---- should commit deleted file'
113
113
  `echo hoge > /tmp/yggdrasil-test/A`
114
114
  `rm -f /tmp/yggdrasil-test/B`
115
115
 
@@ -124,7 +124,7 @@ describe Yggdrasil, "commit" do
124
124
  end
125
125
 
126
126
  it 'should commit all files at once' do
127
- puts "---- should commit all files at once"
127
+ puts '---- should commit all files at once'
128
128
 
129
129
  `echo HOGE >> /tmp/yggdrasil-test/A`
130
130
  `rm -f /tmp/yggdrasil-test/B`
data/spec/diff_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "diff" do
3
+ describe Yggdrasil, 'diff' do
4
4
  it '-------- diff' do
5
5
  puts '-------- diff'
6
6
  prepare_environment
@@ -12,9 +12,9 @@ describe Yggdrasil, "diff" do
12
12
  end
13
13
 
14
14
  it 'should success diff (absolute/relative path)' do
15
- puts "---- should success diff (absolute/relative path)"
15
+ puts '---- should success diff (absolute/relative path)'
16
16
  out = catch_out do
17
- FileUtils.cd "/tmp/yggdrasil-test" do
17
+ FileUtils.cd '/tmp/yggdrasil-test' do
18
18
  Yggdrasil.command(%w{diff /tmp/yggdrasil-test/A B --username hoge --password foo})
19
19
  end
20
20
  end
@@ -39,9 +39,9 @@ EOS
39
39
  end
40
40
 
41
41
  it 'should success (no path)' do
42
- puts "---- should success (no path)"
42
+ puts '---- should success (no path)'
43
43
  out = catch_out do
44
- FileUtils.cd "/tmp/yggdrasil-test" do
44
+ FileUtils.cd '/tmp/yggdrasil-test' do
45
45
  Yggdrasil.command %w{diff --username hoge --password foo}
46
46
  end
47
47
  end
@@ -66,9 +66,9 @@ EOS
66
66
  end
67
67
 
68
68
  it 'should success (-r)' do
69
- puts "---- should success (-r)"
69
+ puts '---- should success (-r)'
70
70
  out = catch_out do
71
- FileUtils.cd "/tmp/yggdrasil-test" do
71
+ FileUtils.cd '/tmp/yggdrasil-test' do
72
72
  Yggdrasil.command %w{diff -r 2:3 A --username hoge --password foo}
73
73
  end
74
74
  end
@@ -84,9 +84,9 @@ EOS
84
84
  end
85
85
 
86
86
  it 'should success (--revision)' do
87
- puts "---- should success (--revision)"
87
+ puts '---- should success (--revision)'
88
88
  out = catch_out do
89
- FileUtils.cd "/tmp/yggdrasil-test" do
89
+ FileUtils.cd '/tmp/yggdrasil-test' do
90
90
  Yggdrasil.command %w{diff --revision 3 A --username hoge --password foo}
91
91
  end
92
92
  end
@@ -103,17 +103,17 @@ EOS
103
103
  end
104
104
 
105
105
  it 'should error: diff with incorrect option' do
106
- puts "---- should error: diff with incorrect option"
106
+ puts '---- should error: diff with incorrect option'
107
107
  cmd = %w{diff --hoge --username hoge --password foo}
108
108
 
109
109
  err = catch_err do
110
- FileUtils.cd "/" do
110
+ FileUtils.cd '/' do
111
111
  lambda{Yggdrasil.command cmd}.should raise_error(SystemExit)
112
112
  end
113
113
  end
114
114
  err.sub!(%r{/\S*svn}, 'svn')
115
115
  err.should == <<"EOS"
116
- #{File.basename($0)} error: command failure: svn diff --no-auth-cache --non-interactive --username hoge --password foo --hoge
116
+ #{File.basename($0)} error: command failure: svn ...
117
117
  command output:
118
118
  svn: invalid option: --hoge
119
119
  Type 'svn help' for usage.
data/spec/help_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "help" do
3
+ describe Yggdrasil, 'help' do
4
4
  puts '-------- help'
5
5
 
6
6
  show_subcommands = <<"EOS"
@@ -16,18 +16,15 @@ Available subcommands:
16
16
  diff (di)
17
17
  help (?, h)
18
18
  init
19
- init-server
20
19
  list (ls)
21
20
  log
22
- results
23
21
  revert
24
- server
25
22
  status (stat, st)
26
23
  update
27
24
  version
28
25
 
29
26
  Yggdrasil is a subversion wrapper to manage server configurations and conditions.
30
- You should type 'yggdrasil init' at first.
27
+ At first, you should type '#{File.basename($0)} init' to create config file.
31
28
 
32
29
  EOS
33
30
 
@@ -286,33 +283,16 @@ usage: #{File.basename($0)} check [OPTIONS...]
286
283
  For example, mount status, number of specific process and etc. can be checked
287
284
  by setting up executable files in ~/.yggdrasil/checker/
288
285
 
289
- if the server is registered, the yggdrasil server receive and record the results.
286
+ If the yggdrasil server is registered,
287
+ this subcommand send the result to yggdrasil server
288
+ and yggdrasil server record the results for all managed servers.
289
+ Type 'yggserve help', if you need to know about yggdrasil server.
290
290
 
291
291
  Valid options:
292
292
  --username ARG : specify a username ARG
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 init-server' do
300
- puts '---- should show help of init-server'
301
- out = catch_out{Yggdrasil.command %w{help init-server}}
302
- out.should == <<"EOS"
303
- init-server: setup server configuration.
304
- usage: #{File.basename($0)} init-server [OPTIONS...]
305
-
306
- Valid options:
307
- --port ARG : specify a TCP port number ARG
308
- --repo ARG : URL of subversion repository
309
- ARG can contain {HOST} or a {host}
310
- {HOST} is replaced by client hostname with domain
311
- {host} is replaced by client hostname without domain
312
- e.g. svn://192.168.3.5/servers/{host}/ygg
313
- --ro-username ARG : specify a username ARG for read only
314
- --ro-password ARG : specify a password ARG for read only
315
-
316
296
  EOS
317
297
  end
318
298
 
@@ -326,19 +306,6 @@ usage: #{File.basename($0)} server [OPTIONS...]
326
306
  Valid options:
327
307
  --daemon : daemon mode
328
308
 
329
- EOS
330
- end
331
-
332
- it 'should show help of results' do
333
- puts '---- should show help of results'
334
- out = catch_out{Yggdrasil.command %w{help results}}
335
- out.should == <<"EOS"
336
- results: display the result of yggdrasil check command.
337
- usage: #{File.basename($0)} results [OPTIONS...]
338
-
339
- Valid options:
340
- --limit ARG : minutes from the final report, to judge the host not be alive
341
-
342
309
  EOS
343
310
  end
344
311
  end
data/spec/init_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "init" do
3
+ describe Yggdrasil, 'init' do
4
4
  it '-------- init' do
5
5
  puts '-------- init'
6
6
  prepare_environment
@@ -80,7 +80,7 @@ describe Yggdrasil, "init" do
80
80
  Yggdrasil.command %w{init --debug} +
81
81
  %w{--repo private}
82
82
 
83
- File.exist?("/tmp/yggdrasil-test/.yggdrasil/config").should be_true
83
+ File.exist?('/tmp/yggdrasil-test/.yggdrasil/config').should be_true
84
84
  end
85
85
 
86
86
  it 'should success: create config file (interactive)' do
@@ -90,11 +90,11 @@ describe Yggdrasil, "init" do
90
90
  `rm -rf /tmp/yggdrasil-test/svn-repo`
91
91
  `svnadmin create /tmp/yggdrasil-test/svn-repo`
92
92
 
93
- File.open("/tmp/yggdrasil-test/svn-repo/conf/passwd", "w") do |f|
93
+ File.open('/tmp/yggdrasil-test/svn-repo/conf/passwd', 'w') do |f|
94
94
  f.write "[users]\nhoge = foo"
95
95
  end
96
96
 
97
- File.open("/tmp/yggdrasil-test/svn-repo/conf/svnserve.conf", "w") do |f|
97
+ File.open('/tmp/yggdrasil-test/svn-repo/conf/svnserve.conf', 'w') do |f|
98
98
  f.write <<"EOS"
99
99
  [general]
100
100
  anon-access = none
@@ -112,21 +112,21 @@ EOS
112
112
  "Y\n"
113
113
  end
114
114
  out.should == \
115
- "Input svn repo URL: "\
115
+ 'Input svn repo URL: '\
116
116
  "check SVN access...\n"\
117
- "Input svn username: "\
117
+ 'Input svn username: '\
118
118
  "Input svn password: \n"\
119
119
  "SVN access OK: svn://localhost/tmp/yggdrasil-test/svn-repo\n"\
120
120
  "not exist directory(s): mng-repo/host-name\n"\
121
- "make directory(s)? [Yn]: "
121
+ 'make directory(s)? [Yn]: '
122
122
  end
123
123
 
124
124
  it 'should make checker example at init' do
125
125
  puts "\n---- should make checker example at init"
126
- dir = "/tmp/yggdrasil-test/.yggdrasil/checker"
126
+ dir = '/tmp/yggdrasil-test/.yggdrasil/checker'
127
127
  File.directory?(dir).should be_true
128
128
 
129
- example_checker = dir + "/gem_list"
129
+ example_checker = dir + '/gem_list'
130
130
  File.executable?(example_checker).should be_true
131
131
  end
132
132
 
@@ -134,23 +134,23 @@ EOS
134
134
  puts '---- should success init subcommand with server option'
135
135
  prepare_environment
136
136
 
137
- Yggdrasil.command %w{init-server} +
137
+ YggdrasilServer.command %w{init} +
138
138
  %w{--port 4000} +
139
139
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
140
140
  %w{--ro-username hoge} +
141
141
  %w{--ro-password foo}
142
142
  fork do
143
- Yggdrasil.command %w{server --debug}
143
+ YggdrasilServer.command %w{debug}
144
144
  end
145
145
 
146
146
  sleep 1
147
147
  Yggdrasil.command %w{init --debug --server localhost:4000},
148
148
  "Y\nhoge\nfoo\n"
149
149
 
150
- File.exist?("/tmp/yggdrasil-test/.yggdrasil/config").should be_true
150
+ File.exist?('/tmp/yggdrasil-test/.yggdrasil/config').should be_true
151
151
 
152
- sock = TCPSocket.open("localhost", 4000)
153
- sock.puts("quit")
152
+ sock = TCPSocket.open('localhost', 4000)
153
+ sock.puts('quit')
154
154
  sock.close
155
155
  Process.waitall
156
156
  end
data/spec/list_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "list" do
3
+ describe Yggdrasil, 'list' do
4
4
  it '-------- list' do
5
5
  puts '-------- list'
6
6
  prepare_environment
@@ -17,7 +17,7 @@ describe Yggdrasil, "list" do
17
17
  it 'should show list (relative path)' do
18
18
  puts '---- should show list (relative path)'
19
19
  out = catch_out do
20
- FileUtils.cd "/tmp" do
20
+ FileUtils.cd '/tmp' do
21
21
  Yggdrasil.command %w{list yggdrasil-test}+
22
22
  %w{--username hoge --password foo}
23
23
  end
@@ -28,7 +28,7 @@ describe Yggdrasil, "list" do
28
28
  it 'should show list (no path)' do
29
29
  puts '---- should show list (no path)'
30
30
  out = catch_out do
31
- FileUtils.cd "/tmp/yggdrasil-test" do
31
+ FileUtils.cd '/tmp/yggdrasil-test' do
32
32
  Yggdrasil.command %w{list} +
33
33
  %w{--username hoge --password foo}
34
34
  end