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.2'
FOLDER =
/(.*)\/(.*)/
DATA_PATH =
File.join(HOME_PATH, 'six-rsync')
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



80
81
82
# File 'lib/six/rsync.rb', line 80

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)


117
118
119
# File 'lib/six/rsync.rb', line 117

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

.hostObject



21
22
23
# File 'lib/six/rsync-app.rb', line 21

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'


103
104
105
# File 'lib/six/rsync.rb', line 103

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

.loggerObject



17
18
19
# File 'lib/six/rsync-app.rb', line 17

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'


94
95
96
# File 'lib/six/rsync.rb', line 94

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
# 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

    opts.on("-l", "--log", "Write logfile") do |bool|
      options[:logging] = bool if bool
    end
  end.parse!

  [options, todo]
end