Module: CouchReplicate
- Defined in:
- lib/couch_replicate.rb,
lib/couch_replicate/command_line.rb
Defined Under Namespace
Classes: CommandLine
Class Method Summary collapse
- .link(db, hosts) ⇒ Object
- .nth(n, db, hosts) ⇒ Object
- .replicate(source_host, target_host, db) ⇒ Object
- .reverse_link(db, hosts) ⇒ Object
- .version ⇒ Object
Class Method Details
.link(db, hosts) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/couch_replicate.rb', line 15 def self.link(db, hosts) Array(hosts).each_cons(2) do |src, target| self.replicate(src, target, db) end self.replicate(hosts.last, hosts.first, db) end |
.nth(n, db, hosts) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/couch_replicate.rb', line 26 def self.nth(n, db, hosts) return if n == db.length + 1 (Array(hosts) + Array(hosts)[0..n]).each_cons(n+1) do |src, *n_hosts| self.replicate(src, n_hosts.last, db) end end |
.replicate(source_host, target_host, db) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/couch_replicate.rb', line 8 def self.replicate(source_host, target_host, db) source = hostify(source_host) target = hostify(target_host) RestClient.post("#{target}/_replicate", %Q|{"source":"#{source}/#{db}", "target":"#{db}", "continuous":true}|) end |
.reverse_link(db, hosts) ⇒ Object
22 23 24 |
# File 'lib/couch_replicate.rb', line 22 def self.reverse_link(db, hosts) self.link(db, hosts.reverse) end |
.version ⇒ Object
4 5 6 |
# File 'lib/couch_replicate.rb', line 4 def self.version File.read(File.(File.dirname(__FILE__) + '/../VERSION')).chomp end |