couch_photo 1.0.0.beta.8 → 1.0.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.beta.8
1
+ 1.0.0.beta.9
@@ -64,7 +64,7 @@ module CouchPhoto
64
64
  private
65
65
  def load_variations
66
66
  all_variations = {}
67
-
67
+
68
68
  # setup defined variations
69
69
  defined_variation_names.each do |defined_variation_name|
70
70
  all_variations[defined_variation_name.to_sym] = CouchPhoto::Variation.new self, defined_variation_name
@@ -75,6 +75,9 @@ module CouchPhoto
75
75
  all_variations[custom_variation_name] = CouchPhoto::CustomVariation.new self, custom_variation_name
76
76
  end
77
77
 
78
+ # setup original variation
79
+ all_variations[original.variation_filename] = original if original.exists?
80
+
78
81
  all_variations
79
82
  end
80
83
 
@@ -21,12 +21,23 @@ module CouchPhoto
21
21
  end
22
22
  end
23
23
 
24
- private
24
+ def variation_name
25
+ "original.#{extension}"
26
+ end
27
+
28
+ def variation_filename
29
+ "original.#{extension}"
30
+ end
31
+
25
32
  def attachment_name
26
- @attachment_name ||=
27
- @document["_attachments"].keys.select do |attachment_name|
28
- attachment_name.match /variations\/original\.[^.]*/
29
- end.first
33
+ if @attachment_name
34
+ @attachment_name
35
+ elsif @document["_attachments"]
36
+ @attachment_name ||=
37
+ @document["_attachments"].keys.select do |attachment_name|
38
+ attachment_name.match /variations\/original\.[^.]*/
39
+ end.first
40
+ end
30
41
  end
31
42
  end
32
43
  end
@@ -82,17 +82,16 @@ module CouchPhoto
82
82
  "variations/#{variation_filename}"
83
83
  end
84
84
 
85
- private
86
85
  def exists?
87
- !@document["_attachments"][attachment_name].nil?
86
+ @document["_attachments"] && @document["_attachments"][attachment_name]
88
87
  end
89
88
 
89
+ private
90
90
  def mini_magick
91
91
  if exists?
92
92
  @mini_magick ||= MiniMagick::Image.read(self.data)
93
93
  end
94
94
  end
95
-
96
95
  end
97
96
  end
98
97
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_photo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196371
4
+ hash: 62196369
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 8
12
- version: 1.0.0.beta.8
11
+ - 9
12
+ version: 1.0.0.beta.9
13
13
  platform: ruby
14
14
  authors:
15
15
  - Matt Parker