Class: TransparentGit::RemoteTrackers

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/transparent_git/remote_trackers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_yaml(f) ⇒ Object



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
# File 'lib/transparent_git/remote_trackers.rb', line 25

def create_from_yaml(f)
  str = File.read(f)
  puts str
  raise "file is empty" if str.blank?

  h = YAML::load(str)
  puts h.inspect

  res = new

  if h.kind_of?(Hash)
    repos = h.delete('repos')
    raise "no repos given" unless repos
    res.from_hash(h)
    repos.each do |repo|
      res.add(repo)
    end
  else
    repos = str.split("\n").map { |x| x.strip }.select { |x| x.present? }
    repos.each do |r|
      res.add :working_dir => r
    end
  end
  res
end

Instance Method Details

#add(ops) ⇒ Object



7
8
9
10
11
# File 'lib/transparent_git/remote_trackers.rb', line 7

def add(ops)
  ops = {:repo_holding_dir => repo_holding_dir}.merge(ops)
  res = RemoteTracker.new(ops)
  list << res
end

#run_loop!Object



17
18
19
20
21
22
# File 'lib/transparent_git/remote_trackers.rb', line 17

def run_loop!
  loop do
    run_once!
    sleep(interval.to_i)
  end
end

#run_once!Object



12
13
14
15
16
# File 'lib/transparent_git/remote_trackers.rb', line 12

def run_once!
  list.each do |t|
    t.commit_current_state!
  end
end