photofy 0.1.3 → 0.1.4
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/lib/photofy.rb +12 -3
- metadata +3 -2
data/lib/photofy.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Photofy
|
|
|
26
26
|
#will give a 'stamp' attribute which on save of main photo filed will scale it to 25 x 25 dimesnions
|
|
27
27
|
#after_photofy :portfolio, Proc.new{|img| img.scale(150, 250)}
|
|
28
28
|
#will give a 'portfolio' attribute which on save of main photo filed will scale it to 150 x 250 dimesnions
|
|
29
|
+
#and also provide 're_photofy_portfolio!'(Proc.new{|img| img.scale(10, 20)}) to perform operation on other user defined events
|
|
29
30
|
def after_photofy(photo_field, p = Proc.new { |img| puts "Rmagick image: #{img.inspect}" })
|
|
30
31
|
define_method "#{photo_field}" do
|
|
31
32
|
File.exist?(send("#{photo_field}_path")) ? File.read(send("#{photo_field}_path")) : nil
|
|
@@ -36,12 +37,20 @@ module Photofy
|
|
|
36
37
|
File.join(directoy_path, "#{photo_field}_#{self.send(self.class.primary_key)}.jpg")
|
|
37
38
|
end
|
|
38
39
|
|
|
39
|
-
define_method "
|
|
40
|
+
define_method "re_photofy_#{photo_field}!" do |proc|
|
|
41
|
+
send("process_n_save_#{photo_field}", proc)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
define_method "process_and_save_#{photo_field}!" do
|
|
45
|
+
send("process_n_save_#{photo_field}", p)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
define_method "process_n_save_#{photo_field}" do |proc|
|
|
40
49
|
begin
|
|
41
50
|
mphoto_f = self.class.photo_field
|
|
42
51
|
if File.exist?(send("#{mphoto_f}_path"))
|
|
43
52
|
img = Magick::Image.read(send("#{mphoto_f}_path")).first # path of Orignal image that has to be worked upon
|
|
44
|
-
img =
|
|
53
|
+
img = proc.call(img)
|
|
45
54
|
img.write(send("#{photo_field}_path"))
|
|
46
55
|
end
|
|
47
56
|
rescue Exception => e
|
|
@@ -54,7 +63,7 @@ module Photofy
|
|
|
54
63
|
File.delete(send("#{photo_field}_path")) if File.exist?(send("#{photo_field}_path"))
|
|
55
64
|
end
|
|
56
65
|
|
|
57
|
-
send(:after_save, "
|
|
66
|
+
send(:after_save, "process_and_save_#{photo_field}!")
|
|
58
67
|
send(:after_destroy, "destroy_#{photo_field}")
|
|
59
68
|
end
|
|
60
69
|
|
metadata
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: photofy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Praveen Kumar Sinha
|
|
9
|
+
- Annu Yadav
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
+
date: 2013-05-10 00:00:00.000000000Z
|
|
13
14
|
dependencies: []
|
|
14
15
|
description: ! "A gem to provide simple method to do file upload of pictures and provides
|
|
15
16
|
getter setter methods of it and save on model object commit.\n #Generates photo
|