attached 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Attached
2
2
 
3
- Attached is a Ruby on Rails file attachment tool that lets users upload to the cloud, then process in the cloud. The tool supports Amazon S3 by default. It surpasses Paperclip by providing built-in support for direct uploads to the cloud and by allowing integration with cloud based processing tools. However, in almost every other way Paperclip is better. The source code is inspired (and copied) from Paperclip. If you aren't working in the cloud exclusively then this isn't for you!
3
+ Attached is a Ruby on Rails file attachment tool that lets users upload to the cloud, then process in the cloud. The gem supports AWS, Google and Rackspace for storage networks by default. It is influenced (and copied) from Paperclip.
4
4
 
5
5
  == Requirements
6
6
 
@@ -58,22 +58,47 @@ View:
58
58
 
59
59
  == Advanced
60
60
 
61
- === Storage
61
+ === Validations
62
+
63
+ # app/models/person.rb
64
+ validates_attached_presence :avatar
65
+ validates_attached_size :avatar, :in => 2.kilobytes..2.megabytes
66
+
67
+ ==== Storage
62
68
 
63
- has_attached :avatar, :provider => :aws, :credentials => {
64
- :secret_access_key => "*****",
65
- :access_key_id => "*****",
66
- }
69
+ # app/models/person.rb
70
+ has_attached :avatar, :medium => :aws, :credentials => "#{Rails.root}/config/aws.yml"
71
+
72
+ # app/models/person.rb
73
+ has_attached :avatar, :medium => :google, "#{Rails.root}/config/google.yml"
74
+
75
+ # app/models/person.rb
76
+ has_attached :avatar, :medium => :rackspace, "#{Rails.root}/config/rackspace.yml"
77
+
78
+ # config/initializers/attached.rb
79
+ Attached::Attachment.options[:medium] = :aws
80
+ Attached::Attachment.options[:credentials] = "#{Rails.root}/config/aws.yml"
81
+
82
+ # config/initializers/attached.rb
83
+ Attached::Attachment.options[:medium] = :google
84
+ Attached::Attachment.options[:credentials] = "#{Rails.root}/config/google.yml"
85
+
86
+ # config/initializers/attached.rb
87
+ Attached::Attachment.options[:medium] = :rackspace
88
+ Attached::Attachment.options[:credentials] = "#{Rails.root}/config/rackspace.yml"
67
89
 
68
90
  === Processor
69
91
 
92
+ # app/models/person.rb
70
93
  has_attached :avatar, :processor => :image, :styles => {
71
- :small => { :size => "200x200#" }
72
- :large => { :size => "400x400#" }
94
+ :small => { :size => '200x200<', :extension => 'png' },
95
+ :large => { :size => '400x400>', :extension => 'png' },
96
+ :default => { :size => '300x300#' },
73
97
  }
74
98
 
75
- === Alias
99
+ === Aliases
76
100
 
101
+ # app/initializer/attached.rb
77
102
  Attached::Attachment.options[:aliases] = %w(
78
103
  d1kf5um3mxa8kv.cloudfront.net
79
104
  d3d5wf186mp1rv.cloudfront.net
data/lib/attached.rb CHANGED
@@ -31,17 +31,15 @@ module Attached
31
31
  #
32
32
  # Options:
33
33
  #
34
- # * :styles -
35
- # * :storage -
36
- # * :processor -
34
+ # * :styles - a hash containing style names followed by parameters passed to processor
35
+ # * :storage - a symbol for a predefined storage or a custom storage class
36
+ # * :processor - a symbol for a predefined processor or a custom processor class
37
37
  #
38
38
  # Usage:
39
39
  #
40
40
  # has_attached :video
41
41
  # has_attached :video, :storage => :s3
42
- # has_attached :video, styles => [ :mp4, :ogv ]
43
- # has_attached :video, styles => { :main => { :size => "480p", :format => "mp4" } }
44
- # has_attached :thumbnail, :range => (1..4)
42
+ # has_attached :video, styles => { :mov => { :size => "480p", :format => "mov" } }
45
43
 
46
44
  def has_attached(name, options = {})
47
45
 
@@ -10,11 +10,11 @@ module Attached
10
10
  #
11
11
  # Usage:
12
12
  #
13
- # Attached::Storage.storage(:aws)
14
- # Attached::Storage.storage(:google)
15
- # Attached::Storage.storage(:rackspace)
13
+ # Attached::Storage.storage(:aws, "#{Rails.root}/config/aws.yml" )
14
+ # Attached::Storage.storage(:google, "#{Rails.root}/config/google.yml" )
15
+ # Attached::Storage.storage(:rackspace, "#{Rails.root}/config/rackspace.yml")
16
16
 
17
- def self.storage(medium = :aws, credentials = nil)
17
+ def self.storage(medium, credentials)
18
18
 
19
19
  case medium
20
20
  when :aws then return Attached::Storage::AWS.new credentials
@@ -48,7 +48,7 @@ module Attached
48
48
  end
49
49
 
50
50
 
51
- # Save a file to a given path on AWS S3.
51
+ # Save a file to a given path.
52
52
  #
53
53
  # Parameters:
54
54
  #
@@ -65,7 +65,7 @@ module Attached
65
65
  end
66
66
 
67
67
 
68
- # Destroy a file at a given path on AWS S3.
68
+ # Destroy a file at a given path.
69
69
  #
70
70
  # Parameters:
71
71
  #
@@ -37,7 +37,7 @@ module Attached
37
37
  end
38
38
 
39
39
 
40
- # Access the host (e.g. bucket.s3.amazonaws.com) for a storage service.
40
+ # Access the host (e.g. https://attached.commondatastorage.googleapis.com/) for a storage service.
41
41
  #
42
42
  # Usage:
43
43
  #
@@ -48,7 +48,7 @@ module Attached
48
48
  end
49
49
 
50
50
 
51
- # Save a file to a given path on AWS S3.
51
+ # Save a file to a given path.
52
52
  #
53
53
  # Parameters:
54
54
  #
@@ -65,7 +65,7 @@ module Attached
65
65
  end
66
66
 
67
67
 
68
- # Destroy a file at a given path on AWS S3.
68
+ # Destroy a file at a given path.
69
69
  #
70
70
  # Parameters:
71
71
  #
@@ -43,7 +43,7 @@ module Attached
43
43
  # storage.host
44
44
 
45
45
  def host()
46
- "https://#{self.bucket}.s3.amazonaws.com/"
46
+ "https://storage.clouddrive.com/#{self.container}/"
47
47
  end
48
48
 
49
49
 
@@ -1,3 +1,3 @@
1
1
  module Attached
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kevin Sylvestre
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-20 00:00:00 -04:00
17
+ date: 2011-01-22 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency