Module: Resizing

Defined in:
lib/resizing.rb,
lib/resizing/video.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/video/client.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, Video Classes: APIError, Client, Configuration, ConfigurationError, Error, MockClient, PublicId

Constant Summary collapse

VERSION =
'0.8.2'

Class Method Summary collapse

Class Method Details

.clientObject



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

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

.configureObject

Raises:



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

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

  @configure.dup
end

.configure=(new_value) ⇒ Object



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

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

.delete(name) ⇒ Object



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

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: ^^^^^^^^^



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

def self.generate_identifier
  Resizing.configure.generate_identifier
end

.get(name) ⇒ Object

Raises:

  • (NotImplementedError)


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

def self.get(name)
  raise NotImplementedError
end

.metadata(name, options) ⇒ Object



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

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

.post(file_or_binary, options) ⇒ Object



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

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

.put(name, file_or_binary, options) ⇒ Object



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

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

.separate_public_id(public_id) ⇒ Object



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

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



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

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