Module: Six::Repositories::Rsync

Defined in:
lib/six/rsync.rb,
lib/six/rsync-app.rb,
lib/six/rsync/lib.rb,
lib/six/rsync/base.rb,
lib/six/rsync/path.rb,
lib/six/rsync/options.rb,
lib/six/rsync/repository.rb,
lib/six/rsync/working_directory.rb

Defined Under Namespace

Classes: App, Base, Lib, Path, Repository, RsyncError, RsyncExecuteError, WorkingDirectory

Constant Summary collapse

VERSION =
'0.4.1'
TOOLS_PATH =
File.join(BASE_PATH, 'tools')
FOLDER =
/(.*)\/(.*)/
TEMP_PATH =
if ENV['TEMP']
  if ENV['TEMP'].size > 0
    if File.directory?(ENV['TEMP'])
      ENV['TEMP']
    else
      BASE_PATH
    end
  else
    BASE_PATH
  end
else
  BASE_PATH
end
COMPONENT =
'six-rsync'
KEY =

TODO: Configure somewhere!

"C:/users/sb/documents/keys/id_rsa.ppk"
RSH =

TODO: Linux

"-r --rsh=\"'#{File.join(BASE_PATH, "tools", "bin", "cygnative.exe")}' plink.exe -i #{KEY}\""
DIR_RSYNC =
'.rsync'
DIR_PACK =
File.join(DIR_RSYNC, '.pack')
REGEX_FOLDER =
/(.*)[\\|\/](.*)/
@@log =

Create loggers

Log4r::Logger.new(COMPONENT)
@@host =
''

Class Method Summary collapse

Class Method Details

.bare(rsync_dir, options = {}) ⇒ Object

open a bare repository

this takes the path to a bare rsync repo it expects not to be able to use a working directory so you can’t checkout stuff, commit things, etc. but you can do most read operations



61
62
63
# File 'lib/six/rsync.rb', line 61

def self.bare(rsync_dir, options = {})
  Base.bare(rsync_dir, options)
end

.clone(repository, name, options = {}) ⇒ Object

clones a remote repository

options

:bare => true (does a bare clone)
:repository => '/path/to/alt_rsync_dir'
:index => '/path/to/alt_index_file'

example

Rsync.clone('rsync://repo.or.cz/ruby', 'clone', :bare => true)


98
99
100
# File 'lib/six/rsync.rb', line 98

def self.clone(repository, name, options = {})
  Base.clone(repository, name, options)
end

.hostObject



47
48
49
# File 'lib/six/rsync-app.rb', line 47

def host
  @@host
end

.init(working_dir = '.', options = {}) ⇒ Object

initialize a new rsync repository, defaults to the current working directory

options

:repository => '/path/to/alt_rsync_dir'
:index => '/path/to/alt_index_file'


84
85
86
# File 'lib/six/rsync.rb', line 84

def self.init(working_dir = '.', options = {})
  Base.init(working_dir, options)
end

.loggerObject



44
45
46
# File 'lib/six/rsync-app.rb', line 44

def logger
  @@log
end

.open(working_dir, options = {}) ⇒ Object

open an existing rsync working directory

this will most likely be the most common way to create a rsync reference, referring to a working directory. if not provided in the options, the library will assume your rsync_dir is in the default place (.rsync/)

options

:repository => '/path/to/alt_rsync_dir'
:index => '/path/to/alt_index_file'


75
76
77
# File 'lib/six/rsync.rb', line 75

def self.open(working_dir, options = {})
  Base.open(working_dir, options)
end

.parse_optionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/six/rsync/options.rb', line 11

def parse_options
  todo = [] #, general_todo, second_todo = [], [], []

  options = Hash.new
  OptionParser.new do |opts|
    $0[/.*\/(.*)/]
    opts.banner = "Usage: #{$1} [folder] [options]"

    opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
      options[:verbose] = v
    end

    opts.on("-i", "--init", "Initializes Repository") do |bool|
      todo << :init if bool
    end

    opts.on("-s", "--status", "Status of Repository") do |bool|
      todo << :status if bool
    end

    opts.on("-u", "--update", "Updates Repository") do |bool|
      todo << :update if bool
    end

    opts.on("-c", "--commit", "Commits changes to Repository") do |bool|
      todo << :commit if bool
    end

    opts.on("--clone S", String, "Clones a Repository") do |s|
      todo << :clone
      @@host = s
    end

=begin
  opts.on("--depth I", Integer, "Clone depth, default: #{@config[:depth]}. Set to 0 to clone all history") do |s|
    options[:depth] = s
  end

  opts.on("--mods S", String, "Additional Mods") do |s|
    options[:mods] = s
  end
=end
  end.parse!
  @@options = todo
=begin
default = if (todo + second_todo + general_todo).size > 0
  false
else
  true
end

# TODO: Move this to Updater ?
@todo = if todo.size > 0
  todo
else
  log.info "No parameters given, running the default"
  #options[:wait] = true
  if default
    @config[:defaultactions]
  else
    []
  end
end
@general_todo = if general_todo.size > 0
  general_todo
else
  if default
    @config[:defaultgeneralactions]
  else
    []
  end
end

@second_todo = if second_todo.size > 0
  second_todo
else
  if default
    @config[:defaultsecondactions]
  else
    []
  end
end
@config = @config.merge(options)
=end
end