Class: NotQuiteSubmodules

Inherits:
Object
  • Object
show all
Defined in:
lib/not-quite-submodules.rb

Constant Summary collapse

DEFAULT_UPDATE_INTERVAL =

Update configuration repository every day

60 * 60 * 24

Class Method Summary collapse

Class Method Details

.initialize(repository, target_path, args = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/not-quite-submodules.rb', line 11

def initialize(repository, target_path, args = {})
  args[:target_path] = target_path
  @update_interval = args[:update_interval] || DEFAULT_UPDATE_INTERVAL
  @force_update_to = args[:force_update_to]

  if args[:temp_path].nil?
    tmp_name = (Digest::SHA1.hexdigest repository)
    args[:temp_path] = "#{Dir.tmpdir}/#{tmp_name[0..8]}"
  end

  check_temporary_repository(args[:temp_path])

  if !File.directory? args[:temp_path]
    clone_repository(repository, args[:temp_path])
  elsif repository_needs_update?(args[:temp_path])
    update_repository(args[:temp_path])
  end

  tags = get_repository_tags(args[:temp_path]).map { |x| Versionomy.parse(x) }.sort
  if configuration_needs_update?(args[:target_path], tags)
    update_target_path(args[:temp_path], args[:target_path], tags)
  end
end