Class: Resizing::MockClient

Inherits:
Object
  • Object
show all
Defined in:
lib/resizing/mock_client.rb

Instance Method Summary collapse

Instance Method Details

#delete(name) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/resizing/mock_client.rb', line 24

def delete(name)
  r = load_yaml('test/vcr/client/delete.yml')
  result = JSON.parse(r['string'])
  # カセット内の値に依存せず、name で id / public_id を組み立て直す
  result['id'] = name
  result['public_id'] = build_public_id(result['public_id'], image_id: name)
  result
end

#metadata(name, _options = {}) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/resizing/mock_client.rb', line 33

def (name, _options = {})
  r = load_yaml('test/vcr/client/metadata.yml')
  result = JSON.parse(r['string'])
  # カセット内の値に依存せず、name で id / public_id を組み立て直す
  result['id'] = name
  result['public_id'] = build_public_id(result['public_id'], image_id: name)
  result
end

#post(_file_or_binary, _options = {}) ⇒ Object



7
8
9
10
# File 'lib/resizing/mock_client.rb', line 7

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) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/resizing/mock_client.rb', line 12

def put(name, _file_or_binary, _options)
  r = load_yaml('test/vcr/client/put.yml')
  result = JSON.parse(r['string'])
  # カセット内の値に依存せず、name と新しい version で id / public_id を組み立て直す
  version = generate_version
  result['id'] = name
  result['version'] = version
  result['latest_version_id'] = version
  result['public_id'] = build_public_id(result['public_id'], image_id: name, version: version)
  result
end