Sha256: 02b8752856fe01552df765b8431717c6f88a6a5db59f7563c4496869c9b24c97
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
require 'rubygems' require 'vortex_client' require 'json' require 'scrape_vortex_search' require 'pp' require 'uri' # Replace text in json document on server # Optional resourcetype can def replace(host, path, from, to, *resourcetype) verbose = false host = host.sub(/\/$/,'') uri = URI.parse(path) url = host + uri.path url = url.sub(/\/$/,'/index.html') vortex = Vortex::Connection.new(host,:use_osx_keychain => true) vortex.find(url) do |item| data = nil begin data = JSON.parse(item.content) rescue if(verbose)then puts "Warning. Bad document. Not json: " + item.uri.to_s end return 0 end if(resourcetype[0] and resourcetype[0].class == String and data["resourcetype"] != resourcetype[0] )then if(verbose)then puts "Warning: resourcetype not: " + resourcetype[0] end return 0 end puts "Oppdaterer: " + item.uri.to_s new_content = item.content.sub(from,to) item.content = new_content return 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vortex_client-0.7.0 | examples/replace_spike.rb |