six-rsync 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'six-rsync'
15
- s.version = '0.4.1'
15
+ s.version = '0.4.2'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README', 'LICENSE']
18
18
  s.summary = 'Your summary here'
data/lib/six/rsync/lib.rb CHANGED
@@ -44,16 +44,6 @@ module Six
44
44
  @rsync_dir = base[:repository]
45
45
  @rsync_work_dir = base[:working_directory]
46
46
  end
47
-
48
- etc = File.join(TOOLS_PATH, 'etc')
49
- FileUtils.mkdir_p etc
50
- fstab = File.join(etc, 'fstab')
51
- str = ""
52
- str = File.open(fstab) {|file| file.read} if File.exists?(fstab)
53
- unless str[/cygdrive/]
54
- str += "\nnone /cygdrive cygdrive user,noacl,posix=0 0 0\n"
55
- File.open(fstab, 'w') {|file| file.puts str}
56
- end
57
47
  end
58
48
 
59
49
  def status
@@ -101,8 +91,10 @@ module Six
101
91
  raise RsyncError
102
92
  end
103
93
  if File.exists? @rsync_work_dir
104
- @logger.error "Seems to already be a folder, Aborting!"
105
- raise RsyncError
94
+ unless Dir[File.join(@rsync_work_dir, '*')].empty?
95
+ @logger.error "Seems to already be a folder, Aborting!"
96
+ raise RsyncError
97
+ end
106
98
  end
107
99
  FileUtils.mkdir_p pack_path
108
100
  save_config(config)
@@ -422,7 +414,7 @@ module Six
422
414
  else
423
415
  c = mismatch.size
424
416
  @logger.info "Fetching #{mismatch.size} files... Please wait"
425
- slist = File.join(TEMP_PATH, ".six-updater_#{rand 9999}-list")
417
+ slist = File.join(TEMP_PATH, ".six-rsync_#{rand 9999}-list")
426
418
  slist.gsub!("\\", "/")
427
419
  File.open(slist, 'w') do |f|
428
420
  mismatch.each { |e| f.puts e }
@@ -41,57 +41,12 @@ module Six
41
41
  @@host = s
42
42
  end
43
43
 
44
- =begin
45
- opts.on("--depth I", Integer, "Clone depth, default: #{@config[:depth]}. Set to 0 to clone all history") do |s|
46
- options[:depth] = s
47
- end
48
-
49
- opts.on("--mods S", String, "Additional Mods") do |s|
50
- options[:mods] = s
51
- end
52
- =end
44
+ opts.on("-l", "--log", "Write logfile") do |bool|
45
+ options[:logging] = bool if bool
46
+ end
53
47
  end.parse!
54
- @@options = todo
55
- =begin
56
- default = if (todo + second_todo + general_todo).size > 0
57
- false
58
- else
59
- true
60
- end
61
48
 
62
- # TODO: Move this to Updater ?
63
- @todo = if todo.size > 0
64
- todo
65
- else
66
- log.info "No parameters given, running the default"
67
- #options[:wait] = true
68
- if default
69
- @config[:defaultactions]
70
- else
71
- []
72
- end
73
- end
74
- @general_todo = if general_todo.size > 0
75
- general_todo
76
- else
77
- if default
78
- @config[:defaultgeneralactions]
79
- else
80
- []
81
- end
82
- end
83
-
84
- @second_todo = if second_todo.size > 0
85
- second_todo
86
- else
87
- if default
88
- @config[:defaultsecondactions]
89
- else
90
- []
91
- end
92
- end
93
- @config = @config.merge(options)
94
- =end
49
+ [options, todo]
95
50
  end
96
51
 
97
52
  end
data/lib/six/rsync-app.rb CHANGED
@@ -12,43 +12,19 @@ module Six
12
12
  module Rsync
13
13
  COMPONENT = 'six-rsync'
14
14
 
15
- # Create loggers
16
- @@log = Log4r::Logger.new(COMPONENT)
17
- if defined?(DEBUG)
18
- format1 = Log4r::PatternFormatter.new(:pattern => "[%l] %d: %m", :date_pattern => '%H:%M:%S')
19
- else
20
- format1 = Log4r::PatternFormatter.new(:pattern => "%m")
21
- end
22
- format2 = Log4r::PatternFormatter.new(:pattern => "[%l] %c %d: %m", :date_pattern => '%H:%M:%S')
23
-
24
- # Create Outputters
25
- o_file = Log4r::FileOutputter.new "#{COMPONENT}-file",
26
- 'level' => 0, # All
27
- :filename => "#{COMPONENT}.log",
28
- 'formatter' => format2
29
- #:maxsize => 1024
30
-
31
- @@log.outputters << o_file
32
-
33
- o_out = Log4r::StdoutOutputter.new "#{COMPONENT}-stdout",
34
- 'level' => 2, # no DEBUG
35
- 'formatter' => format1
36
-
37
- o_err = Log4r::StderrOutputter.new "#{COMPONENT}-stderr",
38
- 'level' => 4, # Error and Up
39
- 'formatter' => format1
40
-
41
- @@log.outputters << o_out << o_err
42
-
43
15
  module_function
16
+
44
17
  def logger
45
18
  @@log
46
19
  end
20
+
47
21
  def host
48
22
  @@host
49
23
  end
24
+
50
25
  class App
51
26
  attr_reader :repo
27
+
52
28
  def logger
53
29
  Six::Repositories::Rsync.logger
54
30
  end
@@ -96,22 +72,52 @@ module Six
96
72
  end
97
73
  end
98
74
 
99
- unless defined?(Ocra)
100
- parse_options
75
+ unless defined?(Ocra)
76
+ options, todo = parse_options
77
+
78
+ # Create loggers
79
+ @@log = Log4r::Logger.new(COMPONENT)
80
+ format1 = if defined?(DEBUG)
81
+ Log4r::PatternFormatter.new(:pattern => "[%l] %d: %m", :date_pattern => '%H:%M:%S')
82
+ else
83
+ Log4r::PatternFormatter.new(:pattern => "%m")
84
+ end
85
+ format2 = Log4r::PatternFormatter.new(:pattern => "[%l] %c %d: %m", :date_pattern => '%H:%M:%S')
86
+
87
+ # Create Outputters
88
+ if options[:logging]
89
+ o_file = Log4r::FileOutputter.new "#{COMPONENT}-file",
90
+ 'level' => 0, # All
91
+ :filename => "#{COMPONENT}.log",
92
+ 'formatter' => format2
93
+ #:maxsize => 1024
94
+ @@log.outputters << o_file
95
+ end
96
+
97
+ o_out = Log4r::StdoutOutputter.new "#{COMPONENT}-stdout",
98
+ 'level' => 2, # no DEBUG
99
+ 'formatter' => format1
101
100
 
102
- if ARGV.empty?
103
- logger.error "No folder argument given!"
104
- Process.exit
105
- end
101
+ o_err = Log4r::StderrOutputter.new "#{COMPONENT}-stderr",
102
+ 'level' => 4, # Error and Up
103
+ 'formatter' => format1
106
104
 
105
+ @@log.outputters << o_out << o_err
107
106
 
108
- #app = App.new(ARGV[0])
109
- ARGV.each do |arg|
110
- @@options.each do |option|
111
- App.send option, arg
112
- end
113
- end
114
- end
115
- end
107
+ if ARGV.empty?
108
+ ARGV << '.'
109
+ #logger.error "Using current folder"
110
+ #Process.exit
111
+ end
112
+
113
+
114
+ #app = App.new(ARGV[0])
115
+ ARGV.each do |arg|
116
+ todo.each do |option|
117
+ App.send option, arg
118
+ end
119
+ end
120
+ end
121
+ end
116
122
  end
117
123
  end
data/lib/six/rsync.rb CHANGED
@@ -30,24 +30,43 @@ module Six
30
30
  end
31
31
 
32
32
  module Rsync
33
- VERSION = '0.4.1'
34
- TOOLS_PATH = File.join(BASE_PATH, 'tools')
35
-
33
+ VERSION = '0.4.2'
36
34
  FOLDER = /(.*)\/(.*)/
37
- ENV['PATH'] = "#{TOOLS_PATH};#{File.join(TOOLS_PATH, 'bin')};#{ENV['PATH']}"
38
- TEMP_PATH = if ENV['TEMP']
39
- if ENV['TEMP'].size > 0
40
- if File.directory?(ENV['TEMP'])
41
- ENV['TEMP']
35
+
36
+ case RUBY_PLATFORM
37
+ when "i386-mingw32"
38
+ HOME_PATH = File.join(ENV['APPDATA'])
39
+ TEMP_PATH = if ENV['TEMP']
40
+ if ENV['TEMP'].size > 0
41
+ if File.directory?(ENV['TEMP'])
42
+ ENV['TEMP']
43
+ else
44
+ BASE_PATH
45
+ end
46
+ else
47
+ BASE_PATH
48
+ end
42
49
  else
43
50
  BASE_PATH
44
51
  end
52
+
53
+ TOOLS_PATH = File.join(BASE_PATH, 'tools')
54
+ ENV['PATH'] = "#{TOOLS_PATH};#{File.join(TOOLS_PATH, 'bin')};#{ENV['PATH']}"
55
+
56
+ etc = File.join(TOOLS_PATH, 'etc')
57
+ FileUtils.mkdir_p etc
58
+ fstab = File.join(etc, 'fstab')
59
+ str = ""
60
+ str = File.open(fstab) {|file| file.read} if File.exists?(fstab)
61
+ unless str[/cygdrive/]
62
+ str += "\nnone /cygdrive cygdrive user,noacl,posix=0 0 0\n"
63
+ File.open(fstab, 'w') {|file| file.puts str}
64
+ end
45
65
  else
46
- BASE_PATH
47
- end
48
- else
49
- BASE_PATH
66
+ HOME_PATH = '~'
67
+ TEMP_PATH = '/tmp'
50
68
  end
69
+ DATA_PATH = File.join(HOME_PATH, 'six-rsync')
51
70
 
52
71
  # No meaning on Cygwin 1.7
53
72
  # ENV['CYGWIN'] = "nontsec"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 1
9
- version: 0.4.1
8
+ - 2
9
+ version: 0.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sickboy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-20 00:00:00 +02:00
17
+ date: 2010-04-21 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency