Module: Resizing

Defined in:
lib/resizing.rb,
lib/resizing/client.rb,
lib/resizing/version.rb,
lib/resizing/constants.rb,
lib/resizing/public_id.rb,
lib/resizing/mock_client.rb,
lib/resizing/carrier_wave.rb,
lib/resizing/configurable.rb,
lib/resizing/configuration.rb,
lib/resizing/http_clientable.rb,
lib/resizing/carrier_wave/storage/file.rb,
lib/resizing/carrier_wave/storage/remote.rb,
lib/resizing/active_storage/service/resizing_service.rb

Defined Under Namespace

Modules: ActiveStorage, CarrierWave, Configurable, Constants, HttpClientable Classes: APIError, Client, Configuration, ConfigurationError, Error, MockClient, PublicId

Constant Summary collapse

VERSION =
'1.2.0'

Class Method Summary collapse

Class Method Details

.clientObject



83
84
85
86
87
88
89
# File 'lib/resizing.rb', line 83

def self.client
  if self.configure.enable_mock
    Resizing::MockClient.new
  else
    Resizing::Client.new
  end
end

.configureObject

Raises:



32
33
34
35
36
# File 'lib/resizing.rb', line 32

def self.configure
  raise ConfigurationError, 'Resizing.configure is not initialized' unless defined? @configure

  @configure.dup
end

.configure=(new_value) ⇒ Object



38
39
40
41
# File 'lib/resizing.rb', line 38

def self.configure=(new_value)
  new_value = Configuration.new(new_value) unless new_value.is_a? Configuration
  @configure = new_value
end

.delete(name) ⇒ Object



59
60
61
# File 'lib/resizing.rb', line 59

def self.delete(name)
  self.client.delete name
end

.generate_identifierObject

TODO: refactoring

identifier: public_id: /projects/098a2a0d-c387-4135-a071-1254d6d7e70a/upload/images/28c49144-c00d-4cb5-8619-98ce95977b9c/v1Id850.. identifier: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ project_id: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ image_id: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ version: ^^^^^^^^^



75
76
77
# File 'lib/resizing.rb', line 75

def self.generate_identifier
  Resizing.configure.generate_identifier
end

.get(name) ⇒ Object

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/resizing.rb', line 43

def self.get(name)
  raise NotImplementedError
end

.metadata(name, options) ⇒ Object



63
64
65
# File 'lib/resizing.rb', line 63

def self.(name, options)
  self.client. name, options
end

.post(file_or_binary, options) ⇒ Object



51
52
53
# File 'lib/resizing.rb', line 51

def self.post(file_or_binary, options)
  self.client.post file_or_binary, options
end

.put(name, file_or_binary, options) ⇒ Object



55
56
57
# File 'lib/resizing.rb', line 55

def self.put(name, file_or_binary, options)
  self.client.put name, file_or_binary, options
end

.separate_public_id(public_id) ⇒ Object



79
80
81
# File 'lib/resizing.rb', line 79

def self.separate_public_id public_id
  public_id.match('/projects/(?<project_id>[0-9a-f-]+)/upload/images/(?<image_id>[^/]+)(/v(?<version>[^/]+))?')
end

.url_from_image_id(image_id, version_id = nil, transformations = []) ⇒ Object



47
48
49
# File 'lib/resizing.rb', line 47

def self.url_from_image_id(image_id, version_id = nil, transformations = [])
  Resizing.configure.generate_image_url(image_id, version_id, transformations)
end