jamesmacaulay-asset_cloud 0.5.2 → 0.5.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
data/asset_cloud.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{asset_cloud}
5
- s.version = "0.5.2"
5
+ s.version = "0.5.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Shopify"]
9
- s.date = %q{2009-07-03}
9
+ s.date = %q{2009-07-06}
10
10
  s.description = %q{An abstraction layer around arbitrary and diverse asset stores.}
11
11
  s.email = %q{developers@shopify.com}
12
12
  s.extra_rdoc_files = [
@@ -12,26 +12,26 @@ module AssetCloud
12
12
  attr_accessor :url, :root
13
13
 
14
14
  class_inheritable_accessor :root_bucket_class
15
- self.root_bucket_class = FileSystemBucket
15
+ self.root_bucket_class = 'AssetCloud::FileSystemBucket'
16
16
  class_inheritable_accessor :root_asset_class
17
- self.root_asset_class = Asset
17
+ self.root_asset_class = 'AssetCloud::Asset'
18
18
 
19
19
  class_inheritable_hash :bucket_classes
20
20
  self.bucket_classes = {}
21
21
  class_inheritable_hash :asset_classes
22
22
  self.asset_classes = {}
23
23
 
24
- def self.bucket(*args)
24
+ def self.bucket(*args)
25
25
  asset_class = if args.last.is_a? Hash
26
- args.pop[:asset_class]
26
+ convert_to_class_name_if_possible(args.pop[:asset_class])
27
27
  end
28
28
 
29
- if args.last.is_a? Class
30
- bucket_class = args.pop
29
+ bucket_class = if args.last.is_a? Class
30
+ convert_to_class_name_if_possible(args.pop)
31
31
  else
32
32
  raise ArgumentError, 'requires a bucket class'
33
33
  end
34
-
34
+
35
35
  if bucket_name = args.first
36
36
  self.bucket_classes[bucket_name.to_sym] = bucket_class
37
37
  self.asset_classes[bucket_name.to_sym] = asset_class if asset_class
@@ -43,8 +43,8 @@ module AssetCloud
43
43
 
44
44
  def buckets
45
45
  @buckets ||= Hash.new do |hash, key|
46
- if klass = self.class.bucket_classes[key]
47
- hash[key] = klass.new(self, key)
46
+ if klass = self.class.bucket_classes[key]
47
+ hash[key] = constantize_if_necessary(klass).new(self, key)
48
48
  else
49
49
  hash[key] = nil
50
50
  end
@@ -169,7 +169,8 @@ module AssetCloud
169
169
  protected
170
170
 
171
171
  def asset_class_for(key)
172
- self.class.asset_classes[bucket_symbol_for_key(key)] || self.class.root_asset_class
172
+ klass = self.class.asset_classes[bucket_symbol_for_key(key)] || self.class.root_asset_class
173
+ constantize_if_necessary(klass)
173
174
  end
174
175
 
175
176
  def bucket_symbol_for_key(key)
@@ -177,7 +178,19 @@ module AssetCloud
177
178
  end
178
179
 
179
180
  def root_bucket
180
- @default_bucket ||= self.class.root_bucket_class.new(self, '')
181
+ @default_bucket ||= constantize_if_necessary(self.class.root_bucket_class).new(self, '')
182
+ end
183
+
184
+ def constantize_if_necessary(klass)
185
+ klass.is_a?(Class) ? klass : klass.constantize
186
+ end
187
+
188
+ def self.convert_to_class_name_if_possible(klass)
189
+ if klass.is_a?(Class) && klass.name.present?
190
+ klass.name
191
+ else
192
+ klass
193
+ end
181
194
  end
182
195
 
183
196
  def check_key_for_errors(key)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jamesmacaulay-asset_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-03 00:00:00 -07:00
12
+ date: 2009-07-06 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15