jd-paperclip-azure 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +25 -0
  3. data/.github/workflows/tests.yml +22 -0
  4. data/.gitignore +58 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +3 -0
  7. data/History.txt +6 -0
  8. data/Manifest.txt +9 -0
  9. data/README.md +138 -0
  10. data/Rakefile +29 -0
  11. data/lib/paperclip/azure.rb +5 -0
  12. data/lib/paperclip/storage/azure/environment.rb +19 -0
  13. data/lib/paperclip/storage/azure.rb +271 -0
  14. data/lib/paperclip-azure.rb +1 -0
  15. data/paperclip-azure.gemspec +33 -0
  16. data/spec/database.yml +3 -0
  17. data/spec/paperclip/storage/azure/environment_spec.rb +26 -0
  18. data/spec/paperclip/storage/azure_spec.rb +426 -0
  19. data/spec/spec_helper.rb +40 -0
  20. data/spec/support/fake_model.rb +25 -0
  21. data/spec/support/fake_rails.rb +12 -0
  22. data/spec/support/fixtures/12k.png +0 -0
  23. data/spec/support/fixtures/50x50.png +0 -0
  24. data/spec/support/fixtures/5k.png +0 -0
  25. data/spec/support/fixtures/animated +0 -0
  26. data/spec/support/fixtures/animated.gif +0 -0
  27. data/spec/support/fixtures/animated.unknown +0 -0
  28. data/spec/support/fixtures/azure.yml +8 -0
  29. data/spec/support/fixtures/bad.png +1 -0
  30. data/spec/support/fixtures/empty.html +1 -0
  31. data/spec/support/fixtures/empty.xlsx +0 -0
  32. data/spec/support/fixtures/fog.yml +8 -0
  33. data/spec/support/fixtures/rotated.jpg +0 -0
  34. data/spec/support/fixtures/spaced file.jpg +0 -0
  35. data/spec/support/fixtures/spaced file.png +0 -0
  36. data/spec/support/fixtures/text.txt +1 -0
  37. data/spec/support/fixtures/twopage.pdf +0 -0
  38. data/spec/support/fixtures/uppercase.PNG +0 -0
  39. data/spec/support/mock_attachment.rb +24 -0
  40. data/spec/support/mock_interpolator.rb +24 -0
  41. data/spec/support/mock_url_generator_builder.rb +27 -0
  42. data/spec/support/model_reconstruction.rb +68 -0
  43. data/spec/support/test_data.rb +13 -0
  44. data/spec/support/version_helper.rb +9 -0
  45. metadata +256 -0
@@ -0,0 +1,68 @@
1
+ module ModelReconstruction
2
+ def reset_class class_name
3
+ ActiveRecord::Base.send(:include, Paperclip::Glue)
4
+ Object.send(:remove_const, class_name) rescue nil
5
+ klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
6
+
7
+ klass.class_eval do
8
+ include Paperclip::Glue
9
+ end
10
+
11
+ klass.reset_column_information
12
+ klass.connection_pool.clear_table_cache!(klass.table_name) if klass.connection_pool.respond_to?(:clear_table_cache!)
13
+
14
+ if klass.connection.respond_to?(:schema_cache)
15
+ if ActiveRecord::VERSION::STRING >= "5.0"
16
+ klass.connection.schema_cache.clear_data_source_cache!(klass.table_name)
17
+ else
18
+ klass.connection.schema_cache.clear_table_cache!(klass.table_name)
19
+ end
20
+ end
21
+
22
+ klass
23
+ end
24
+
25
+ def reset_table table_name, &block
26
+ block ||= lambda { |table| true }
27
+ ActiveRecord::Base.connection.create_table :dummies, {force: true}, &block
28
+ end
29
+
30
+ def modify_table table_name, &block
31
+ ActiveRecord::Base.connection.change_table :dummies, &block
32
+ end
33
+
34
+ def rebuild_model options = {}
35
+ ActiveRecord::Base.connection.create_table :dummies, force: true do |table|
36
+ table.column :title, :string
37
+ table.column :other, :string
38
+ table.column :avatar_file_name, :string
39
+ table.column :avatar_content_type, :string
40
+ table.column :avatar_file_size, :integer
41
+ table.column :avatar_updated_at, :datetime
42
+ table.column :avatar_fingerprint, :string
43
+ end
44
+ rebuild_class options
45
+ end
46
+
47
+ def rebuild_class options = {}
48
+ reset_class("Dummy").tap do |klass|
49
+ klass.has_attached_file :avatar, options
50
+ klass.do_not_validate_attachment_file_type :avatar
51
+ Paperclip.reset_duplicate_clash_check!
52
+ end
53
+ end
54
+
55
+ def rebuild_meta_class_of obj, options = {}
56
+ meta_class_of(obj).tap do |metaklass|
57
+ metaklass.has_attached_file :avatar, options
58
+ metaklass.do_not_validate_attachment_file_type :avatar
59
+ Paperclip.reset_duplicate_clash_check!
60
+ end
61
+ end
62
+
63
+ def meta_class_of(obj)
64
+ class << obj
65
+ self
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,13 @@
1
+ module TestData
2
+ def attachment(options={})
3
+ Paperclip::Attachment.new(:avatar, FakeModel.new, options)
4
+ end
5
+
6
+ def stringy_file
7
+ StringIO.new('.\n')
8
+ end
9
+
10
+ def fixture_file(filename)
11
+ File.join(File.dirname(__FILE__), 'fixtures', filename)
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module VersionHelper
2
+ def active_support_version
3
+ ActiveSupport::VERSION::STRING
4
+ end
5
+
6
+ def ruby_version
7
+ RUBY_VERSION
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,256 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jd-paperclip-azure
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joé Dupuis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: azure-blob
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: addressable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: kt-paperclip
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '7.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '7.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activerecord
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '6.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '6.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activerecord-import
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activemodel
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '6.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '6.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activesupport
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '6.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '6.1'
153
+ description:
154
+ email:
155
+ - joe@dupuis.io
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".autotest"
161
+ - ".github/workflows/tests.yml"
162
+ - ".gitignore"
163
+ - ".ruby-version"
164
+ - Gemfile
165
+ - History.txt
166
+ - Manifest.txt
167
+ - README.md
168
+ - Rakefile
169
+ - lib/paperclip-azure.rb
170
+ - lib/paperclip/azure.rb
171
+ - lib/paperclip/storage/azure.rb
172
+ - lib/paperclip/storage/azure/environment.rb
173
+ - paperclip-azure.gemspec
174
+ - spec/database.yml
175
+ - spec/paperclip/storage/azure/environment_spec.rb
176
+ - spec/paperclip/storage/azure_spec.rb
177
+ - spec/spec_helper.rb
178
+ - spec/support/fake_model.rb
179
+ - spec/support/fake_rails.rb
180
+ - spec/support/fixtures/12k.png
181
+ - spec/support/fixtures/50x50.png
182
+ - spec/support/fixtures/5k.png
183
+ - spec/support/fixtures/animated
184
+ - spec/support/fixtures/animated.gif
185
+ - spec/support/fixtures/animated.unknown
186
+ - spec/support/fixtures/azure.yml
187
+ - spec/support/fixtures/bad.png
188
+ - spec/support/fixtures/empty.html
189
+ - spec/support/fixtures/empty.xlsx
190
+ - spec/support/fixtures/fog.yml
191
+ - spec/support/fixtures/rotated.jpg
192
+ - spec/support/fixtures/spaced file.jpg
193
+ - spec/support/fixtures/spaced file.png
194
+ - spec/support/fixtures/text.txt
195
+ - spec/support/fixtures/twopage.pdf
196
+ - spec/support/fixtures/uppercase.PNG
197
+ - spec/support/mock_attachment.rb
198
+ - spec/support/mock_interpolator.rb
199
+ - spec/support/mock_url_generator_builder.rb
200
+ - spec/support/model_reconstruction.rb
201
+ - spec/support/test_data.rb
202
+ - spec/support/version_helper.rb
203
+ homepage: https://github.com/joedupuis/paperclip-azure
204
+ licenses:
205
+ - MIT
206
+ metadata: {}
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubygems_version: 3.5.16
223
+ signing_key:
224
+ specification_version: 4
225
+ summary: Paperclip-Azure is a Paperclip storage driver for storing files in a Microsoft
226
+ Azure Blob
227
+ test_files:
228
+ - spec/database.yml
229
+ - spec/paperclip/storage/azure/environment_spec.rb
230
+ - spec/paperclip/storage/azure_spec.rb
231
+ - spec/spec_helper.rb
232
+ - spec/support/fake_model.rb
233
+ - spec/support/fake_rails.rb
234
+ - spec/support/fixtures/12k.png
235
+ - spec/support/fixtures/50x50.png
236
+ - spec/support/fixtures/5k.png
237
+ - spec/support/fixtures/animated
238
+ - spec/support/fixtures/animated.gif
239
+ - spec/support/fixtures/animated.unknown
240
+ - spec/support/fixtures/azure.yml
241
+ - spec/support/fixtures/bad.png
242
+ - spec/support/fixtures/empty.html
243
+ - spec/support/fixtures/empty.xlsx
244
+ - spec/support/fixtures/fog.yml
245
+ - spec/support/fixtures/rotated.jpg
246
+ - spec/support/fixtures/spaced file.jpg
247
+ - spec/support/fixtures/spaced file.png
248
+ - spec/support/fixtures/text.txt
249
+ - spec/support/fixtures/twopage.pdf
250
+ - spec/support/fixtures/uppercase.PNG
251
+ - spec/support/mock_attachment.rb
252
+ - spec/support/mock_interpolator.rb
253
+ - spec/support/mock_url_generator_builder.rb
254
+ - spec/support/model_reconstruction.rb
255
+ - spec/support/test_data.rb
256
+ - spec/support/version_helper.rb