photofy 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/photofy.rb +9 -0
  2. metadata +3 -3
data/lib/photofy.rb CHANGED
@@ -32,6 +32,10 @@ module Photofy
32
32
  File.exist?(send("#{photo_field}_path")) ? File.read(send("#{photo_field}_path")) : nil
33
33
  end
34
34
 
35
+ define_method "#{photo_field}?" do
36
+ send("#{photo_field}").nil? ? false : true
37
+ end
38
+
35
39
  define_method "#{photo_field}_path" do
36
40
  directoy_path = FileUtils.mkdir_p File.join(self.class.photo_repository, self.class.photo_field.to_s)
37
41
  File.join(directoy_path, "#{photo_field}_#{self.send(self.class.primary_key)}.jpg")
@@ -80,6 +84,7 @@ module Photofy
80
84
  #Generates photo filed from photo_field arguments and provides methods like
81
85
  #if photo_filed is "collage" then it provides methods on top of it as
82
86
  #collage >> Getter,
87
+ #collage? >> Returns true if collage is having value other than nil else false,
83
88
  #collage = >> Setter. Accepted inputs are file upload(ActionDispatch::Http::UploadedFile), filer handle and String(format validation is ignored),
84
89
  #collage_path >> Getter of filepath,
85
90
  #collage_persisted? >> true if provided file/data is stored on disk,
@@ -100,6 +105,10 @@ module Photofy
100
105
  @file_buffer.nil? ? (send("#{self.class.photo_field}_persisted?") ? File.read(send("#{self.class.photo_field}_path")) : nil) : @file_buffer
101
106
  end
102
107
 
108
+ define_method "#{@photo_field}?" do
109
+ send("#{self.class.photo_field}").nil? ? false : true
110
+ end
111
+
103
112
  define_method "#{@photo_field}=" do |file_upload|
104
113
  if file_upload.class == ActionDispatch::Http::UploadedFile
105
114
  return false unless self.class.photo_formats.include?(File.extname(file_upload.original_filename).downcase)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-10 00:00:00.000000000Z
13
+ date: 2013-05-18 00:00:00.000000000Z
14
14
  dependencies: []
15
15
  description: ! "A gem to provide simple method to do file upload of pictures and provides
16
16
  getter setter methods of it and save on model object commit.\n #Generates photo
@@ -27,7 +27,7 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
  files:
29
29
  - lib/photofy.rb
30
- homepage: https://github.com/praveenkumarsinha/Photofy
30
+ homepage: http://praveenkumarsinha.github.io/Photofy
31
31
  licenses: []
32
32
  post_install_message:
33
33
  rdoc_options: []