Class: DependUpdate::Depends

Inherits:
Object
  • Object
show all
Extended by:
DependUpdate
Defined in:
lib/depends_update/init.rb

Constant Summary

Constants included from DependUpdate

SVN32_URL

Instance Method Summary collapse

Methods included from DependUpdate

depends_list, depends_update, download, get_depends_file, get_os, load_depends_settings, svn_installed?

Instance Method Details

#depend(*args) ⇒ Object



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
# File 'lib/depends_update/init.rb', line 15

def depend(*args)
  dest = args.first
  options = args.last.is_a?(::Hash) ? args.pop : {}

  case options.keys.first.to_s
  when "svn"
    pattern = options[:svn]
    command = SVN::SVNCommand
  else
  end
  
  
  
  repos_root = command.repos_current_path()
  repos_current = command.repos_root_path()
  from = options.values.first
  
  if pattern !~ /[\*|\?]/ # 非模式匹配 
    # dest == Directory
    if pattern == /^(http[s]?|svn):\/\// # 不同仓库
      from_path = pattern
      to_path = dest
    elsif pattern == /^\// # 根目录
      from_path = url_join_path(from,repos_root)
      to_path = dest
    else
      from_path = url_join_path(from,repos_current)
      to_path = dest
    end         
    puts "更新文件 #{from_path} 到 #{to_path}"
    command.export(from_path,to_path)
  else
    if pattern == /^(http[s]?|svn):\/\// # 不同仓库
      from_paths = command.ReposTree.new pattern
      to_path = dest
    elsif pattern == /^\// # 根目录
      from_paths = command.ReposTree.new url_join_path(from,repos_root)
      to_path = dest
    else
      from_paths = command.ReposTree.new url_join_path(form,repos_current)
      to_path = dest
    end 

    from_paths.each do |from_path|
      puts "更新文件 #{from_path} 到 #{to_path}"
      command.export(from_path,to_path)              
    end
  end          
end

#initalize {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
# File 'lib/depends_update/init.rb', line 10

def initalize(&block)
  return nil unless block_given?
  yield self
end