module Public
Constants
- DATAURI
-
location of where public files are placed on the web
Public Class Methods
Source
# File lib/whimsy/public.rb, line 29 def self.getJSON(pubname) JSON.parse(getfile(pubname)) end
contents of a given public file, read from local copy if possible, fetched from the web otherwise; parsed as JSON
Source
# File lib/whimsy/public.rb, line 15 def self.getfile(pubname) local_copy = File.expand_path('../../../www/public/' + pubname, __FILE__) if File.exist? local_copy File.read(local_copy) else response = Net::HTTP.get_response(URI(DATAURI + pubname)) raise ArgumentError, "'#{pubname}' #{response.message}" unless response.is_a?(Net::HTTPSuccess) response.body end end
contents of a given public file, read from local copy if possible, fetched from the web otherwise