Skip to content

Instantly share code, notes, and snippets.

@GregSutcliffe
Created April 26, 2012 13:07
Show Gist options
  • Save GregSutcliffe/2499426 to your computer and use it in GitHub Desktop.
Save GregSutcliffe/2499426 to your computer and use it in GitHub Desktop.
require 'json'
require 'rest-client'
require 'pp'
def get_foreman_array(path, options = { })
options[:foreman] ||= "foreman.office.etvinteractive.com"
options[:protocol] ||= "https"
options[:user] ||= "you know"
options[:pass] ||= "these values"
url = "#{options[:protocol]}://#{options[:foreman]}/#{path}?format=json"
JSON.parse(RestClient::Resource.new(url, options[:user], options[:pass]).get(:content_type => :json))
end
json_data=get_foreman_array("/facts/etv_hotelname/values")
pp json_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment