Sha256: 1517b6ab2c052892b823beccc08e69ccac84db9a0a1f7cedd24b8bc5bdbf572c

Contents?: true

Size: 1.88 KB

Versions: 222

Compression:

Stored size: 1.88 KB

Contents

module Dev
class Svn
  
  def self.last_changed_revision(url)
    call=Dev::SystemCall.new("svn info #{url}")
    if call.status == 0
      call.output.each_line { |line|
        words=line.split(':')
        return words[1].strip if(words.length==2 && words[0] == "Last Changed Rev")
      }
    end
    return "0"
  end
  
  def self.update_revision_variable(filename,variable_name,url)
    if File.exist?(filename)
      revision=Dev::Svn::last_changed_revision(url)
      replace="#{variable_name}='#{revision}'"
      puts "  " + replace + " in " + filename unless revision=="0"
      text=File.read(filename)
      unless text.include?(replace)
        unless revision == "0"
          puts "  updating " + filename + " with " + replace
          search=Regexp.new("#{variable_name}=['\"][\\d]+['\"]")
          Dev::Environment.replace_text_in_file(filename,search,"#{variable_name}='#{revision}'")
        end
      end
    end
  end
  
  def self.update_revision_variables(filename)
    if File.exist?(filename)
      puts_debug "scanning " + filename + " for revision variables"
      text=File.read(filename)
      # extract potential variable names of form 
      text.scan(/([\dA-Z_]+)=['"][\d]+['"]/).each{ | var_match |
        puts_debug "found var_match: " + var_match[0].to_s
        varname = var_match[0].to_s
        # extract potential urls that use the variable name
        # '([.\w:\/-]+)@#{INTERFACE_REV}'
        uri_search=Regexp.new("['\"]([.\\w:\\/-]+)@" + '#{' + "#{varname}" + '}' + "['\"]")
        #puts uri_search.to_s
        text.scan(uri_search).each { |uri_match|
          puts_debug "found uri_match: " + uri_match.to_s
          uri=uri_match[0].to_s
          update_revision_variable(filename,varname,uri)
        }
      }
    else
      puts "  " + filename + " does not exist"
    end
  end
  
end # class Svn
end # module Dev

Version data entries

222 entries across 222 versions & 1 rubygems

Version Path
dev-1.0.247 lib/dev/Svn.rb
dev-1.0.246 lib/dev/Svn.rb
dev-1.0.245 lib/dev/Svn.rb
dev-1.0.244 lib/dev/Svn.rb
dev-1.0.243 lib/dev/Svn.rb
dev-1.0.242 lib/dev/Svn.rb
dev-1.0.241 lib/dev/Svn.rb
dev-1.0.240 lib/dev/Svn.rb
dev-1.0.239 lib/dev/Svn.rb
dev-1.0.238 lib/dev/Svn.rb
dev-1.0.237 lib/dev/Svn.rb
dev-1.0.236 lib/dev/Svn.rb
dev-1.0.235 lib/dev/Svn.rb
dev-1.0.233 lib/dev/Svn.rb
dev-1.0.232 lib/dev/Svn.rb
dev-1.0.231 lib/dev/Svn.rb
dev-1.0.230 lib/dev/Svn.rb
dev-1.0.229 lib/dev/Svn.rb
dev-1.0.228 lib/dev/Svn.rb
dev-1.0.227 lib/dev/Svn.rb