class SRScript
Constants
- URL_BASE
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/srscript.rb, line 25 def initialize() super puts 'initialized at ' + Time.now.to_s end
Public Instance Methods
check_url(url)
click to toggle source
# File lib/srscript.rb, line 71 def check_url(url) url = URI.parse(url) Net::HTTP.start(url.host, url.port) do |http| return http.head(url.request_uri).code end end
display_url_run(url, jobs, opts)
click to toggle source
# File lib/srscript.rb, line 62 def display_url_run(url, jobs, opts) h = {'.xml' => 'text/xml','.html' => 'text/html','.txt' => 'text/plain'} @content_type = h[opts[:extension]] out = run_script(url, jobs, opts[:args]) content_type @content_type, :charset => 'utf-8' if defined? content_type out end
follow_route(routes, key)
click to toggle source
# File lib/srscript.rb, line 291 def follow_route(routes, key) if routes.has_key? key then routes[key].call(params) else route = routes.detect {|k,v| key[/#{k}/]} if route then remaining = $' if remaining then args = remaining.split('/') args.shift else args = [] end route[1].call( params, args) else puts '@@app is ' + @@app.inspect out, @content_type = @@app.run_projectx('dir', 'view', {:file_path => key, :passthru => params[:passthru]}) [out, @content_type] #puts "no match" end end end
package_run(package_id, job, opts={})
click to toggle source
# File lib/srscript.rb, line 78 def package_run(package_id, job, opts={}) o = { :extension => '.html', :args => [] }.merge(opts) jobs = "//job:" + job url, @content_type = @@app.run_projectx('registry', 'get-key', :path => "system/packages/*[name='#{package_id}']/url/text()").map(&:to_s) url = @@url_base + url[1..-1] if url[/^\//] if url then display_url_run(url.to_s.sub(/^#{@@url_base}/,'\0s/open/'),jobs, o) else code = check_url(url) if code == '200' then url = "%s%s.rsf" % [@@url_base, package_id] display_url_run(url,jobs, o) else # 404 url = url_base + 'open-uri-error.rsf' run_script(url, '//job:with-code', code) end end end
run_rcscript(rsf_url, jobs, raw_args=[])
click to toggle source
# File lib/srscript.rb, line 53 def run_rcscript(rsf_url, jobs, raw_args=[]) @@rscript.read([rsf_url, jobs.split(/\s/), raw_args].flatten) end
run_script(url, jobs, *qargs)
click to toggle source
# File lib/srscript.rb, line 57 def run_script(url, jobs, *qargs) result, args = run_rcscript(url, jobs, qargs) eval(result) end