shrine-cloudimage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1d642abb6a1ae4756fd4fa37d95e62b9609b632fb8c4730ea23ac7d82d5763e4
4
+ data.tar.gz: 6c42038796003d6b16501764a4b697a45c9abae3586e1153c438d0241d731665
5
+ SHA512:
6
+ metadata.gz: 3382f5ce91fb23b884760def4aee25d17f78ea116aa1bce57c94ed710e7122802b85040aaab213d1415133f8ded115a8185129fbbbf7ee3e15f0affc7854a281
7
+ data.tar.gz: db4e5d92cb12a1dd9c43fb2ba9be3dd5d7fc31ddf019f5de3087d36a008f2908ccdb650e73ae4e7218291109135ef94457eacbe2db68dfdb44a847f6ce007efc
@@ -0,0 +1 @@
1
+ # 0.1.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jan Klimo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ # Shrine::Plugins::Cloudimage
2
+
3
+ ![](https://github.com/janklimo/shrine-cloudimage/workflows/Build/badge.svg)
4
+
5
+ [Cloudimage](https://www.cloudimage.io) integration for [Shrine](https://shrinerb.com).
6
+
7
+ Supports Ruby `2.4` and above, `JRuby`, and `TruffleRuby`.
8
+
9
+ - [Shrine::Plugins::Cloudimage](#shrinepluginscloudimage)
10
+ - [Installation](#installation)
11
+ - [Configuration](#configuration)
12
+ - [Usage](#usage)
13
+ - [Development](#development)
14
+ - [Contributing](#contributing)
15
+ - [License](#license)
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'shrine-cloudimage'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle install
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install shrine-cloudimage
32
+
33
+ ## Configuration
34
+
35
+ Register the plugin with any valid Cloudimage settings:
36
+
37
+ ```ruby
38
+ Shrine.plugin :cloudimage, client: {
39
+ token: 'token', salt: 'salt', sign_urls: false, signature_length: 10
40
+ }
41
+ ```
42
+
43
+ Or pass in the client object directly:
44
+
45
+ ```ruby
46
+ require 'cloudimage'
47
+
48
+ Shrine.plugin :cloudimage, Cloudimage::Client.new(
49
+ token: 'token', salt: 'salt', sign_urls: false, signature_length: 10
50
+ )
51
+ ```
52
+
53
+ See [`cloudimage`](https://github.com/scaleflex/cloudimage-rb) for a list
54
+ of available options.
55
+
56
+ ## Usage
57
+
58
+ You can generate a Cloudimage URL for a `Shrine::UploadedFile` object by
59
+ calling `#cloudimage_url`:
60
+
61
+ ```ruby
62
+ photo.image.cloudimage_url(w: 300, h: 300, blur: 5)
63
+ # => "https://token.cloudimg.io/v7/https://my-bucket.s3.us-east-1.amazonaws.com/assets/image.jpg?blur=5&h=300&w=300"
64
+ ```
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bundle install` to install dependencies.
69
+ Then, run `bundle exec rake` to run the tests.
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome! This project is intended
74
+ to be a safe, welcoming space for collaboration, and contributors
75
+ are expected to adhere to the
76
+ [code of conduct](https://github.com/scaleflex/cloudimage-rb/blob/master/CODE_OF_CONDUCT.md).
77
+
78
+ ## License
79
+
80
+ [MIT](https://opensource.org/licenses/MIT)
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cloudimage'
4
+
5
+ class Shrine
6
+ module Plugins
7
+ module Cloudimage
8
+ def self.configure(uploader, **opts)
9
+ if opts[:client].is_a?(Hash)
10
+ opts[:client] = ::Cloudimage::Client.new(**opts[:client])
11
+ end
12
+
13
+ uploader.opts[:cloudimage] ||= {}
14
+ uploader.opts[:cloudimage].merge!(**opts)
15
+
16
+ return if uploader.cloudimage_client
17
+
18
+ raise Error, ':client is required for cloudimage plugin'
19
+ end
20
+
21
+ module ClassMethods
22
+ def cloudimage_client
23
+ opts[:cloudimage][:client]
24
+ end
25
+ end
26
+
27
+ module FileMethods
28
+ def cloudimage_url(**options)
29
+ cloudimage_client.path(url).to_url(**options)
30
+ end
31
+
32
+ private
33
+
34
+ def cloudimage_client
35
+ shrine_class.cloudimage_client
36
+ end
37
+ end
38
+ end
39
+
40
+ register_plugin(:cloudimage, Cloudimage)
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shrine-cloudimage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Klimo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cloudimage
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: shrine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4'
47
+ - !ruby/object:Gem::Dependency
48
+ name: github_changelog_generator
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 1.15.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 1.15.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.13'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.13'
75
+ description: Fast and easy image resizing, transformation, and acceleration in the
76
+ Cloud.
77
+ email:
78
+ - jan.klimo@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - CHANGELOG.md
84
+ - LICENSE.txt
85
+ - README.md
86
+ - lib/shrine/plugins/cloudimage.rb
87
+ homepage: https://github.com/janklimo/shrine-cloudimage
88
+ licenses:
89
+ - MIT
90
+ metadata:
91
+ bug_tracker_uri: https://github.com/janklimo/shrine-cloudimage/issues
92
+ changelog_uri: https://github.com/janklimo/shrine-cloudimage/blob/master/CHANGELOG.md
93
+ source_code_uri: https://github.com/janklimo/shrine-cloudimage
94
+ documentation_uri: https://docs.cloudimage.io/go/cloudimage-documentation-v7/en/introduction
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.1.4
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Cloudimage integration for Shrine.
114
+ test_files: []