asset_cloud 2.5.3 → 2.6.0
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/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +326 -0
- data/History.md +6 -0
- data/README.rdoc +8 -0
- data/Rakefile +5 -2
- data/asset_cloud.gemspec +2 -2
- data/lib/asset_cloud/asset.rb +4 -0
- data/lib/asset_cloud/metadata.rb +10 -3
- data/spec/active_record_bucket_spec.rb +27 -27
- data/spec/asset_cloud/metadata_spec.rb +31 -0
- data/spec/asset_extension_spec.rb +21 -18
- data/spec/asset_spec.rb +47 -56
- data/spec/base_spec.rb +60 -62
- data/spec/blackhole_bucket_spec.rb +6 -5
- data/spec/bucket_chain_spec.rb +50 -50
- data/spec/bucket_spec.rb +5 -4
- data/spec/callbacks_spec.rb +31 -31
- data/spec/file_system_spec.rb +15 -16
- data/spec/find_free_key_spec.rb +17 -19
- data/spec/gcs_bucket_remote_spec.rb +18 -19
- data/spec/gcs_bucket_spec.rb +29 -28
- data/spec/memory_bucket_spec.rb +8 -9
- data/spec/mock_s3_interface.rb +4 -3
- data/spec/remote_s3_bucket_spec.rb +17 -16
- data/spec/s3_bucket_spec.rb +12 -12
- data/spec/spec_helper.rb +2 -1
- data/spec/validations_spec.rb +18 -16
- data/spec/versioned_memory_bucket_spec.rb +6 -6
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134ba5f46359569f492531369197e78de71f48eabc0efef27c60b9f2a9b2a4fd
|
4
|
+
data.tar.gz: 28edd6a34bfb58f3fe796c697a0c58855a65f117c489a4d427711b88386b2df0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161578c01372d753f3fe15558bc0f2b446e2cdbab75272c48c72bb3ce3e0a94c67616544b712efafc74eac6a7e0e18f69367712e5a37e87a769723177479c0c8
|
7
|
+
data.tar.gz: a65784b410afe987d821589a631cf16e4b78795b6e07cebf6b6a4252c5631dc35eaca8a1da8ea2cbe4bf37d3308965bd5ed3a6dafe0c57de37a49489d8e11d4d
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,326 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-05-22 10:33:52 -0400 using RuboCop version 0.82.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 7
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
12
|
+
Layout/EmptyLineBetweenDefs:
|
13
|
+
Exclude:
|
14
|
+
- 'lib/asset_cloud/asset_extension.rb'
|
15
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
# Configuration parameters: EnforcedStyle.
|
20
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
21
|
+
Layout/EmptyLinesAroundBlockBody:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/asset_cloud/callbacks.rb'
|
24
|
+
|
25
|
+
# Offense count: 4
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
# Configuration parameters: EnforcedStyle.
|
28
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
29
|
+
Layout/EmptyLinesAroundClassBody:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/asset_cloud/base.rb'
|
32
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
33
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
34
|
+
- 'lib/asset_cloud/buckets/versioned_memory_bucket.rb'
|
35
|
+
|
36
|
+
# Offense count: 6
|
37
|
+
# Cop supports --auto-correct.
|
38
|
+
# Configuration parameters: EnforcedStyle.
|
39
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
40
|
+
Layout/EmptyLinesAroundModuleBody:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/asset_cloud/asset.rb'
|
43
|
+
- 'lib/asset_cloud/base.rb'
|
44
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
45
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
46
|
+
- 'lib/asset_cloud/free_key_locator.rb'
|
47
|
+
|
48
|
+
# Offense count: 2
|
49
|
+
# Cop supports --auto-correct.
|
50
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
51
|
+
Layout/ExtraSpacing:
|
52
|
+
Exclude:
|
53
|
+
- 'lib/asset_cloud/base.rb'
|
54
|
+
|
55
|
+
# Offense count: 9
|
56
|
+
# Cop supports --auto-correct.
|
57
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
58
|
+
# URISchemes: http, https
|
59
|
+
Layout/LineLength:
|
60
|
+
Max: 187
|
61
|
+
|
62
|
+
# Offense count: 1
|
63
|
+
# Cop supports --auto-correct.
|
64
|
+
Layout/RescueEnsureAlignment:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
67
|
+
|
68
|
+
# Offense count: 5
|
69
|
+
# Cop supports --auto-correct.
|
70
|
+
Layout/SpaceAfterComma:
|
71
|
+
Exclude:
|
72
|
+
- 'lib/asset_cloud/asset.rb'
|
73
|
+
- 'lib/asset_cloud/base.rb'
|
74
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
75
|
+
- 'lib/asset_cloud/buckets/memory_bucket.rb'
|
76
|
+
|
77
|
+
# Offense count: 7
|
78
|
+
# Cop supports --auto-correct.
|
79
|
+
# Configuration parameters: EnforcedStyle.
|
80
|
+
# SupportedStyles: space, no_space
|
81
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
82
|
+
Exclude:
|
83
|
+
- 'lib/asset_cloud/base.rb'
|
84
|
+
- 'lib/asset_cloud/bucket.rb'
|
85
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
86
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
87
|
+
- 'lib/asset_cloud/buckets/memory_bucket.rb'
|
88
|
+
|
89
|
+
# Offense count: 3
|
90
|
+
# Cop supports --auto-correct.
|
91
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
92
|
+
# SupportedStylesForExponentOperator: space, no_space
|
93
|
+
Layout/SpaceAroundOperators:
|
94
|
+
Exclude:
|
95
|
+
- 'lib/asset_cloud/base.rb'
|
96
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
97
|
+
|
98
|
+
# Offense count: 22
|
99
|
+
# Cop supports --auto-correct.
|
100
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
101
|
+
# SupportedStyles: space, no_space
|
102
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
103
|
+
Layout/SpaceInsideBlockBraces:
|
104
|
+
Exclude:
|
105
|
+
- 'lib/asset_cloud/base.rb'
|
106
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
107
|
+
|
108
|
+
# Offense count: 2
|
109
|
+
# Cop supports --auto-correct.
|
110
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
111
|
+
# SupportedStyles: space, no_space, compact
|
112
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
113
|
+
Layout/SpaceInsideHashLiteralBraces:
|
114
|
+
Exclude:
|
115
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
116
|
+
|
117
|
+
# Offense count: 9
|
118
|
+
# Configuration parameters: AllowSafeAssignment.
|
119
|
+
Lint/AssignmentInCondition:
|
120
|
+
Exclude:
|
121
|
+
- 'lib/asset_cloud/asset.rb'
|
122
|
+
- 'lib/asset_cloud/base.rb'
|
123
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
124
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
125
|
+
- 'lib/asset_cloud/buckets/s3_bucket.rb'
|
126
|
+
|
127
|
+
# Offense count: 2
|
128
|
+
Lint/DuplicateMethods:
|
129
|
+
Exclude:
|
130
|
+
- 'lib/asset_cloud/asset.rb'
|
131
|
+
|
132
|
+
# Offense count: 1
|
133
|
+
Lint/IneffectiveAccessModifier:
|
134
|
+
Exclude:
|
135
|
+
- 'lib/asset_cloud/base.rb'
|
136
|
+
|
137
|
+
# Offense count: 1
|
138
|
+
# Configuration parameters: AllowComments.
|
139
|
+
Lint/SuppressedException:
|
140
|
+
Exclude:
|
141
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
142
|
+
|
143
|
+
# Offense count: 1
|
144
|
+
# Cop supports --auto-correct.
|
145
|
+
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
146
|
+
Lint/UnusedBlockArgument:
|
147
|
+
Exclude:
|
148
|
+
- 'lib/asset_cloud/buckets/memory_bucket.rb'
|
149
|
+
|
150
|
+
# Offense count: 9
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
153
|
+
Lint/UnusedMethodArgument:
|
154
|
+
Exclude:
|
155
|
+
- 'lib/asset_cloud/base.rb'
|
156
|
+
- 'lib/asset_cloud/buckets/blackhole_bucket.rb'
|
157
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
158
|
+
- 'lib/asset_cloud/buckets/invalid_bucket.rb'
|
159
|
+
|
160
|
+
# Offense count: 6
|
161
|
+
Lint/UselessAssignment:
|
162
|
+
Exclude:
|
163
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
164
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
165
|
+
- 'spec/gcs_bucket_spec.rb'
|
166
|
+
|
167
|
+
# Offense count: 1
|
168
|
+
Naming/ConstantName:
|
169
|
+
Exclude:
|
170
|
+
- 'lib/asset_cloud/buckets/invalid_bucket.rb'
|
171
|
+
|
172
|
+
# Offense count: 2
|
173
|
+
# Cop supports --auto-correct.
|
174
|
+
# Configuration parameters: EnforcedStyle.
|
175
|
+
# SupportedStyles: always, conditionals
|
176
|
+
Style/AndOr:
|
177
|
+
Exclude:
|
178
|
+
- 'lib/asset_cloud/asset.rb'
|
179
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
180
|
+
|
181
|
+
# Offense count: 1
|
182
|
+
# Cop supports --auto-correct.
|
183
|
+
# Configuration parameters: EnforcedStyle, AllowInnerBackticks.
|
184
|
+
# SupportedStyles: backticks, percent_x, mixed
|
185
|
+
Style/CommandLiteral:
|
186
|
+
Exclude:
|
187
|
+
- 'asset_cloud.gemspec'
|
188
|
+
|
189
|
+
# Offense count: 1
|
190
|
+
# Cop supports --auto-correct.
|
191
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
192
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
193
|
+
Style/ConditionalAssignment:
|
194
|
+
Exclude:
|
195
|
+
- 'lib/asset_cloud/base.rb'
|
196
|
+
|
197
|
+
# Offense count: 22
|
198
|
+
# Cop supports --auto-correct.
|
199
|
+
# Configuration parameters: EnforcedStyle.
|
200
|
+
# SupportedStyles: always, always_true, never
|
201
|
+
Style/FrozenStringLiteralComment:
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
# Offense count: 3
|
205
|
+
# Cop supports --auto-correct.
|
206
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
207
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
208
|
+
Style/HashSyntax:
|
209
|
+
Exclude:
|
210
|
+
- 'lib/asset_cloud/asset_extension.rb'
|
211
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
212
|
+
|
213
|
+
# Offense count: 17
|
214
|
+
# Cop supports --auto-correct.
|
215
|
+
# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle.
|
216
|
+
# SupportedStyles: require_parentheses, omit_parentheses
|
217
|
+
Style/MethodCallWithArgsParentheses:
|
218
|
+
Exclude:
|
219
|
+
- 'Gemfile'
|
220
|
+
- 'Rakefile'
|
221
|
+
- 'asset_cloud.gemspec'
|
222
|
+
- 'lib/asset_cloud.rb'
|
223
|
+
- 'lib/asset_cloud/asset.rb'
|
224
|
+
- 'lib/asset_cloud/base.rb'
|
225
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
226
|
+
- 'lib/asset_cloud/metadata.rb'
|
227
|
+
|
228
|
+
# Offense count: 2
|
229
|
+
Style/MethodMissingSuper:
|
230
|
+
Exclude:
|
231
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
232
|
+
- 'spec/callbacks_spec.rb'
|
233
|
+
|
234
|
+
# Offense count: 2
|
235
|
+
Style/MissingRespondToMissing:
|
236
|
+
Exclude:
|
237
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
238
|
+
- 'spec/callbacks_spec.rb'
|
239
|
+
|
240
|
+
# Offense count: 2
|
241
|
+
# Cop supports --auto-correct.
|
242
|
+
Style/ParallelAssignment:
|
243
|
+
Exclude:
|
244
|
+
- 'lib/asset_cloud/base.rb'
|
245
|
+
- 'lib/asset_cloud/bucket.rb'
|
246
|
+
|
247
|
+
# Offense count: 2
|
248
|
+
# Cop supports --auto-correct.
|
249
|
+
Style/PerlBackrefs:
|
250
|
+
Exclude:
|
251
|
+
- 'lib/asset_cloud/base.rb'
|
252
|
+
- 'lib/asset_cloud/buckets/s3_bucket.rb'
|
253
|
+
|
254
|
+
# Offense count: 3
|
255
|
+
# Cop supports --auto-correct.
|
256
|
+
# Configuration parameters: EnforcedStyle.
|
257
|
+
# SupportedStyles: short, verbose
|
258
|
+
Style/PreferredHashMethods:
|
259
|
+
Exclude:
|
260
|
+
- 'lib/asset_cloud/buckets/memory_bucket.rb'
|
261
|
+
- 'lib/asset_cloud/buckets/versioned_memory_bucket.rb'
|
262
|
+
|
263
|
+
# Offense count: 2
|
264
|
+
# Cop supports --auto-correct.
|
265
|
+
Style/RedundantBegin:
|
266
|
+
Exclude:
|
267
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
268
|
+
- 'lib/asset_cloud/buckets/gcs_bucket.rb'
|
269
|
+
|
270
|
+
# Offense count: 5
|
271
|
+
# Cop supports --auto-correct.
|
272
|
+
Style/RedundantPercentQ:
|
273
|
+
Exclude:
|
274
|
+
- 'asset_cloud.gemspec'
|
275
|
+
|
276
|
+
# Offense count: 3
|
277
|
+
# Cop supports --auto-correct.
|
278
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
279
|
+
Style/RedundantReturn:
|
280
|
+
Exclude:
|
281
|
+
- 'lib/asset_cloud/buckets/bucket_chain.rb'
|
282
|
+
- 'lib/asset_cloud/buckets/gcs_bucket.rb'
|
283
|
+
- 'lib/asset_cloud/buckets/s3_bucket.rb'
|
284
|
+
|
285
|
+
# Offense count: 14
|
286
|
+
# Cop supports --auto-correct.
|
287
|
+
Style/RedundantSelf:
|
288
|
+
Exclude:
|
289
|
+
- 'lib/asset_cloud/asset.rb'
|
290
|
+
- 'lib/asset_cloud/buckets/active_record_bucket.rb'
|
291
|
+
- 'lib/asset_cloud/callbacks.rb'
|
292
|
+
- 'lib/asset_cloud/metadata.rb'
|
293
|
+
- 'lib/asset_cloud/validations.rb'
|
294
|
+
|
295
|
+
# Offense count: 4
|
296
|
+
# Cop supports --auto-correct.
|
297
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
298
|
+
# SupportedStyles: slashes, percent_r, mixed
|
299
|
+
Style/RegexpLiteral:
|
300
|
+
Exclude:
|
301
|
+
- 'lib/asset_cloud/base.rb'
|
302
|
+
- 'lib/asset_cloud/buckets/file_system_bucket.rb'
|
303
|
+
- 'lib/asset_cloud/buckets/s3_bucket.rb'
|
304
|
+
|
305
|
+
# Offense count: 10
|
306
|
+
# Cop supports --auto-correct.
|
307
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
308
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
309
|
+
Style/SafeNavigation:
|
310
|
+
Exclude:
|
311
|
+
- 'lib/asset_cloud/base.rb'
|
312
|
+
|
313
|
+
# Offense count: 2
|
314
|
+
# Cop supports --auto-correct.
|
315
|
+
# Configuration parameters: AllowIfMethodIsEmpty.
|
316
|
+
Style/SingleLineMethods:
|
317
|
+
Exclude:
|
318
|
+
- 'lib/asset_cloud/asset_extension.rb'
|
319
|
+
|
320
|
+
# Offense count: 1
|
321
|
+
# Cop supports --auto-correct.
|
322
|
+
# Configuration parameters: EnforcedStyle.
|
323
|
+
# SupportedStyles: use_perl_names, use_english_names
|
324
|
+
Style/SpecialGlobalVars:
|
325
|
+
Exclude:
|
326
|
+
- 'asset_cloud.gemspec'
|
data/History.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Asset Cloud Version History
|
2
2
|
|
3
|
+
## Version 2.6.0, 2020-05-22
|
4
|
+
|
5
|
+
* Add checksum to metadata (https://github.com/Shopify/asset_cloud/pull/57)
|
6
|
+
|
7
|
+
**Note:** There are versions between 2.2.2 and 2.6.0 not covered by the History.
|
8
|
+
|
3
9
|
## Version 2.2.2, 2016-02-11
|
4
10
|
|
5
11
|
* Allow asset_class to be a proc which determines the class to use within a bucket (https://github.com/Shopify/asset_cloud/pull/15)
|
data/README.rdoc
CHANGED
@@ -4,6 +4,14 @@
|
|
4
4
|
|
5
5
|
An abstraction layer around arbitrary and diverse asset stores.
|
6
6
|
|
7
|
+
== Value Hash vs Checksum
|
8
|
+
|
9
|
+
+value_hash+ is intended as a *private* hash/checksum, not exposed to end users. Its underlying algorithm is private, and
|
10
|
+
could change over time so should not be relied on by clients.
|
11
|
+
|
12
|
+
+checksum+ is intended as a *public* hash/checksum, exposed to end users. Its underlying algorithms is documented (e.g. MD5)
|
13
|
+
and is not expected to change.
|
14
|
+
|
7
15
|
== Installation
|
8
16
|
|
9
17
|
=== as a Gem
|
data/Rakefile
CHANGED
@@ -5,9 +5,10 @@ require 'rake'
|
|
5
5
|
require 'rake/testtask'
|
6
6
|
require 'rdoc/task'
|
7
7
|
require 'rspec/core/rake_task'
|
8
|
+
require 'rubocop/rake_task'
|
8
9
|
|
9
|
-
desc 'Default: run unit tests.'
|
10
|
-
task :
|
10
|
+
desc 'Default: run unit tests and style checks.'
|
11
|
+
task default: [:spec, :rubocop]
|
11
12
|
|
12
13
|
desc "Run all spec examples"
|
13
14
|
RSpec::Core::RakeTask.new do |t|
|
@@ -23,3 +24,5 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
23
24
|
rdoc.rdoc_files.include('README')
|
24
25
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
26
|
end
|
27
|
+
|
28
|
+
RuboCop::RakeTask.new
|
data/asset_cloud.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{asset_cloud}
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.6.0"
|
6
6
|
|
7
7
|
s.authors = %w(Shopify)
|
8
8
|
s.summary = %q{An abstraction layer around arbitrary and diverse asset stores.}
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.add_development_dependency 'rspec'
|
25
25
|
s.add_development_dependency 'rake'
|
26
|
-
s.add_development_dependency 'mocha'
|
27
26
|
s.add_development_dependency 'pry'
|
28
27
|
s.add_development_dependency 'pry-byebug'
|
28
|
+
s.add_development_dependency 'rubocop-shopify'
|
29
29
|
end
|
data/lib/asset_cloud/asset.rb
CHANGED
data/lib/asset_cloud/metadata.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module AssetCloud
|
2
2
|
class Metadata
|
3
|
-
attr_accessor :exist, :size, :created_at, :updated_at, :value_hash
|
3
|
+
attr_accessor :exist, :size, :created_at, :updated_at, :value_hash, :checksum
|
4
4
|
|
5
5
|
def new?
|
6
6
|
!self.exist
|
@@ -10,9 +10,16 @@ module AssetCloud
|
|
10
10
|
self.exist
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
14
|
+
def initialize(exist, size = nil, created_at = nil, updated_at = nil, value_hash = nil, checksum = nil)
|
15
|
+
self.exist = exist
|
16
|
+
self.size = size
|
17
|
+
self.created_at = created_at
|
18
|
+
self.updated_at = updated_at
|
19
|
+
self.value_hash = value_hash
|
20
|
+
self.checksum = checksum
|
15
21
|
end
|
22
|
+
# rubocop:enable Metrics/ParameterLists
|
16
23
|
|
17
24
|
def self.existing
|
18
25
|
self.new(true)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
MockRecords = Object.new
|
@@ -5,7 +6,9 @@ MockRecords = Object.new
|
|
5
6
|
class MockActiveRecordBucket < AssetCloud::ActiveRecordBucket
|
6
7
|
self.key_attribute = 'name'
|
7
8
|
self.value_attribute = 'body'
|
9
|
+
|
8
10
|
protected
|
11
|
+
|
9
12
|
def records
|
10
13
|
MockRecords
|
11
14
|
end
|
@@ -19,49 +22,49 @@ describe AssetCloud::ActiveRecordBucket do
|
|
19
22
|
directory = File.dirname(__FILE__) + '/files'
|
20
23
|
|
21
24
|
before do
|
22
|
-
@cloud = RecordCloud.new(directory
|
25
|
+
@cloud = RecordCloud.new(directory, 'http://assets/files')
|
23
26
|
@bucket = @cloud.buckets[:stuff]
|
24
27
|
end
|
25
28
|
|
26
29
|
describe '#ls' do
|
27
30
|
before do
|
28
|
-
MockRecords.
|
29
|
-
@mock_connection.
|
30
|
-
(@mock_record = double("record")).
|
31
|
+
expect(MockRecords).to(receive(:connection).and_return(@mock_connection = double("connection")))
|
32
|
+
expect(@mock_connection).to(receive(:quote_column_name).with('name').and_return("`name`"))
|
33
|
+
expect(@mock_record = double("record")).to(receive(:name).and_return('stuff/a1'))
|
31
34
|
end
|
32
35
|
|
33
36
|
it "should return a list of assets which start with the given prefix" do
|
34
|
-
MockRecords.
|
37
|
+
expect(MockRecords).to(receive(:all).with(conditions: ["`name` LIKE ?", "stuff/a%"]).and_return([@mock_record]))
|
35
38
|
|
36
|
-
@bucket.ls('stuff/a').size.
|
39
|
+
expect(@bucket.ls('stuff/a').size).to(eq(1))
|
37
40
|
end
|
38
41
|
|
39
42
|
it "should return a list of all assets when a prefix is not given" do
|
40
|
-
MockRecords.
|
43
|
+
expect(MockRecords).to(receive(:all).with(conditions: ["`name` LIKE ?", "stuff%"]).and_return([@mock_record]))
|
41
44
|
|
42
|
-
@bucket.ls.size.
|
45
|
+
expect(@bucket.ls.size).to(eq(1))
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
49
|
describe '#read' do
|
47
50
|
it "should return the value of a key when it exists" do
|
48
|
-
(@mock_record = double("record")).
|
49
|
-
MockRecords.
|
51
|
+
expect(@mock_record = double("record")).to(receive(:body).and_return('foo'))
|
52
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
50
53
|
|
51
54
|
@bucket.read('stuff/a1')
|
52
55
|
end
|
53
56
|
it "should raise AssetNotFoundError when nothing is there" do
|
54
|
-
MockRecords.
|
57
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(nil))
|
55
58
|
|
56
|
-
|
59
|
+
expect { @bucket.read('stuff/a1') }.to(raise_error(AssetCloud::AssetNotFoundError))
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
63
|
describe '#write' do
|
61
64
|
it "should write to the DB" do
|
62
|
-
(@mock_record = double("record")).
|
63
|
-
@mock_record.
|
64
|
-
MockRecords.
|
65
|
+
expect(@mock_record = double("record")).to(receive(:body=).with('foo').and_return('foo'))
|
66
|
+
expect(@mock_record).to(receive(:save!).and_return(true))
|
67
|
+
expect(MockRecords).to(receive(:find_or_initialize_by_name).with('stuff/a1').and_return(@mock_record))
|
65
68
|
|
66
69
|
@bucket.write('stuff/a1', 'foo')
|
67
70
|
end
|
@@ -69,8 +72,8 @@ describe AssetCloud::ActiveRecordBucket do
|
|
69
72
|
|
70
73
|
describe '#delete' do
|
71
74
|
it "should destroy records" do
|
72
|
-
(@mock_record = double("record")).
|
73
|
-
MockRecords.
|
75
|
+
expect(@mock_record = double("record")).to(receive(:destroy).and_return(true))
|
76
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
74
77
|
|
75
78
|
@bucket.delete('stuff/a1')
|
76
79
|
end
|
@@ -78,18 +81,15 @@ describe AssetCloud::ActiveRecordBucket do
|
|
78
81
|
|
79
82
|
describe '#stat' do
|
80
83
|
it "should return appropriate metadata" do
|
81
|
-
(@mock_record = double("record")).
|
82
|
-
@mock_record.
|
83
|
-
@mock_record.
|
84
|
-
MockRecords.
|
84
|
+
expect(@mock_record = double("record")).to(receive(:created_at).and_return(1982))
|
85
|
+
expect(@mock_record).to(receive(:updated_at).and_return(2002))
|
86
|
+
expect(@mock_record).to(receive(:body).and_return('foo'))
|
87
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
85
88
|
|
86
89
|
metadata = @bucket.stat('stuff/a1')
|
87
|
-
metadata.created_at.
|
88
|
-
metadata.updated_at.
|
89
|
-
metadata.size.
|
90
|
+
expect(metadata.created_at).to(eq(1982))
|
91
|
+
expect(metadata.updated_at).to(eq(2002))
|
92
|
+
expect(metadata.size).to(eq(3))
|
90
93
|
end
|
91
94
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
95
|
end
|