class Raykit::SourceImport
Public Class Methods
new(url,source,glob,target,commit)
click to toggle source
# File lib/raykit/sourceImport.rb, line 4 def initialize(url,source,glob,target,commit) self['remote'] = url self['source'] = source self['glob'] = glob self['target'] = target self['commit']=commit end
Public Instance Methods
copy()
click to toggle source
# File lib/raykit/sourceImport.rb, line 47 def copy if(target.length == 0) puts 'target has not been specified' else FileUtils.remove_dir(target) if(Dir.exist?(target)) count=0 source_names = [] work=self['remote'].work_dir Dir.chdir(work) do if(File.exist?('rakefile.rb')) cmd = Command.new('rake clean') end Dir.chdir(self.source) do source_names=Dir.glob(self['glob']) end end source_names.each{|source_name| source_file =work + "/" + self.source + "/" + source_name target_name = target + "/" + source_name target_parent = File.dirname(target_name) FileUtils.mkdir_p(target_parent) if(!Dir.exist?(target_parent)) FileUtils.copy(source_file,target_name) count += 1 } puts ' copied ' + count.to_s + ' files to ' + target end end
glob()
click to toggle source
# File lib/raykit/sourceImport.rb, line 24 def glob self['glob'] end
remote()
click to toggle source
# File lib/raykit/sourceImport.rb, line 12 def remote self['remote'] end
source()
click to toggle source
# File lib/raykit/sourceImport.rb, line 16 def source self['source'] end
target()
click to toggle source
# File lib/raykit/sourceImport.rb, line 20 def target self['target'] end
update()
click to toggle source
# File lib/raykit/sourceImport.rb, line 28 def update work=self['remote'].work_dir work_parent=File.dirname(work) FileUtils.mkdir_p(work_parent) if(!Dir.exist?(work_parent)) if(Dir.exist?(work)) Dir.chdir(work) do cmd = Command.new('git pull') end else PROJECT.run("git clone #{remote} #{work}") end Dir.chdir(work) do text=`git log -n 1` scan=text.scan(/commit ([\w]+)\s/) self['commit'] = scan[0][0].to_s end end