paperclip-azure 1.0.0 → 1.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 +4 -4
- data/Manifest.txt +27 -1
- data/README.txt +25 -7
- data/Rakefile +7 -1
- data/lib/paperclip-azure.rb +0 -1
- data/lib/paperclip/azure.rb +1 -1
- data/lib/paperclip/storage/azure.rb +43 -57
- data/lib/paperclip/storage/azure/environment.rb +2 -2
- data/spec/database.yml +3 -0
- data/spec/paperclip/storage/azure_spec.rb +435 -0
- data/spec/spec_helper.rb +29 -3
- data/spec/support/fake_model.rb +25 -0
- data/spec/support/fake_rails.rb +12 -0
- data/spec/support/fixtures/12k.png +0 -0
- data/spec/support/fixtures/50x50.png +0 -0
- data/spec/support/fixtures/5k.png +0 -0
- data/spec/support/fixtures/animated +0 -0
- data/spec/support/fixtures/animated.gif +0 -0
- data/spec/support/fixtures/animated.unknown +0 -0
- data/spec/support/fixtures/azure.yml +8 -0
- data/spec/support/fixtures/bad.png +1 -0
- data/spec/support/fixtures/empty.html +1 -0
- data/spec/support/fixtures/empty.xlsx +0 -0
- data/spec/support/fixtures/fog.yml +8 -0
- data/spec/support/fixtures/rotated.jpg +0 -0
- data/spec/support/fixtures/spaced file.jpg +0 -0
- data/spec/support/fixtures/spaced file.png +0 -0
- data/spec/support/fixtures/text.txt +1 -0
- data/spec/support/fixtures/twopage.pdf +0 -0
- data/spec/support/fixtures/uppercase.PNG +0 -0
- data/spec/support/mock_attachment.rb +24 -0
- data/spec/support/mock_interpolator.rb +24 -0
- data/spec/support/mock_url_generator_builder.rb +27 -0
- data/spec/support/model_reconstruction.rb +68 -0
- data/spec/support/test_data.rb +13 -0
- data/spec/support/version_helper.rb +9 -0
- metadata +116 -6
- data/lib/azure/core/auth/shared_access_signature.rb +0 -84
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
|
+
require 'active_record'
|
4
|
+
require 'active_record/version'
|
5
|
+
require 'active_support'
|
6
|
+
require 'active_support/core_ext'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'pathname'
|
9
|
+
require 'activerecord-import'
|
10
|
+
require 'simplecov'
|
11
|
+
require 'yaml'
|
12
|
+
require 'paperclip'
|
3
13
|
|
4
14
|
ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
|
5
15
|
|
@@ -22,9 +32,25 @@ $LOAD_PATH << File.join(ROOT, 'lib')
|
|
22
32
|
$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
|
23
33
|
require File.join(ROOT, 'lib', 'paperclip-azure.rb')
|
24
34
|
|
25
|
-
|
26
|
-
|
35
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
36
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
37
|
+
ActiveRecord::Base.establish_connection(config['test'])
|
38
|
+
if ActiveRecord::VERSION::STRING >= "4.2" &&
|
39
|
+
ActiveRecord::VERSION::STRING < "5.0"
|
40
|
+
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
41
|
+
end
|
42
|
+
Paperclip.options[:logger] = ActiveRecord::Base.logger
|
43
|
+
|
27
44
|
Dir[File.join(ROOT, 'spec', 'support', '**', '*.rb')].each{|f| require f }
|
28
45
|
|
46
|
+
Rails = FakeRails.new('test', Pathname.new(ROOT).join('tmp'))
|
47
|
+
ActiveSupport::Deprecation.silenced = true
|
48
|
+
|
29
49
|
RSpec.configure do |config|
|
50
|
+
config.include ModelReconstruction
|
51
|
+
config.include TestData
|
52
|
+
config.extend VersionHelper
|
53
|
+
config.before(:all) do
|
54
|
+
rebuild_model
|
55
|
+
end
|
30
56
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class FakeModel
|
2
|
+
attr_accessor(
|
3
|
+
:avatar_file_name,
|
4
|
+
:avatar_file_size,
|
5
|
+
:avatar_updated_at,
|
6
|
+
:avatar_content_type,
|
7
|
+
:avatar_fingerprint,
|
8
|
+
:id
|
9
|
+
)
|
10
|
+
|
11
|
+
def errors
|
12
|
+
@errors ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_paperclip_callbacks name, *args
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid?
|
19
|
+
errors.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_record?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
This is not an image.
|
@@ -0,0 +1 @@
|
|
1
|
+
<html></html>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
paperclip!
|
Binary file
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class MockAttachment
|
2
|
+
attr_accessor :updated_at, :original_filename
|
3
|
+
attr_reader :options
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@options = options
|
7
|
+
@model = options[:model]
|
8
|
+
@responds_to_updated_at = options[:responds_to_updated_at]
|
9
|
+
@updated_at = options[:updated_at]
|
10
|
+
@original_filename = options[:original_filename]
|
11
|
+
end
|
12
|
+
|
13
|
+
def instance
|
14
|
+
@model
|
15
|
+
end
|
16
|
+
|
17
|
+
def respond_to?(meth)
|
18
|
+
if meth.to_s == "updated_at"
|
19
|
+
@responds_to_updated_at || @updated_at
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class MockInterpolator
|
2
|
+
def initialize(options = {})
|
3
|
+
@options = options
|
4
|
+
end
|
5
|
+
|
6
|
+
def interpolate(pattern, attachment, style_name)
|
7
|
+
@interpolated_pattern = pattern
|
8
|
+
@interpolated_attachment = attachment
|
9
|
+
@interpolated_style_name = style_name
|
10
|
+
@options[:result]
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_interpolated_pattern?(pattern)
|
14
|
+
@interpolated_pattern == pattern
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_interpolated_style_name?(style_name)
|
18
|
+
@interpolated_style_name == style_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_interpolated_attachment?(attachment)
|
22
|
+
@interpolated_attachment == attachment
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class MockUrlGeneratorBuilder
|
2
|
+
def initializer
|
3
|
+
end
|
4
|
+
|
5
|
+
def new(attachment)
|
6
|
+
@attachment = attachment
|
7
|
+
@attachment_options = @attachment.options
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
def for(style_name, options)
|
12
|
+
@generated_url_with_style_name = style_name
|
13
|
+
@generated_url_with_options = options
|
14
|
+
"hello"
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_generated_url_with_options?(options)
|
18
|
+
# options.is_a_subhash_of(@generated_url_with_options)
|
19
|
+
options.inject(true) do |acc,(k,v)|
|
20
|
+
acc && @generated_url_with_options[k] == v
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_generated_url_with_style_name?(style_name)
|
25
|
+
@generated_url_with_style_name == style_name
|
26
|
+
end
|
27
|
+
end
|
@@ -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
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hireross.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: azure
|
14
|
+
name: azure-storage
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.12'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: hashie
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: paperclip
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.3.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.3.6
|
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.8
|
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.8
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +108,62 @@ dependencies:
|
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activerecord
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.2.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 4.2.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: activerecord-import
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.19'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.19'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: activemodel
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 4.2.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 4.2.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: activesupport
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 4.2.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 4.2.0
|
83
167
|
- !ruby/object:Gem::Dependency
|
84
168
|
name: rdoc
|
85
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,13 +208,39 @@ files:
|
|
124
208
|
- Manifest.txt
|
125
209
|
- README.txt
|
126
210
|
- Rakefile
|
127
|
-
- lib/azure/core/auth/shared_access_signature.rb
|
128
211
|
- lib/paperclip-azure.rb
|
129
212
|
- lib/paperclip/azure.rb
|
130
213
|
- lib/paperclip/storage/azure.rb
|
131
214
|
- lib/paperclip/storage/azure/environment.rb
|
215
|
+
- spec/database.yml
|
132
216
|
- spec/paperclip/storage/azure/environment_spec.rb
|
217
|
+
- spec/paperclip/storage/azure_spec.rb
|
133
218
|
- spec/spec_helper.rb
|
219
|
+
- spec/support/fake_model.rb
|
220
|
+
- spec/support/fake_rails.rb
|
221
|
+
- spec/support/fixtures/12k.png
|
222
|
+
- spec/support/fixtures/50x50.png
|
223
|
+
- spec/support/fixtures/5k.png
|
224
|
+
- spec/support/fixtures/animated
|
225
|
+
- spec/support/fixtures/animated.gif
|
226
|
+
- spec/support/fixtures/animated.unknown
|
227
|
+
- spec/support/fixtures/azure.yml
|
228
|
+
- spec/support/fixtures/bad.png
|
229
|
+
- spec/support/fixtures/empty.html
|
230
|
+
- spec/support/fixtures/empty.xlsx
|
231
|
+
- spec/support/fixtures/fog.yml
|
232
|
+
- spec/support/fixtures/rotated.jpg
|
233
|
+
- spec/support/fixtures/spaced file.jpg
|
234
|
+
- spec/support/fixtures/spaced file.png
|
235
|
+
- spec/support/fixtures/text.txt
|
236
|
+
- spec/support/fixtures/twopage.pdf
|
237
|
+
- spec/support/fixtures/uppercase.PNG
|
238
|
+
- spec/support/mock_attachment.rb
|
239
|
+
- spec/support/mock_interpolator.rb
|
240
|
+
- spec/support/mock_url_generator_builder.rb
|
241
|
+
- spec/support/model_reconstruction.rb
|
242
|
+
- spec/support/test_data.rb
|
243
|
+
- spec/support/version_helper.rb
|
134
244
|
homepage: https://github.com/supportify/paperclip-azure
|
135
245
|
licenses:
|
136
246
|
- MIT
|