attached 0.3.7 → 0.3.8
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/README.rdoc +18 -18
- data/lib/attached/attachment.rb +4 -1
- data/lib/attached/version.rb +1 -1
- metadata +2 -2
    
        data/README.rdoc
    CHANGED
    
    | @@ -40,10 +40,10 @@ Model: | |
| 40 40 |  | 
| 41 41 | 
             
              class Video < ActiveRecord::Base
         | 
| 42 42 |  | 
| 43 | 
            -
                has_attached :encoding, : | 
| 44 | 
            -
                  : | 
| 45 | 
            -
                  : | 
| 46 | 
            -
                  : | 
| 43 | 
            +
                has_attached :encoding, styles: { 
         | 
| 44 | 
            +
                  webm: { extension: '.webm' },
         | 
| 45 | 
            +
                  mp4:  { extension: '.mp4'  },
         | 
| 46 | 
            +
                  ogv:  { extension: '.ogv'  },
         | 
| 47 47 | 
             
                }
         | 
| 48 48 |  | 
| 49 49 | 
             
                after_save do
         | 
| @@ -54,7 +54,7 @@ Model: | |
| 54 54 |  | 
| 55 55 | 
             
            Form:
         | 
| 56 56 |  | 
| 57 | 
            -
              <%= form_for @video, : | 
| 57 | 
            +
              <%= form_for @video, html: { multipart: true } do |form| %>
         | 
| 58 58 | 
             
                <%= form.file_field :encoding %>
         | 
| 59 59 | 
             
              <% end %>
         | 
| 60 60 |  | 
| @@ -72,19 +72,19 @@ View: | |
| 72 72 |  | 
| 73 73 | 
             
              # app/models/person.rb
         | 
| 74 74 | 
             
              validates_attached_presence :file
         | 
| 75 | 
            -
              validates_attached_size :file, : | 
| 76 | 
            -
              validates_attached_extension :file, : | 
| 75 | 
            +
              validates_attached_size :file, in: 2.kilobytes..2.megabytes
         | 
| 76 | 
            +
              validates_attached_extension :file, in: %w(jpe jpg jpeg png)
         | 
| 77 77 |  | 
| 78 78 | 
             
            ==== Storage
         | 
| 79 79 |  | 
| 80 80 | 
             
              # app/models/user.rb
         | 
| 81 | 
            -
              has_attached :file, : | 
| 81 | 
            +
              has_attached :file, medium: :aws, credentials: "#{Rails.root}/config/aws.yml"
         | 
| 82 82 |  | 
| 83 83 | 
             
              # app/models/user.rb
         | 
| 84 | 
            -
              has_attached :file, : | 
| 84 | 
            +
              has_attached :file, medium: :google, credentials: "#{Rails.root}/config/google.yml"
         | 
| 85 85 |  | 
| 86 86 | 
             
              # app/models/user.rb
         | 
| 87 | 
            -
              has_attached :file, : | 
| 87 | 
            +
              has_attached :file, medium: :rackspace, credentials: "#{Rails.root}/config/rackspace.yml"
         | 
| 88 88 |  | 
| 89 89 | 
             
              # config/initializers/attached.rb
         | 
| 90 90 | 
             
              Attached::Attachment.options[:medium] = :aws
         | 
| @@ -101,17 +101,17 @@ View: | |
| 101 101 | 
             
            === Processor
         | 
| 102 102 |  | 
| 103 103 | 
             
              # app/models/image.rb
         | 
| 104 | 
            -
              has_attached :file, : | 
| 105 | 
            -
                : | 
| 106 | 
            -
                : | 
| 107 | 
            -
                : | 
| 104 | 
            +
              has_attached :file, processor: :image, styles: {
         | 
| 105 | 
            +
                small:   { size: '200x200<', extension: '.jpg', quality: 90 },
         | 
| 106 | 
            +
                large:   { size: '400x400>', extension: '.jpg', quality: 90 },
         | 
| 107 | 
            +
                default: { size: '300x300#', extension: '.jpg', quality: 90 },
         | 
| 108 108 | 
             
              }
         | 
| 109 109 |  | 
| 110 110 | 
             
              # app/models/audio.rb
         | 
| 111 | 
            -
              has_attached :file, : | 
| 112 | 
            -
                : | 
| 113 | 
            -
                : | 
| 114 | 
            -
                : | 
| 111 | 
            +
              has_attached :file, processor: :audio, styles: {
         | 
| 112 | 
            +
                full:  { preset: '320kbps', extension: '.wav' },
         | 
| 113 | 
            +
                large: { preset: '256kbps', extension: '.wav' },
         | 
| 114 | 
            +
                small: { preset: '128kbps', extension: '.wav' },
         | 
| 115 115 | 
             
              }
         | 
| 116 116 |  | 
| 117 117 | 
             
            === Reprocessing
         | 
    
        data/lib/attached/attachment.rb
    CHANGED
    
    | @@ -20,6 +20,7 @@ module Attached | |
| 20 20 | 
             
                attr_reader :purge
         | 
| 21 21 | 
             
                attr_reader :errors
         | 
| 22 22 | 
             
                attr_reader :path
         | 
| 23 | 
            +
                attr_reader :missing
         | 
| 23 24 | 
             
                attr_reader :styles
         | 
| 24 25 | 
             
                attr_reader :default
         | 
| 25 26 | 
             
                attr_reader :medium
         | 
| @@ -41,6 +42,7 @@ module Attached | |
| 41 42 | 
             
                def self.options
         | 
| 42 43 | 
             
                  @options ||= {
         | 
| 43 44 | 
             
                    :path        => ":name/:style/:identifier:extension",
         | 
| 45 | 
            +
                    :missing     => ":name/:style/missing:extension",
         | 
| 44 46 | 
             
                    :default     => :original,
         | 
| 45 47 | 
             
                    :medium      => :local,
         | 
| 46 48 | 
             
                    :credentials => {},
         | 
| @@ -80,6 +82,7 @@ module Attached | |
| 80 82 | 
             
                  @errors      = []
         | 
| 81 83 |  | 
| 82 84 | 
             
                  @path        = options[:path]
         | 
| 85 | 
            +
                  @missing     = options[:missing]
         | 
| 83 86 | 
             
                  @styles      = options[:styles]
         | 
| 84 87 | 
             
                  @default     = options[:default]
         | 
| 85 88 | 
             
                  @medium      = options[:medium]
         | 
| @@ -221,7 +224,7 @@ module Attached | |
| 221 224 | 
             
                #   @object.avatar.url(:large)
         | 
| 222 225 |  | 
| 223 226 | 
             
                def path(style = self.default)
         | 
| 224 | 
            -
                  path = @path.clone
         | 
| 227 | 
            +
                  path = self.attached? ? @path.clone : @missing.clone
         | 
| 225 228 |  | 
| 226 229 | 
             
                  path.gsub!(/:name/, name.to_s)
         | 
| 227 230 | 
             
                  path.gsub!(/:style/, style.to_s)
         | 
    
        data/lib/attached/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            name: attached
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0.3. | 
| 5 | 
            +
              version: 0.3.8
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors: 
         | 
| 8 8 | 
             
            - Kevin Sylvestre
         | 
| @@ -10,7 +10,7 @@ autorequire: | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2011-05- | 
| 13 | 
            +
            date: 2011-05-31 00:00:00 -04:00
         | 
| 14 14 | 
             
            default_executable: 
         | 
| 15 15 | 
             
            dependencies: 
         | 
| 16 16 | 
             
            - !ruby/object:Gem::Dependency 
         |