diff --git a/fauxhai.gemspec b/fauxhai.gemspec index a57a5d56..75ed17a7 100644 --- a/fauxhai.gemspec +++ b/fauxhai.gemspec @@ -15,7 +15,6 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.add_runtime_dependency 'httparty' spec.add_runtime_dependency 'net-ssh' spec.add_runtime_dependency 'ohai' diff --git a/lib/fauxhai/mocker.rb b/lib/fauxhai/mocker.rb index 72ba49b4..c494f41c 100644 --- a/lib/fauxhai/mocker.rb +++ b/lib/fauxhai/mocker.rb @@ -1,9 +1,12 @@ -require 'httparty' require 'json' +require 'net/http' require 'pathname' module Fauxhai class Mocker + # The base URL for the GitHub project (raw) + RAW_BASE = 'https://raw.github.com/customink/fauxhai/master' + # @return [Hash] The raw ohai data for the given Mock attr_reader :data @@ -54,8 +57,7 @@ def fauxhai_data elsif # Try loading from github (in case someone submitted a PR with a new file, but we haven't # yet updated the gem version). Cache the response locally so it's faster next time. - url = "https://raw.github.com/customink/fauxhai/master/lib/fauxhai/platforms/#{platform}/#{version}.json" - response = HTTParty.get(url) + response = get("#{RAW_BASE}/lib/fauxhai/platforms/#{platform}/#{version}.json") if response.code.to_i == 200 path = Pathname.new(filepath) @@ -85,5 +87,14 @@ def version def chefspec_version platform == 'chefspec' ? '0.6.1' : nil end + + def get(url) + url = URI.parse(url) + http = Net::HTTP.new(url.host, url.port) + http.use_ssl = true + + request = Net::HTTP::Get.new(url.path) + http.start { |http| http.request(request) } + end end end