diff options
author | mr <mr@mrautenberg.de> | 2011-09-14 10:05:47 +0200 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-09-14 10:05:47 +0200 |
commit | 038c4563032f65f935f38ef6bffe426b2dd14c0c (patch) | |
tree | 0fbc87f21f0cc4d3b9161ffceb204de2c1c12d70 /helper.rb | |
parent | 9299e2d50ac9f63ef30b7d5ead662b8f2f2df78f (diff) |
Endpoint selection from ontology server with cache
Diffstat (limited to 'helper.rb')
-rw-r--r-- | helper.rb | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -96,5 +96,24 @@ helpers do haml :models_navigation, :layout => false end + def endpoint_option_list(max_time=3600) + out = "" + tmpfile = File.join(TMP_DIR, "endpoint_option_list") + if File.exists? tmpfile + if Time.now-File.mtime(tmpfile) <= max_time + f = File.open(tmpfile, 'r+') + f.each{|line| out << line} + return out + else + File.unlink(tmpfile) + end + end + result = OpenTox::Ontology::Echa.endpoint_option_list() + if result.lines.count > 3 + f = File.new(tmpfile,"w") + f.print result + f.close + end + return result + end end - |