imageproxy_ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 69096b90f26374d536f6fd15afa1372cc94eb56f8b2f178e768317b4e8605fa5
4
+ data.tar.gz: '0576801a9b0c27e45f7cbc1d1af28713d048cae90bd84ba9cdd4793ee13bc114'
5
+ SHA512:
6
+ metadata.gz: 96d912261fd39e29b54bd44bdd29a378017ad2fa92d4192d2749752fe526c8ecffe6c3aa6e87571f5086be80a18dbf45abd9678ae0b95bea20f1036a37ee82da
7
+ data.tar.gz: fe111c199cede8e172da930b0e79577cbee1e5f37a404b13133446ec9c4923b10e5346b226070d99aae65cb4ca59de03fe63e32454d5600a328c946687ae3aa5
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ImageProxy module
4
+ module ImageProxyRuby
5
+ class << self
6
+ attr_accessor :configuration
7
+ end
8
+
9
+ def self.configure
10
+ self.configuration ||= Configuration.new
11
+ yield(configuration)
12
+ end
13
+
14
+ # configure class
15
+ class Configuration
16
+ attr_accessor :server
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'image_proxy/operations/smart_crop'
4
+ require 'image_proxy/operations/rectangle_crop'
5
+ require 'image_proxy/operations/rotation'
6
+ require 'image_proxy/operations/flip'
7
+ require 'image_proxy/operations/quality'
8
+ require 'image_proxy/operations/format'
9
+ require 'image_proxy/operations/resize'
10
+
11
+ module ImageProxyRuby
12
+ # represent Image with different functionalities
13
+ class Image
14
+ include Operations::SmartCrop
15
+ include Operations::RectangleCrop
16
+ include Operations::Rotation
17
+ include Operations::Flip
18
+ include Operations::Quality
19
+ include Operations::Format
20
+ include Operations::Resize
21
+
22
+ attr_accessor :remote_url, :operations
23
+
24
+ def initialize(remote_url)
25
+ @remote_url = remote_url
26
+ @operations = []
27
+ end
28
+
29
+ def url
30
+ operations_str = operations.join(',')
31
+
32
+ "#{ImageProxyRuby.configuration.server}#{operations_str}/#{remote_url}"
33
+ end
34
+
35
+ alias size resize
36
+ alias to_s url
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add flip functionalities to image
6
+ module Flip
7
+ def flip_vertically
8
+ operations << 'fv'
9
+
10
+ self
11
+ end
12
+
13
+ def flip_horizontally
14
+ operations << 'fh'
15
+
16
+ self
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add format functionalities to image
6
+ module Format
7
+ def jpeg
8
+ operations << 'jpeg'
9
+
10
+ self
11
+ end
12
+
13
+ def png
14
+ operations << 'png'
15
+
16
+ self
17
+ end
18
+
19
+ def tiff
20
+ operations << 'tiff'
21
+
22
+ self
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add quality functionality to image
6
+ module Quality
7
+ def quality(quality_percentage)
8
+ operations << "q#{quality_percentage}"
9
+
10
+ self
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add crop functionality to image
6
+ module RectangleCrop
7
+ def rectangle_crop(start_x: 0, start_y: 0, width: nil, height: nil)
8
+ operations_str = "cx#{start_x}cy#{start_y}"
9
+ operations_str += "cw#{width}" if width
10
+ operations_str += "ch#{height}" if height
11
+
12
+ operations << operations_str
13
+ self
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add resize functionality to image
6
+ module Resize
7
+ def resize(width: nil, height: nil)
8
+ operations << "#{width}x#{height}"
9
+
10
+ self
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add rotation functionality to image
6
+ module Rotation
7
+ def rotation(degrees)
8
+ operations << "r#{degrees}"
9
+
10
+ self
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageProxyRuby
4
+ module Operations
5
+ # add smart crop functionaly to image
6
+ module SmartCrop
7
+ def smart_crop
8
+ operations << 'sc'
9
+
10
+ self
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'image_proxy/configuration'
4
+ require 'image_proxy/image'
5
+
6
+ # the main module
7
+ module ImageProxyRuby
8
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imageproxy_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - azolf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-02-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby client for Image Proxy Server
14
+ email: amirhosein.zlf@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/image_proxy/configuration.rb
20
+ - lib/image_proxy/image.rb
21
+ - lib/image_proxy/operations/flip.rb
22
+ - lib/image_proxy/operations/format.rb
23
+ - lib/image_proxy/operations/quality.rb
24
+ - lib/image_proxy/operations/rectangle_crop.rb
25
+ - lib/image_proxy/operations/resize.rb
26
+ - lib/image_proxy/operations/rotation.rb
27
+ - lib/image_proxy/operations/smart_crop.rb
28
+ - lib/imageproxy_ruby.rb
29
+ homepage: https://rubygems.org/gems/imageproxy_ruby
30
+ licenses:
31
+ - MIT
32
+ metadata:
33
+ rubygems_mfa_required: 'true'
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '2.7'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.3.26
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Ruby client for Image Proxy Server
53
+ test_files: []