imagery 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/imagery.gemspec +2 -2
- data/lib/imagery.rb +1 -1
- data/lib/imagery/faking.rb +55 -8
- data/lib/imagery/missing.rb +18 -7
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/imagery.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{imagery}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cyril David"]
|
12
|
-
s.date = %q{2010-06
|
12
|
+
s.date = %q{2010-07-06}
|
13
13
|
s.description = %q{Uses ImageMagick directly underneath. Nuff said.}
|
14
14
|
s.email = %q{cyx.ucron@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/imagery.rb
CHANGED
data/lib/imagery/faking.rb
CHANGED
@@ -3,16 +3,41 @@ module Imagery
|
|
3
3
|
def self.included(base)
|
4
4
|
base.extend ClassMethods
|
5
5
|
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def mode=(mode)
|
9
|
-
@mode = mode
|
10
|
-
end
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
module ClassMethods
|
8
|
+
# Allows you to define the current mode. The only special value here is
|
9
|
+
# `:fake`. If the mode is :fake, then Imagery::Model#save and
|
10
|
+
# Imagery::Model#delete will not actually run.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
#
|
14
|
+
# Photo = Class.new(Struct.new(:id))
|
15
|
+
#
|
16
|
+
# i = Imagery.new(Photo.new(1001))
|
17
|
+
# i.root = '/tmp'
|
18
|
+
#
|
19
|
+
# Imagery::Model.faked {
|
20
|
+
# assert i.save(File.open('/path/to/image.png'))
|
21
|
+
# }
|
22
|
+
#
|
23
|
+
# @see Imagery::Test
|
24
|
+
#
|
25
|
+
attr_accessor :mode
|
15
26
|
|
27
|
+
# Switches the current mode to :fake.
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# Imagery::Model.mode == nil
|
31
|
+
# # => true
|
32
|
+
#
|
33
|
+
# Imagery::Model.faked {
|
34
|
+
# Imagery::Model.mode == :fake
|
35
|
+
# # => true
|
36
|
+
# }
|
37
|
+
#
|
38
|
+
# Imagery::Model.mode = nil
|
39
|
+
# # => true
|
40
|
+
#
|
16
41
|
def faked
|
17
42
|
@omode, @mode = @mode, :fake
|
18
43
|
yield
|
@@ -20,6 +45,24 @@ module Imagery
|
|
20
45
|
@mode = @omode
|
21
46
|
end
|
22
47
|
|
48
|
+
# Switches the current mode to nil. Useful for forcing real saves
|
49
|
+
# in your test.
|
50
|
+
#
|
51
|
+
# You should do this at least once in your project just to know
|
52
|
+
# that all your Imagery::Model#save and Imagery::Model#delete
|
53
|
+
# operations actually work.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# Imagery::Model.mode = :fake
|
57
|
+
#
|
58
|
+
# Imagery::Model.faked {
|
59
|
+
# Imagery::Model.mode == nil
|
60
|
+
# # => true
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# Imagery::Model.mode = :fake
|
64
|
+
# # => true
|
65
|
+
#
|
23
66
|
def real
|
24
67
|
@omode, @mode = @mode, nil
|
25
68
|
yield
|
@@ -28,12 +71,16 @@ module Imagery
|
|
28
71
|
end
|
29
72
|
end
|
30
73
|
|
74
|
+
# Implement the stubbed version of save and skips actual operation
|
75
|
+
# if Imagery::Model.mode == :fake
|
31
76
|
def save(io)
|
32
77
|
return true if self.class.mode == :fake
|
33
78
|
|
34
79
|
super
|
35
80
|
end
|
36
81
|
|
82
|
+
# Implement the stubbed version of save and skips actual operation
|
83
|
+
# if Imagery::Model.mode == :fake
|
37
84
|
def delete
|
38
85
|
return true if self.class.mode == :fake
|
39
86
|
|
data/lib/imagery/missing.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
module Imagery
|
2
2
|
module Missing
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
# Allows you to set the current filename of your photo.
|
4
|
+
# Much of Imagery::Missing is hinged on this.
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
#
|
8
|
+
# Photo = Class.new(Struct.new(:id))
|
9
|
+
# i = Imagery::Model.new(Photo.new(1001))
|
10
|
+
# i.extend Imagery::Missing
|
11
|
+
# i.url == "/photo/1001/original.png"
|
12
|
+
# # => true
|
13
|
+
#
|
14
|
+
# i.existing = "Filename"
|
15
|
+
# i.url == "/missing/photo/original.png"
|
16
|
+
# # => true
|
17
|
+
#
|
18
|
+
# @see Imagery::Missing#url
|
19
|
+
#
|
20
|
+
attr_accessor :existing
|
10
21
|
|
11
22
|
def url(size = self.default_size)
|
12
23
|
if existing.to_s.empty?
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Cyril David
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06
|
17
|
+
date: 2010-07-06 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|