resizing 0.8.3.pre → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8351713d4b33f84d7bff196edaa7a842ba34cb157a56aa652067b003cc459b3d
4
- data.tar.gz: d40a7f4d588283bc1535ed5f31f94f592e86430a8fb7724554b9ec502067071a
3
+ metadata.gz: 5fff2fe2e1211d6d9b8fc9d399d63df0e1fe7a7f56aca9cc5c4fb045f7877110
4
+ data.tar.gz: ac9be08e555131de36131bcaca8747d300b951b1ee00c848d85749c0b80b4766
5
5
  SHA512:
6
- metadata.gz: 2d015cf9ce5e436630618fa540523b3fe8449060844938eaf3d3ea5b455c1cede10a0993a80c2b90c967da2e3399e79837001ca4f315fee3694db0e657c8ebf0
7
- data.tar.gz: 4fdefce63e3f9cdc5c6629fdf769928a6ca030b2715398df4a0ddb1ac09ca1492dd25a414f2b8e7750d591e92b86fa66c2394433dbcd4ba69dfaa8d33a573600
6
+ metadata.gz: b076ac07bf0c60a9a8a8af0bf18536e78b20fe9faa2565b5c79e41fbcf1f66207be30b14e92b31e8c0af3cc05d4c5589db40d9e5dbd7574343ecee10d4121b65
7
+ data.tar.gz: 46c7f5303f4cf0620d0205d01c68d74a483b025918cffda9ca42207c656c6fc8cfc40c6843349181aeef170aaeeffe1e93c558aacccd98ad82f9c071ea183318
data/.circleci/config.yml CHANGED
@@ -40,7 +40,9 @@ jobs:
40
40
  sudo gem install bundler
41
41
  sudo gem uninstall -x rake
42
42
  echo "install: --no-document" >> ~/.gemrc
43
- bundle check --path vendor/bundle || bundle install --path vendor/bundle --clean
43
+ bundle config set --local path vendor/bundle
44
+ bundle config set --local clean true
45
+ bundle check || bundle install
44
46
 
45
47
  - save_cache:
46
48
  key: v2-{{ .Environment.CACHE_KEY }}-gem-cache-{{ arch }}-{{ .Branch }}
File without changes
File without changes
data/{bin → exe}/setup RENAMED
File without changes
@@ -6,15 +6,16 @@ module Resizing
6
6
  class File
7
7
  include ::CarrierWave::Utilities::Uri
8
8
 
9
+ attr_reader :public_id
10
+
9
11
  def initialize(uploader, identifier = nil)
10
12
  @uploader = uploader
11
- @file = nil
12
13
  @content_type = nil
13
- @public_id = Resizing::PublicId.new identifier
14
+ @public_id = Resizing::PublicId.new(identifier)
15
+ @file = nil
16
+ @metadata = nil
14
17
  end
15
18
 
16
- attr_reader :public_id
17
-
18
19
  def attributes
19
20
  file.attributes
20
21
  end
@@ -112,6 +113,7 @@ module Resizing
112
113
 
113
114
  @response = Resizing.post(content, { content_type: @content_type, filename: original_filename })
114
115
  @public_id = Resizing::PublicId.new(@response['public_id'])
116
+ @content_type = @response['content_type']
115
117
 
116
118
  # force update column
117
119
  # model_class
@@ -133,6 +135,9 @@ module Resizing
133
135
  # CarrierWave::Storage::Fog::File.new(@uploader, @base, new_path)
134
136
  # end
135
137
 
138
+ def retrieve(identifier)
139
+ @public_id = Resizing::PublicId.new(identifier)
140
+ end
136
141
  private
137
142
 
138
143
  attr_reader :uploader
@@ -190,14 +195,6 @@ module Resizing
190
195
  parameters.count == 2 && parameters[1].include?(:options)
191
196
  end
192
197
 
193
- def retrieve!(identifier)
194
- raise NotImplementedError, "retrieve! #{identifier}"
195
- end
196
-
197
- # def cache!(new_file)
198
- # raise NotImplementedError,
199
- # "Need to implement #cache! if you want to use #{self.class.name} as a cache storage."
200
- # end
201
198
 
202
199
  # def retrieve_from_cache!(identifier)
203
200
  # raise NotImplementedError,
@@ -9,20 +9,18 @@ module Resizing
9
9
  def store!(file)
10
10
  f = Resizing::CarrierWave::Storage::File.new(uploader)
11
11
  f.store(file)
12
- @filename = f.public_id.to_s
13
12
  f
14
13
  end
15
14
 
16
15
  def remove!(file)
17
16
  f = Resizing::CarrierWave::Storage::File.new(uploader)
18
17
  f.delete(file)
19
- @filename = f.public_id.to_s
20
18
  f
21
19
  end
22
20
 
23
- def retrieve!(identifier)
24
- Resizing::CarrierWave::Storage::File.new(uploader, identifier)
25
- end
21
+ # def retrieve!(identifier)
22
+ # super
23
+ # end
26
24
 
27
25
  def cache!(new_file)
28
26
  f = Resizing::CarrierWave::Storage::File.new(uploader)
@@ -31,6 +31,15 @@ module Resizing
31
31
  super
32
32
  end
33
33
 
34
+ def file
35
+ return if identifier.nil?
36
+ return @file unless defined? @file
37
+
38
+ @file ||= Resizing::CarrierWave::Storage::File.new(self)
39
+ @file.retrieve(identifier)
40
+ @file
41
+ end
42
+
34
43
  def url(*args)
35
44
  return default_url unless read_column.present?
36
45
 
@@ -103,7 +103,7 @@ module Resizing
103
103
  end
104
104
  end
105
105
 
106
- result = handle_metadata_response(response)
106
+ result = handle_metadata_response(response, options)
107
107
  result
108
108
  end
109
109
 
@@ -151,7 +151,7 @@ module Resizing
151
151
  end
152
152
 
153
153
  def handle_create_response(response)
154
- raise APIError, "no response is returned" if response.nil?
154
+ raise APIError, "No response is returned" if response.nil?
155
155
 
156
156
  case response.status
157
157
  when HTTP_STATUS_OK, HTTP_STATUS_CREATED
@@ -162,7 +162,7 @@ module Resizing
162
162
  end
163
163
 
164
164
  def handle_delete_response(response)
165
- raise APIError, "no response is returned" if response.nil?
165
+ raise APIError, "No response is returned" if response.nil?
166
166
 
167
167
  case response.status
168
168
  when HTTP_STATUS_OK, HTTP_STATUS_NOT_FOUND
@@ -172,12 +172,17 @@ module Resizing
172
172
  end
173
173
  end
174
174
 
175
- def handle_metadata_response(response)
176
- raise APIError, "no response is returned" if response.nil?
175
+ def handle_metadata_response(response, options = {})
176
+ when_not_found = options[:when_not_found] || nil
177
+
178
+ raise APIError, "No response is returned" if response.nil?
177
179
 
178
180
  case response.status
179
181
  when HTTP_STATUS_OK, HTTP_STATUS_NOT_FOUND
180
182
  JSON.parse(response.body)
183
+ when HTTP_STATUS_NOT_FOUND
184
+ raise decode_error_from(response) if when_not_found == :raise
185
+ nil
181
186
  else
182
187
  raise decode_error_from(response)
183
188
  end
@@ -103,8 +103,12 @@ module Resizing
103
103
  end
104
104
 
105
105
  def initialize_by_hash(attr)
106
- # @host = attr[:host].dup.freeze || DEFAULT_HOST
107
106
  @image_host = attr[:image_host].dup.freeze || DEFAULT_IMAGE_HOST
107
+ if attr[:host].present?
108
+ Kernel.warn "[DEPRECATED] The host on configration is deprecated. Use image_host, video_host" if attr[:host].present?
109
+ @image_host ||= attr[:host].dup.freeze || DEFAULT_HOST # for backward compatible
110
+ end
111
+
108
112
  @video_host = attr[:video_host].dup.freeze || DEFAULT_VIDEO_HOST
109
113
  @project_id = attr[:project_id].dup.freeze
110
114
  @secret_token = attr[:secret_token].dup.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resizing
4
- VERSION = '0.8.3.pre'
4
+ VERSION = '1.0.0.pre'
5
5
  end
data/resizing.gemspec CHANGED
@@ -28,12 +28,12 @@ Gem::Specification.new do |spec|
28
28
  spec.bindir = 'exe'
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
- spec.add_runtime_dependency 'faraday', '>= 1.0.1', '< 1.4.0'
32
- spec.add_development_dependency 'carrierwave', '~> 2.2.0'
31
+ spec.add_runtime_dependency 'faraday', '~> 1.0'
32
+ spec.add_development_dependency 'rails', '~> 6.0'
33
+ spec.add_development_dependency 'carrierwave', '~> 1.3.2'
33
34
  spec.add_development_dependency 'fog-aws'
34
35
  spec.add_development_dependency 'minitest'
35
36
  spec.add_development_dependency 'minitest-ci'
36
- spec.add_development_dependency 'rails', '~> 5.2.3'
37
37
  spec.add_development_dependency 'rubocop'
38
38
  spec.add_development_dependency 'timecop'
39
39
  spec.add_development_dependency 'vcr'
metadata CHANGED
@@ -1,65 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resizing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3.pre
4
+ version: 1.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junichiro Kasuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-08 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.0.1
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 1.4.0
19
+ version: '1.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.0.1
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 1.4.0
26
+ version: '1.0'
33
27
  - !ruby/object:Gem::Dependency
34
- name: carrierwave
28
+ name: rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 2.2.0
33
+ version: '6.0'
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 2.2.0
40
+ version: '6.0'
47
41
  - !ruby/object:Gem::Dependency
48
- name: fog-aws
42
+ name: carrierwave
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - ">="
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 1.3.2
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - ">="
52
+ - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0'
54
+ version: 1.3.2
61
55
  - !ruby/object:Gem::Dependency
62
- name: minitest
56
+ name: fog-aws
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - ">="
@@ -73,7 +67,7 @@ dependencies:
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  - !ruby/object:Gem::Dependency
76
- name: minitest-ci
70
+ name: minitest
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
73
  - - ">="
@@ -87,19 +81,19 @@ dependencies:
87
81
  - !ruby/object:Gem::Version
88
82
  version: '0'
89
83
  - !ruby/object:Gem::Dependency
90
- name: rails
84
+ name: minitest-ci
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: 5.2.3
89
+ version: '0'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: 5.2.3
96
+ version: '0'
103
97
  - !ruby/object:Gem::Dependency
104
98
  name: rubocop
105
99
  requirement: !ruby/object:Gem::Requirement
@@ -145,7 +139,10 @@ dependencies:
145
139
  description: 'Client and utilities for Resizing '
146
140
  email:
147
141
  - junichiro.kasuya@gmail.com
148
- executables: []
142
+ executables:
143
+ - console
144
+ - generate-changelog
145
+ - setup
149
146
  extensions: []
150
147
  extra_rdoc_files: []
151
148
  files:
@@ -157,10 +154,10 @@ files:
157
154
  - LICENSE.txt
158
155
  - README.md
159
156
  - Rakefile
160
- - bin/console
161
- - bin/generate-changelog
162
- - bin/setup
163
157
  - docker-compose.yml
158
+ - exe/console
159
+ - exe/generate-changelog
160
+ - exe/setup
164
161
  - lib/resizing.rb
165
162
  - lib/resizing/active_storage/service/resizing_service.rb
166
163
  - lib/resizing/carrier_wave.rb
@@ -220,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
217
  - !ruby/object:Gem::Version
221
218
  version: 1.3.1
222
219
  requirements: []
223
- rubygems_version: 3.0.3
220
+ rubygems_version: 3.1.6
224
221
  signing_key:
225
222
  specification_version: 4
226
223
  summary: Client and utilities for Resizing