Class: Dev::Scm

Inherits:
Object
  • Object
show all
Defined in:
lib/dev/Scm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScm

Returns a new instance of Scm.



5
6
7
8
9
# File 'lib/dev/Scm.rb', line 5

def initialize
  @scm_type="none"
  @scm_type="svn" if File.exists?(".svn")
  @scm_type="git" if File.exists?(".git")
end

Instance Attribute Details

#scm_typeObject

Returns the value of attribute scm_type.



3
4
5
# File 'lib/dev/Scm.rb', line 3

def scm_type
  @scm_type
end

Class Method Details

.export(remote, local, scm) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dev/Scm.rb', line 44

def self.export(remote,local,scm)
  puts_debug "Scm.export, scm=#{scm}"
  if remote.include?("svn:") || scm=="svn"
    local_tmp=local.gsub('@','-')
    call=Dev::SystemCall.new("svn export \"#{remote}\" \"#{local_tmp}\"")
    call.puts_summary
    if(local_tmp != local)
      sleep 15
      File.rename(local_tmp,local) if File.exist?(local_tmp)
      sleep 15
    end
  end
  if scm=="git"
    call=Dev::SystemCall.new("git clone #{remote} #{local}")
  end
end

.update(local) ⇒ Object



61
62
# File 'lib/dev/Scm.rb', line 61

def self.update(local)
end

Instance Method Details

#add_file(file) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dev/Scm.rb', line 19

def add_file(file)
  call=Dev::SystemCall.new("git add #{file}") if @scm_type=="git"
  
  if @scm_type=="svn"
 afile=file
 afile="#{file}@" if afile.include?('@')
    call=Dev::SystemCall.new("svn info \"#{afile}\"")
    if(call.status != 0)
      call=Dev::SystemCall.new("svn add \"#{afile}\" --parents")
      call.puts_summary
    end
  end
end

#add_file_glob(glob) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/dev/Scm.rb', line 33

def add_file_glob(glob)
  Dir.glob(glob).each { |f|
 if(!f.include?("/obj/") && 
    !f.include?("/bin/") &&
 f.index("obj/") != 0 &&
 f.index("bin/") != 0 )
      add_file(f)
 end
  }
end

#file_tracked?(file) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/dev/Scm.rb', line 11

def file_tracked?(file)
  if @scm_type=="git"
    call=Dev::SystemCall.new("git ls-files #{file} -error_unmatch")
    return true if call.status==0
  end
  false
end