Class: Dev::Cmd::Pull

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

Class Method Summary collapse

Class Method Details

.executeObject



5
6
7
8
9
10
11
12
13
14
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
# File 'lib/dev/cmd/Pull.rb', line 5

def self.execute
 puts "checking dependencies in #{DEV[:directory]}"

  text = File.read("#{DEV[:directory]}/rakefile.rb")
  new_text = text

  DEV[:dep].each {|key,value|
 puts_debug "checking dep key #{key}"
 if(value.has_key?(:dir) && value[:dir].include?('@'))
   cmd="svn info #{value[:uri].gsub(/@[\d\w]+/,'')}"
puts_debug cmd
call=Dev::SystemCall.new(cmd)
call.puts_summary
   info =call.output# %x[cmd]

new_revision="0"
if(RUBY_VERSION=="1.8.7")
  info.each_line do |line|
          if(line.include?("Last Changed Rev:"))
    new_revision=line.split(':')[1].strip
  end
        end
else
  new_revision = info.match(/Last Changed Rev: (?<rev>\d+)/)[:rev]
end
new_dir = value[:dir].gsub(/@[\d]+/,"@#{new_revision}")
puts_debug "new_dir=#{new_dir}"
if(new_dir != value[:dir])
  puts "updating from #{value[:dir]} to #{new_dir}"
     new_text = new_text.gsub(value[:dir],new_dir)
end
 end
  }

  if(text != new_text)
 File.open("#{DEV[:directory]}/rakefile.rb",'w') { |f|f.write(new_text) }
  end

end