six-rsync 0.1.3 → 0.1.4
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/Rakefile +1 -1
- data/lib/six/rsync/lib.rb +1 -1
- data/lib/six/rsync/options.rb +94 -0
- data/lib/six/rsync-app.rb +102 -0
- data/lib/six/rsync.rb +3 -2
- metadata +4 -2
data/Rakefile
CHANGED
data/lib/six/rsync/lib.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Docu: http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
module Six
|
7
|
+
module Repositories
|
8
|
+
module Rsync
|
9
|
+
module_function
|
10
|
+
def parse_options
|
11
|
+
todo = [] #, general_todo, second_todo = [], [], []
|
12
|
+
|
13
|
+
options = Hash.new
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
$0[/.*\/(.*)/]
|
16
|
+
opts.banner = "Usage: #{$1} [folder] [options]"
|
17
|
+
|
18
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
19
|
+
options[:verbose] = v
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-i", "--init", "Initializes Repository") do |bool|
|
23
|
+
todo << :init if bool
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on("-u", "--update", "Updates Repository") do |bool|
|
27
|
+
todo << :update if bool
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("-c", "--commit", "Commits changes to Repository") do |bool|
|
31
|
+
todo << :commit if bool
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("--clone S", String, "Clones a Repository") do |s|
|
35
|
+
todo << :clone
|
36
|
+
@@host = s
|
37
|
+
end
|
38
|
+
|
39
|
+
=begin
|
40
|
+
opts.on("--depth I", Integer, "Clone depth, default: #{@config[:depth]}. Set to 0 to clone all history") do |s|
|
41
|
+
options[:depth] = s
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("--mods S", String, "Additional Mods") do |s|
|
45
|
+
options[:mods] = s
|
46
|
+
end
|
47
|
+
=end
|
48
|
+
end.parse!
|
49
|
+
@@options = todo
|
50
|
+
=begin
|
51
|
+
default = if (todo + second_todo + general_todo).size > 0
|
52
|
+
false
|
53
|
+
else
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
# TODO: Move this to Updater ?
|
58
|
+
@todo = if todo.size > 0
|
59
|
+
todo
|
60
|
+
else
|
61
|
+
log.info "No parameters given, running the default"
|
62
|
+
#options[:wait] = true
|
63
|
+
if default
|
64
|
+
@config[:defaultactions]
|
65
|
+
else
|
66
|
+
[]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@general_todo = if general_todo.size > 0
|
70
|
+
general_todo
|
71
|
+
else
|
72
|
+
if default
|
73
|
+
@config[:defaultgeneralactions]
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
@second_todo = if second_todo.size > 0
|
80
|
+
second_todo
|
81
|
+
else
|
82
|
+
if default
|
83
|
+
@config[:defaultsecondactions]
|
84
|
+
else
|
85
|
+
[]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
@config = @config.merge(options)
|
89
|
+
=end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# TODO: Cleanup mess
|
4
|
+
|
5
|
+
require 'log4r'
|
6
|
+
require 'six/rsync'
|
7
|
+
require 'six/rsync/options'
|
8
|
+
|
9
|
+
module Six
|
10
|
+
module Repositories
|
11
|
+
module Rsync
|
12
|
+
COMPONENT = 'six-rsync'
|
13
|
+
|
14
|
+
# Create loggers
|
15
|
+
@@log = Log4r::Logger.new(COMPONENT)
|
16
|
+
if defined?(DEBUG)
|
17
|
+
format1 = Log4r::PatternFormatter.new(:pattern => "[%l] %d: %m", :date_pattern => '%H:%M:%S')
|
18
|
+
else
|
19
|
+
format1 = Log4r::PatternFormatter.new(:pattern => "%m")
|
20
|
+
end
|
21
|
+
format2 = Log4r::PatternFormatter.new(:pattern => "[%l] %c %d: %m", :date_pattern => '%H:%M:%S')
|
22
|
+
|
23
|
+
# Create Outputters
|
24
|
+
o_file = Log4r::FileOutputter.new "#{COMPONENT}-file",
|
25
|
+
'level' => 0, # All
|
26
|
+
:filename => "#{COMPONENT}.log",
|
27
|
+
'formatter' => format2
|
28
|
+
#:maxsize => 1024
|
29
|
+
|
30
|
+
@@log.outputters << o_file
|
31
|
+
|
32
|
+
o_out = Log4r::StdoutOutputter.new "#{COMPONENT}-stdout",
|
33
|
+
'level' => 2, # no DEBUG
|
34
|
+
'formatter' => format1
|
35
|
+
|
36
|
+
o_err = Log4r::StderrOutputter.new "#{COMPONENT}-stderr",
|
37
|
+
'level' => 4, # Error and Up
|
38
|
+
'formatter' => format1
|
39
|
+
|
40
|
+
@@log.outputters << o_out << o_err
|
41
|
+
|
42
|
+
module_function
|
43
|
+
def logger
|
44
|
+
@@log
|
45
|
+
end
|
46
|
+
|
47
|
+
class App
|
48
|
+
attr_reader :repo
|
49
|
+
def logger
|
50
|
+
Six::Repositories::Rsync.logger
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize(folder)
|
54
|
+
@folder = folder
|
55
|
+
@repo = Six::Repositories::Rsync.open(folder, :log => logger)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.open(folder)
|
59
|
+
app = self.new(folder)
|
60
|
+
app
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.commit(folder)
|
64
|
+
app = self.new(folder)
|
65
|
+
app.repo.commit
|
66
|
+
app
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.update(folder)
|
70
|
+
app = self.new(folder)
|
71
|
+
app.repo.update
|
72
|
+
app
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.clone(host)
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.init(folder)
|
80
|
+
# if File.exists?(folder)
|
81
|
+
# logger.error "#{folder} already exists!"
|
82
|
+
# Process.exit
|
83
|
+
# end
|
84
|
+
@repo = Six::Repositories::Rsync.init(folder, :log => Six::Repositories::Rsync.logger)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
parse_options
|
89
|
+
|
90
|
+
unless ARGV[0]
|
91
|
+
logger.error "No folder argument given!"
|
92
|
+
Process.exit
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
#app = App.new(ARGV[0])
|
97
|
+
@@options.each do |option|
|
98
|
+
App.send option, ARGV[0]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/six/rsync.rb
CHANGED
@@ -15,7 +15,8 @@ require 'six/rsync/base'
|
|
15
15
|
require 'open3'
|
16
16
|
#require 'win32/open3'
|
17
17
|
|
18
|
-
|
18
|
+
case RUBY_VERSION
|
19
|
+
when /1\.8\.[0-9]/
|
19
20
|
class Array
|
20
21
|
def sample
|
21
22
|
self[rand self.size]
|
@@ -29,7 +30,7 @@ module Six
|
|
29
30
|
end
|
30
31
|
|
31
32
|
module Rsync
|
32
|
-
VERSION = '0.1.
|
33
|
+
VERSION = '0.1.4'
|
33
34
|
TOOLS_PATH = File.join(BASE_PATH, 'tools')
|
34
35
|
FOLDER = /(.*)\/(.*)/
|
35
36
|
ENV['PATH'] = ENV['PATH'] + ";#{TOOLS_PATH};#{File.join(TOOLS_PATH, 'bin')}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: six-rsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sickboy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-30 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,9 +28,11 @@ files:
|
|
28
28
|
- Rakefile
|
29
29
|
- lib/six/rsync/base.rb
|
30
30
|
- lib/six/rsync/lib.rb
|
31
|
+
- lib/six/rsync/options.rb
|
31
32
|
- lib/six/rsync/path.rb
|
32
33
|
- lib/six/rsync/repository.rb
|
33
34
|
- lib/six/rsync/working_directory.rb
|
35
|
+
- lib/six/rsync-app.rb
|
34
36
|
- lib/six/rsync.rb
|
35
37
|
has_rdoc: true
|
36
38
|
homepage:
|