class Resizing::MockClient

Public Instance Methods

delete(name) click to toggle source
# File lib/resizing/mock_client.rb, line 20
def delete(name)
  r = load_yaml('test/vcr/client/delete.yml')
  result = JSON.parse(r['string'])
  # replace name and public_id by name argument
  result['id'] = name
  result['public_id'].gsub!(/28c49144-c00d-4cb5-8619-98ce95977b9c/, name)
  result
end
metadata(name) click to toggle source
# File lib/resizing/mock_client.rb, line 29
def metadata(name)
  r = load_yaml('test/vcr/client/metadata.yml')
  result = JSON.parse(r['string'])
  # replace name and public_id by name argument
  result['id'] = name
  result['public_id'].gsub!(/bfdaf2b3-7ec5-41f4-9caa-d53247dd9666/, name)
  result
end
post(file_or_binary, options = {}) click to toggle source
# File lib/resizing/mock_client.rb, line 5
def post(file_or_binary, options = {})
  r = load_yaml('test/vcr/client/post.yml')
  JSON.parse(r['string'])
end
put(name, file_or_binary, options) click to toggle source
# File lib/resizing/mock_client.rb, line 10
def put(name, file_or_binary, options)
  r = load_yaml('test/vcr/client/put.yml')
  result = JSON.parse(r['string'])
  # replace name, public_id and version by name argument
  result['id'] = name
  result['public_id'].gsub!(/AWEaewfAreaweFAFASfwe/, name)
  result['public_id'].gsub!(/v6Ew3HmDAYfb3NMRdLxR45i_gXMbLlGyi/, "v#{Time.now.to_f}")
  result
end

Private Instance Methods

library_root() click to toggle source
# File lib/resizing/mock_client.rb, line 44
def library_root
  @library_root ||= File.expand_path('../../../', __FILE__)
end
load_yaml(filename) click to toggle source
# File lib/resizing/mock_client.rb, line 39
def load_yaml filename
  path = "#{library_root}/#{filename}"
  YAML.load_file(path)['http_interactions'].first['response']['body']
end