carrierwave-cloudflare 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bfcbaec70caed8b3460a42e0bc1b39d1232fd43e16a5085d13e9f22f4dee3e2c
4
+ data.tar.gz: 95a8e0999e8b2e95ce197705166488a207e869c58a6cb971de451c0c024794ee
5
+ SHA512:
6
+ metadata.gz: a35397c051afa4e66920e22ce10a3717e789b8f5bf1b41ac970c16814c24f8b5a380a587cb886af919628eaf8aeff60d5dfbab1105d1ba61835eaf2aeeccf0fc
7
+ data.tar.gz: d28e1eef9d280247abb591258478dec7a0b7e9bc66b3f6354a0037aea37c9f584b32465cb9b04dcc287bde94b65b96808270185e9bec2096447b481cf5a2c34c
@@ -0,0 +1,49 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ # Manually publish
5
+ workflow_dispatch:
6
+ # Alternatively, publish whenever changes are merged to the `main` branch.
7
+ push:
8
+ branches: "*"
9
+ pull_request:
10
+ branches: "*"
11
+
12
+ jobs:
13
+ build:
14
+ name: Build + Publish
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ packages: write
18
+ contents: read
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby 2.6
23
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
24
+ with:
25
+ ruby-version: 2.6
26
+ - run: bundle install
27
+
28
+ # - name: Publish to GPR
29
+ # run: |
30
+ # mkdir -p $HOME/.gem
31
+ # touch $HOME/.gem/credentials
32
+ # chmod 0600 $HOME/.gem/credentials
33
+ # printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
34
+ # gem build *.gemspec
35
+ # gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
36
+ # env:
37
+ # GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
38
+ # OWNER: ${{ github.repository_owner }}
39
+
40
+ - name: Publish to RubyGems
41
+ run: |
42
+ mkdir -p $HOME/.gem
43
+ touch $HOME/.gem/credentials
44
+ chmod 0600 $HOME/.gem/credentials
45
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
46
+ gem build *.gemspec
47
+ gem push *.gem
48
+ env:
49
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,25 @@
1
+ name: Run specs
2
+
3
+ on:
4
+ push:
5
+ branches: "*"
6
+ pull_request:
7
+ branches: "*"
8
+
9
+ jobs:
10
+ build:
11
+ name: Tests
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.6
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.6.x
20
+
21
+ - name: Run rspec
22
+ run: |
23
+ gem install bundler
24
+ bundle install --jobs 4 --retry 3
25
+ bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cheerful.mf@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in carrierwave-cloudflare.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ carrierwave-cloudflare (0.1.1)
5
+ carrierwave (~> 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (5.2.3)
11
+ activesupport (= 5.2.3)
12
+ activesupport (5.2.3)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ carrierwave (1.3.2)
18
+ activemodel (>= 4.0.0)
19
+ activesupport (>= 4.0.0)
20
+ mime-types (>= 1.16)
21
+ ssrf_filter (~> 1.0)
22
+ coderay (1.1.2)
23
+ concurrent-ruby (1.1.6)
24
+ diff-lcs (1.4.4)
25
+ i18n (1.8.5)
26
+ concurrent-ruby (~> 1.0)
27
+ method_source (1.0.0)
28
+ mime-types (3.3.1)
29
+ mime-types-data (~> 3.2015)
30
+ mime-types-data (3.2020.1104)
31
+ minitest (5.14.1)
32
+ pry (0.13.1)
33
+ coderay (~> 1.1)
34
+ method_source (~> 1.0)
35
+ rack (2.2.3)
36
+ rake (13.0.3)
37
+ rspec (3.10.0)
38
+ rspec-core (~> 3.10.0)
39
+ rspec-expectations (~> 3.10.0)
40
+ rspec-mocks (~> 3.10.0)
41
+ rspec-core (3.10.1)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-expectations (3.10.1)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-mocks (3.10.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-support (3.10.1)
50
+ ssrf_filter (1.0.7)
51
+ thread_safe (0.3.6)
52
+ tzinfo (1.2.7)
53
+ thread_safe (~> 0.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ activesupport (~> 5.2)
60
+ carrierwave-cloudflare!
61
+ pry
62
+ rack (~> 2.0)
63
+ rake
64
+ rspec
65
+
66
+ BUNDLED WITH
67
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Mark Frost
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.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Carrierwave::Cloudflare
2
+
3
+ This gem provides a simple wrapper for transformation images via Cloudflare
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'carrierwave-cloudflare'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install carrierwave-cloudflare
20
+
21
+ ## Usage
22
+
23
+ Include `CarrierWave::Cloudflare` in your base uploader
24
+
25
+ ```ruby
26
+ class BaseUploader < CarrierWave::Uploader::Base
27
+ include CarrierWave::Cloudflare
28
+ end
29
+ ```
30
+
31
+
32
+ Define `virtual` version in some uploader:
33
+ ```ruby
34
+ class AvatarUploader < BaseUploader
35
+ version(:medium) do
36
+ cdn_transform width: 100, height: 100, dpr: 2
37
+ end
38
+ end
39
+
40
+
41
+ User.avatar.medium # CarrierWave::Uploader
42
+ User.avatar.url # "https://s3.resume.io/users/avatar/1.jpg"
43
+ User.avatar.medium_url # "https://s3.resume.io/cdn-cgi/.../users/avatar/1.jpg"
44
+ User.avatar.medium.url # "https://s3.resume.io/cdn-cgi/.../users/avatar/1.jpg"
45
+ User.avatar.url(:medium) # "https://s3.resume.io/cdn-cgi/.../users/avatar/1.jpg"
46
+ User.avatar.medium.url(dpr: 1)
47
+ User.avatar.resize(width: 1200, fit: :cover).url
48
+ ```
49
+
50
+ ### Options
51
+
52
+ Supported options:
53
+
54
+ `width`, `height`, `dpr`, `fit`, `gravity`, `quality`, `format`, `onerror`, `metadata`
55
+
56
+ See details in Cloudflare [documentation](https://developers.cloudflare.com/images/about)
57
+
58
+ Also, you can define default options (supports all options described above)
59
+
60
+ ```ruby
61
+ class BaseUploader < CarrierWave::Uploader::Base
62
+ default_cdn_options format: :auto
63
+ end
64
+ ```
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
+
70
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/resume-io/carrierwave-cloudflare. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/resume-io/carrierwave-cloudflare/blob/master/CODE_OF_CONDUCT.md).
75
+
76
+
77
+ ## License
78
+
79
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
80
+
81
+ ## Code of Conduct
82
+
83
+ Everyone interacting in the Carrierwave::Cloudflare project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/resume-io/carrierwave-cloudflare/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'carrierwave/cloudflare'
6
+
7
+ require 'pry'
8
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/carrierwave/cloudflare/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'carrierwave-cloudflare'
7
+ spec.version = Carrierwave::Cloudflare::VERSION
8
+ spec.authors = ['Mark Frost', 'Alexey Taktarov']
9
+ spec.email = ['cheerful.mf@gmail.com']
10
+
11
+ spec.summary = 'Wrapper for cloudflare transforming images'
12
+ spec.homepage = 'https://github.com/resume-io/carrierwave-cloudflare'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/resume-io/carrierwave-cloudflare'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/resume-io/carrierwave-cloudflare/blob/master/CHANGELOG.md'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency 'activesupport', '~> 5.2'
30
+ spec.add_development_dependency 'pry'
31
+ spec.add_development_dependency 'rack', '~> 2.0'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'rspec'
34
+
35
+ spec.add_dependency 'carrierwave', '~> 1.3'
36
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack/utils'
4
+
5
+ module CarrierWave::Cloudflare::URL
6
+ class QueryString < Hash
7
+ Parser = Object.new.tap do |obj|
8
+ obj.extend(Rack::Utils)
9
+
10
+ # these methods are private in Rack::Utils
11
+ obj.singleton_class.instance_eval { public :build_query, :parse_query }
12
+ end
13
+
14
+ def initialize(query = '')
15
+ super()
16
+ merge!(Parser.parse_query(query))
17
+ end
18
+
19
+ def to_query
20
+ result = Parser.build_query(self)
21
+ result unless result.empty?
22
+ end
23
+
24
+ alias to_s to_query
25
+ end
26
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'url/query_string'
4
+
5
+ module CarrierWave::Cloudflare
6
+ module URL
7
+ ALLOWED_OPTIONS = %w[width height dpr fit gravity quality format onerror metadata].freeze
8
+
9
+ module_function
10
+
11
+ def should_modify_path?
12
+ ::CarrierWave::Cloudflare.cloudflare_transform
13
+ end
14
+
15
+ def extract(url)
16
+ uri = URI.parse(url)
17
+ options = {}
18
+
19
+ if should_modify_path?
20
+ if %r{/cdn-cgi/image/([^/]+)(/.*)} =~ uri.path
21
+ formatted = $LAST_MATCH_INFO[1]
22
+ original_path = $LAST_MATCH_INFO[2]
23
+
24
+ options = parse_options(formatted)
25
+ uri.path = original_path
26
+ end
27
+ else
28
+ query = QueryString.new(uri.query)
29
+
30
+ if query.key?('cdn-cgi')
31
+ options = parse_options(query['cdn-cgi'], separator: '.', assigner: '-')
32
+ end
33
+ end
34
+
35
+ [uri, options]
36
+ end
37
+
38
+ def transform(url, **options)
39
+ uri, existing_opts = extract(url)
40
+ options = existing_opts.merge(options.transform_keys(&:to_s))
41
+
42
+ pairs = sanitized_options(options)
43
+
44
+ if pairs.empty?
45
+ url
46
+ else
47
+ append_options!(uri, pairs)
48
+ uri.to_s
49
+ end
50
+ end
51
+
52
+ def append_options!(uri, options)
53
+ if should_modify_path?
54
+ segment = '/cdn-cgi/image/' + options.map { |k, v| "#{k}=#{v}" }.join(',')
55
+ uri.path = segment + uri.path
56
+ else
57
+ uri.query = QueryString.new(uri.query).tap do |params|
58
+ # the format is "width-500.height.200", only safe symbols are used
59
+ param_with_options = options.map { |k, v| "#{k}-#{v}" }.join('.')
60
+
61
+ params['cdn-cgi'] = param_with_options
62
+ end.to_query
63
+ end
64
+ end
65
+
66
+ def sanitized_options(options)
67
+ ordered = options.map do |k, v|
68
+ idx = ALLOWED_OPTIONS.index(k)
69
+ [idx, [k, v]]
70
+ end
71
+
72
+ filtered = ordered.select { |i,| i }.sort
73
+
74
+ filtered.map do |_, (k, v)|
75
+ v = v.join('x') if v.is_a?(Array)
76
+ [k, v]
77
+ end
78
+ end
79
+
80
+ # converts strings "w=foo,h=bar" into hashes
81
+ def parse_options(str, separator: ',', assigner: '=')
82
+ kv = str.split(separator).map { |s| s.strip.split(assigner) }
83
+ Hash[kv]
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,5 @@
1
+ module Carrierwave
2
+ module Cloudflare
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ require 'carrierwave/cloudflare/version'
6
+
7
+ module CarrierWave
8
+ module Cloudflare
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ class_attribute :_default_cdn_options, instance_reader: false, instance_writer: false
13
+
14
+ self._default_cdn_options = {}
15
+ end
16
+
17
+ module ClassMethods
18
+ def cdn_transform(**options)
19
+ opts = default_cdn_options.merge(options)
20
+ self.version_options = version_options.merge(cdn_transform: opts)
21
+ end
22
+
23
+ def default_cdn_options(**defaults)
24
+ return _default_cdn_options if defaults.empty?
25
+
26
+ self._default_cdn_options = defaults
27
+ end
28
+ end
29
+
30
+ def self.configure
31
+ yield self
32
+ end
33
+
34
+ def self.cloudflare_transform(value = nil)
35
+ return @cloudflare_transform if value.nil?
36
+
37
+ @cloudflare_transform = value
38
+ end
39
+
40
+ def store!(*args)
41
+ return if virtual_version?
42
+
43
+ super(*args)
44
+ end
45
+
46
+ def cache!(*args)
47
+ return if virtual_version?
48
+
49
+ super(*args)
50
+ end
51
+
52
+ def retrieve_from_cache!(*args)
53
+ return if virtual_version?
54
+
55
+ super(*args)
56
+ end
57
+
58
+ def retrieve_from_store!(*args)
59
+ return if virtual_version?
60
+
61
+ super(*args)
62
+ end
63
+
64
+ def url(*args)
65
+ if virtual_version?
66
+ cdn_url
67
+ else
68
+ super(*args)
69
+ end
70
+ end
71
+
72
+ def resize(**options)
73
+ # build temporary uploader
74
+ uploader = self.class.dup
75
+ self.class.const_set("Uploader#{uploader.object_id}".tr('-', '_'), uploader)
76
+ uploader.version_options = { cdn_transform: options }
77
+
78
+ # init the instance uploader and set parent_version
79
+ obj = uploader.new(self)
80
+ obj.parent_version = self
81
+ obj
82
+ end
83
+
84
+ private
85
+
86
+ def virtual_version?
87
+ self.class.version_options && self.class.version_options[:cdn_transform].present? && parent_version
88
+ end
89
+
90
+ def cdn_url
91
+ if base_image_url
92
+ CarrierWave::Cloudflare::URL.transform(
93
+ base_image_url,
94
+ **self.class.version_options[:cdn_transform]
95
+ )
96
+ end
97
+ end
98
+
99
+ def base_image_url
100
+ parent_version.url
101
+ end
102
+ end
103
+ end
104
+
105
+ require_relative 'cloudflare/url'
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave-cloudflare
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Frost
8
+ - Alexey Taktarov
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2021-07-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '5.2'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '5.2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rack
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: carrierwave
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.3'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.3'
98
+ description:
99
+ email:
100
+ - cheerful.mf@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".github/workflows/publish-gem.yml"
106
+ - ".github/workflows/run-specs.yml"
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
+ - CHANGELOG.md
111
+ - CODE_OF_CONDUCT.md
112
+ - Gemfile
113
+ - Gemfile.lock
114
+ - LICENSE.txt
115
+ - README.md
116
+ - Rakefile
117
+ - bin/console
118
+ - bin/setup
119
+ - carrierwave-cloudflare.gemspec
120
+ - lib/carrierwave/cloudflare.rb
121
+ - lib/carrierwave/cloudflare/url.rb
122
+ - lib/carrierwave/cloudflare/url/query_string.rb
123
+ - lib/carrierwave/cloudflare/version.rb
124
+ homepage: https://github.com/resume-io/carrierwave-cloudflare
125
+ licenses:
126
+ - MIT
127
+ metadata:
128
+ homepage_uri: https://github.com/resume-io/carrierwave-cloudflare
129
+ source_code_uri: https://github.com/resume-io/carrierwave-cloudflare
130
+ changelog_uri: https://github.com/resume-io/carrierwave-cloudflare/blob/master/CHANGELOG.md
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 2.3.0
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubygems_version: 3.0.3.1
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Wrapper for cloudflare transforming images
150
+ test_files: []