pax_global_header 0000666 0000000 0000000 00000000064 12303471703 0014512 g ustar 00root root 0000000 0000000 52 comment=3a0978a390de9d96d05e5befc40b2fabc27644cc carrierwave-0.10.0/ 0000775 0000000 0000000 00000000000 12303471703 0014102 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/.gitignore 0000664 0000000 0000000 00000000300 12303471703 0016063 0 ustar 00root root 0000000 0000000 doc .yardoc .DS_Store spec/public pkg doc more/activerecord/spec/db more/activerecord/spec/public more/datamapper/spec/public *.project spec/test.log spec/tmp *.swp .rvmrc .bundle Gemfile.lock carrierwave-0.10.0/.travis.yml 0000664 0000000 0000000 00000001141 12303471703 0016210 0 ustar 00root root 0000000 0000000 before_install: - gem install bundler notifications: email: false rvm: - 1.9.3 - 2.0.0 - 2.1.1 - ruby-head gemfile: - Gemfile - gemfiles/rails-3-2-stable.gemfile - gemfiles/rails-4-0-stable.gemfile - gemfiles/rails-4-1-stable.gemfile - gemfiles/rails-master.gemfile matrix: allow_failures: - rvm: ruby-head include: - rvm: 1.8.7 gemfile: gemfiles/rails-3-2-stable.gemfile - rvm: 1.9.2 gemfile: gemfiles/rails-3-2-stable.gemfile - rvm: ree gemfile: gemfiles/rails-3-2-stable.gemfile before_script: - "mysql -e 'create database carrierwave_test;'" carrierwave-0.10.0/CONTRIBUTING.md 0000664 0000000 0000000 00000002171 12303471703 0016334 0 ustar 00root root 0000000 0000000 # Contributing to CarrierWave CarrierWave thrives on a large number of [contributors](https://github.com/carrierwaveuploader/carrierwave/contributors), and pull requests are very welcome. Before submitting a pull request, please make sure that your changes are well tested. First, make sure you have `imagemagick` and `ghostscript` installed. Then, you'll need to install bundler and the gem dependencies: `gem install bundler && bundle install` You should now be able to run the local tests: `bundle exec rake` You can also run the remote specs by creating a ~/.fog file: ```yaml :carrierwave: :aws_access_key_id: xxx :aws_secret_access_key: yyy :rackspace_username: xxx :rackspace_api_key: yyy :google_storage_access_key_id: xxx :google_storage_secret_access_key: yyy ``` You should now be able to run the remote tests: REMOTE=true bundle exec rake Please test with the latest Ruby 1.8.x and 1.9.x versions using RVM if possible. ## Running active record tests Make sure you have a local MySQL database named `carrierwave_test` with the username `root` and empty password. carrierwave-0.10.0/Gemfile 0000664 0000000 0000000 00000000047 12303471703 0015376 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gemspec carrierwave-0.10.0/History.txt 0000664 0000000 0000000 00000045447 12303471703 0016322 0 ustar 00root root 0000000 0000000 === Version 0.9.0 2013-07-06 * [BREAKING CHANGE] Use integer time (UTC) to generate cache IDs [@bensie] * [changed] Recommend using ActionController::Base.helpers instead of Sprockets::Rails::Helper for asset pipeline [@c0] * [changed] Lots of URL encoding fixes [@taavo] * [added] Added #version_exists? method [@tmaier] * [added] Added configuration param (:fog_use_ssl_for_aws) to disable SSL for public_url [@pbzymek] * [added] Add Dutch i18n translations for errors [@vanderhoorn] * [added] Add Czech i18n translations for errors [@elmariofredo] * [added] Add German i18n translations for errors [@felixbuenemann] * [fixed] Gemspec error in Ruby 2.0.0 [@sanemat] * [fixed] Fixed bug in serializing to xml or json where both :only and :except are passed [@Knack] * [fixed] Fix recreate_versions! when version if proc returns false [@arthurnn] === Version 0.8.0 2013-01-08 * [BREAKING CHANGE] Remove 'fog_endpoint' in favor of 'host' and/or 'endpoint' in fog_credentials [bensie] * [changed] Remove autoload in favor of standard 'require' to help with thread safety [bensie] * [added] Allow recreating only specified versions instead of all versions [div] * [added] Add support for S3-compliant storage APIs that are not actually S3 [neuhausler] * [added] Add #extension CarrierWave::Storage::Fog::File for fetching a file extension [sweatypitts] * [fixed] Marshaling uploader objects no longer raises a TypeError on anonymous classes [bensie] === Version 0.7.1 2012-11-08 * [added] add a override to allow fog configuration per uploader [dei79] * [fixed] Fix a regression when removing uploads [mattolson] === Version 0.7.0 2012-10-19 * [BREAKING CHANGE] Rename 'fog_host' config option to 'asset_host' and add support for file storage [DouweM] * [changed] Changed after_destroy with after_commit ... :on => :destroy [Cristian Sorinel] * [changed] Do not handle any special cases for URL handling, keep the existing escape/unescape functionality and allow overriding [bensie] * [changed] Activerecord-deprecated_finders gem was renamed [bensie] * [changed] Removed unnecessary present? method from ActiveSupport [Yauheni Kryudziuk] * [changed] Use AWS S3 subdomain URL when directory name contains a period. [DouweM] * [added] Added resize_to_geometry_string RMagick method that will scale image [wprater] * [added] Made feature to blacklist certain extensions [thiagofm] * [added] Parse and pass fog_host option to ::Fog::Storage [Yauheni Kryudziuk] * [added] Add serialization spec for multiple uploaders. [malclocke] * [added] Add :read option to manipulate! [xtreme-tanzeeb-khalili] * [added] Add binary/octet-stream as generic mime type. [phiggins] * [added] Add 'fog_endpoint' config option to set an alternate Fog host. [DouweM] * [fixed] Fixed can't convert File into String [jnimety] * [fixed] Fixed an issue when parsing URL w/o schema. [Yauheni Kryudziuk] * [fixed] Fix reference to column in serializable_hash [malclocke] * [fixed] Fix inconsistence in file API [oelmekki] === Version 0.6.2 2012-04-12 * [fixed] Don't double-generate cache_id [skyeagle] * [added] Escape plus signs (+) in remote URLs [adrianpike] * [added] Enhance multi-page PDF support in RMagick [xtreme-tanzeeb-khalili] === Version 0.6.1 2012-04-02 * [fixed] Calling #serializable_hash with no options [matthewrudy] === Version 0.6.0 2012-03-27 * [BREAKING CHANGE] Require Rails 3.2 or Rails master (4.0) - depends on activesupport/activemodel [bensie] * [BREAKING CHANGE] Remove :S3 storage option in favor of Fog [bensie] * [BREAKING CHANGE] Remove :CloudFiles storage option in favor of Fog [bensie] * [changed] JSON / XML serialization hashes are consistent and work as expected with ActiveRecord's serializable_hash [bensie] * [added] fog_host now accepts a proc (useful for dynamic asset servers) [jtrim] * [added] Add ability to process a version from an existing version so you aren't always crunching the original, large file [ferblape] * [added] Allow brackets in remote URLs [ngauthier] * [added] CarrierWave::Storage::Fog::File#exists? to check the existence of the file without needing to fetch it [bensie] * [added] Gravity option on resize_to_fill (minimagick) [TheOddLinguist] * [added] Add query options for s3 to support response headers overwriting [meceo] * [added] Make storages File#url methods to work without any params [meceo] * [added] Set the CarrierWave.root correctly if Padrino is defined [futurechimp] * [added] Cache fog connections for improved performance [labocho] * [fixed] Fix slow fetching of content-length on remote file [geemus] * [fixed] Fog remote specs now passing and depend on Fog >= 1.3.1 [geemus] * [fixed] Fix an issue where multi-page PDFs can't be converted with RMagick [chanind] * [fixed] MiniMagick expects string args to mogrify commands [bensie] * [fixed] With Active Record ORM, setting remote_url marks mounted column as dirty [trevorturk] * [fixed] Fix possible race condition with CarrierWave.root [bensie] * [fixed] ActiveSupport::Memoizable deprecation warning [slbug] === Version 0.5.8 2011-11-10 * [added] Allow custom error messages [bartt] * [added] Add config.base_path to use as a prefix for uploader URLs [die-antwort] * [added] Support fog streaming uploads [chrisdurtschi] * [added] Support `move_to` in addition to the default `copy_to` when using the cache [jasonydes] * [fixed] Support for Sinatra 1.3 (with backward compatibility) [bensie] * [fixed] Fog get_object_url deprecated, use get_object_https_url or get_object_http_url [scottmessinger] === Version 0.5.7 2011-08-12 * [BREAKING CHANGE] Extracted Mongoid support into a separate gem (carrierwave-mongoid) [jnicklas] * [BREAKING CHANGE] Remove ImageScience support due to lack maintenance and 1.9.2 compatibility [jnicklas] * [BREAKING CHANGE] Combine delete_tmp_file_after_storage and delete_cache_id_after_storage options [bensie] * [changed] Cached and then remote-uploaded file will no longer have a content_type, please use CarrierWave::MimeTypes processor instead [trevorturk] * [changed] Allow writing over a previously assigned file when retrieving a remote file [Florent2] * [fixed] Fixed exception when nested or double-embedded Mongoid documents are saved [potatosalad] * [fixed] Fixed that store! can call process! twice [gzigzigzeo] * [fixed] Performance enhancements by reducing use of rescue [jamescook] === Version 0.5.6 2011-07-12 * [fixed] Remove cache file and directories after storing [scottwb] * [fixed] Add missing active_support/deprecation require [trevorturk] * [fixed] Remove redundant requires of sequel and datamapper [solnic] * [fixed] Running tests with REMOTE=true [geemus] === Version 0.5.5 2011-07-09 * [BREAKING CHANGE] Extracted DataMapper support into a separate gem (carrierwave-datamapper) [jnicklas] * [BREAKING CHANGE] Extracted Sequel support into a separate gem (carrierwave-sequel) [jnicklas] * [changed] Don't downcase filenames by default [bensie] * [changed] Orm mount modules default uploader to nil [jnicklas] * [changed] Remove alias_method :blank? from SanitizedFile to for performance re: issue #298 [trevorturk] * [added] Conditional processing of versions [gucki] * [added] Remove Remove previously stored files after Active Record mounted uploader update re: issue #75 [trevorturk] * [added] Remove Remove previously stored files after Mongoid mounted uploader update re: issue #75 [did] * [added] Added _identifier to retrieve identifier/filename [jnicklas] * [added] clean_cached_files! clears all files older than 24 hours by default, but time frame can now be customized [cover] * [added] Versions now implement an enable_processing method which uses the parent when no value is set [mariovisic] * [added] Delete cache_id garbage dirs, closes GH issue #338 [clyfe] * [added] Added CarrierWave::MimeTypes processor for more advanced content-type guessing [JangoSteve] * [fixed] Active Record's will_change! method works when mount_on option is used [indrekj] * [fixed] Fixed problem with accepting URL uploads when the URL was already escaped [cover] * [fixed] Fixed ability to override sanitize_regexp [trevorturk] * [fixed] Fix that cached and then remote-uploaded file should have content_type [trevorturk] * [fixed] Fix validates_size/length_of in Rails 3.0.6 and above, closes #342 [bensie] * [fixed] Various Active Support compatibility updates [slbug, bensie, et al] === Version 0.5.4 2011-05-18 * [changed] Fog: Performance enhancements for AWS and Google [geemus] * [changed] Fog: Try to use subdomain public url on s3 [geemus] * [changed] Memoize CarrierWave::Mounter#option for increased performance [ingemar] * [changed] Relax development gem dependency versions where possible and fix tests [trevorturk] * [changed] Upgrade to RSpec 2 [jnicklas] === Version 0.5.3 2011-03-22 * [changed] Cloud Files storage so delete and url return nil if object not found instead of exception [minter] * [added] New fog storage provider that supports Amazon S3, Rackspace Cloud Files, and Google Storare for Developers [geemus] * [added] cloud_files_auth_url and cloud_files_snet config options for Cloud Files [minter] * [added] process_uri method that can be overridden in your uploader to support downloads from non-standard urls [trevorturk] * [added] version urls to json output [karb] * [added] Active Record marks uploader column as changed when changed [josevalim] * [fixed] Cloud Files storage tests to use the new url format [minter] * [fixed] Moved raising of FormNotMultipart farther down to avoid errors with nested attribute forms [trevorturk] * [fixed] original_filename of remote uploads should be calculated from final (possibly redirected) URL [brady8] * [fixed] Fix calling :process! on files stored in remote solutions [alexcrichton] * [fixed] Fix paperclip compatibility mappings [valakirka] * [fixed] Ensure temporary files can be deleted on Windows [Eleo] === Version 0.5.2 2011-02-18 * [changed] Require active_support/core_ext/string/multibyte to fix downcasing unicode filenames during sanitizing [nashbridges] * [changed] Use fog ~> 0.4, Fog::AWS::Storage.new -> Fog::Storage.new(:provider => 'AWS') [trevorturk] * [changed] Use class_attribute (inheritable attributes are deprecated) [stephencelis] * [changed] extension_white_list no longer supports a single string, only an array of strings and/or Regexps [trevorturk] * [changed] Rackspace Cloud Files: only create container if container does not exist [edmundsalvacion] * [changed] GridFS: the path returned is no longer always nil, it is now the path in GridFS [alexcrichton] * [added] Ability to specify a Regexp in the extension_white_list [lwe] * [added] CarrierWave::SanitizedFile#sanitize_regexp public method to allow customizing [trevorturk] * [added] sanitize_regexp documentation to the README [nashbridges] * [added] Ability to use https for Amazon S3 URLs if config.s3_use_ssl is true [recruitmilitary] * [added] The s3_region configuration documentation to the README [mrsimo] * [fixed] Reprocessing remotely stored files [alexcrichton] * [fixed] Nested versioning processing [alexcrichton] * [fixed] An intermittent bug with ImageScience resize_to_fill method [LupineDev] * [fixed] DataMapper#save should remove the avatar if remove_avatar? returns true [wprater] === Version 0.5.1 2010-12-01 * [changed] s3_access renamed to s3_access_policy [Jonas Nicklas] * [changed] Depend on activesupport ~> 3.0 for Rails 3.1 compatibility [Trevor Turk] * [changed] Use fog >= 0.3.0, fix deprecation warnings [Paul Elliott] * [changed] Use mini_magick ~> 2.3, MiniMagick::Image.from_file becomes MiniMagick::Image.open [Fredrik Björk] * [changed] Convert generic MiniMagick::Invalid into ProcessingError [Alex Crichton] * [changed] Remove cached tmp file after storing for file store [Damien Mathieu] * [added] s3_region config option to set AWS S3 region [Roger Campos] * [added] Option to retain cached tmp file after storage (delete_tmp_file_after_storage) [Damien Mathieu] * [added] Transparent support for authenticated_read on S3 [Jonas Nicklas] * [fixed] Clean up internal require statements [Josh Kalderimis] * [fixed] Header support for S3 [Alex Crichton] * [fixed] Stack level too deep errors when using to_json [Trevor Turk] * [fixed] Documentation for mount_uploader [Nathan Kleyn] === Version 0.5 2010-09-23 * [changed] Use ActiveModel instead of ActiveRecord validations to support Mongoid validations as well [Jeroen van Dijk, saberma] * [changed] Support S3 file storage with the fog gem, instead of the aws gem (Trevor Turk) * [changed] Move translations to a YAML file (Josh Kalderimis) * [changed] Depend on activesupport ~> 3.0.0 instead of >= 3.0.0.rc (Trevor Turk) * [changed] Remove old Merb and Rails generators, support Rails 3 generators (Jonas Nicklas, Trevor Turk) * [changed] Replace Net::HTTP with open-url for remote file downloads (icebreaker) * [changed] Move translations to a YAML file (Josh Kalderimis) * [changed] Use gemspec to generate Gemfile contents (Jonas Nicklas) * [added] Add file size support for S3 storage (Pavel Chipiga) * [added] Add option for disabling multipart form check (Dennis Blöte) * [fixed] Correct naming of validators (Josh Kalderimis) * [fixed] Fix remote file downloader (Jonas Nicklas) * [fixed] Escape URLs passed to remote file downloader so URLs with spaces work (Mauricio Zaffari) * [fixed] Correct filename used in generators (Fred Wu) === Version 0.4.6 2010-07-20 * [removed] Support for MongoMapper, see: http://groups.google.com/group/carrierwave/browse_thread/thread/56df146b83878c22 * [changed] AWS support now uses the aws gem, instead of using aws-s3 or right-aws as previously * [added] cloud_files_cdn_host for Cloudfiles for performance gain * [added] #recreate_versions! to recreate versions from base file * [added] Support for MiniMagick in RSpec matchers * [added] RMagick's #resize_to_fill now takes an optional Gravity * [fixed] Pass through options to to_json * [fixed] Support new GridFS syntax for lates mongo gem * [fixed] Validation errors are internationalized when the error is thrown, not on load * [fixed] Rescue correct MiniMagick error * [fixed] Support DataMapper 1.0 * [fixed] SanitizedFile#copy_to preserves content_type. Should fix GridFS content type not being set. === Version 0.4.5 2010-02-20 * [added] Support for Rackspace Cloudfiles * [added] GridFS now accepts a port * [fixed] s3_headers is now properly initialized * [fixed] work around DataMapper's patching of core method === Version 0.4.4 2010-01-31 * [added] Support for downloading remote files * [added] CarrierWave.clean_cached_files! to remove old cached files * [added] Option to set headers for S3 * [added] GridStore now has authentication * [fixed] Rmagick convert method now does what it says * [fixed] Content type is stored on GridStore and Amazon S3 * [fixed] Metadata is no longer broken for S3 === Version 0.4.3 2009-12-19 * [fixed] cnamed URLs on S3 no longer have a third slash after http * [fixed] fixed deprecation warnings on Rails 2.3.5 === Version 0.4.2 2009-11-26 * [added] RightAWS as an alternative S3 implementation * [added] An option to enable/disable processing for tests * [added] Mongoid ORM support * [fixed] DataMapper now works both with and without dm-validations === Version 0.4.1 2009-10-26 * [changed] Major changes to the ImageScience module, it actually works now! * [fixed] Bug in configuration where it complais that it can't dup Symbol * [removed] Support for Sequel < 2.12 * [removed] `crop_resized` and `resize` aliases in RMagick, use `resize_to_fill` and `resize_to_fit` respectively === Version 0.4.0 2009-10-12 * [changed] the `public` option has been renamed `root` and the old `root` option was removed. No more ambiguity. * [changed] Major *breaking* changes to the configuration syntax. * [removed] support for `default_path` * [removed] the `cache_to_cache_dir` option * [removed] storage no longer calls `setup!` on storage engines * [added] Support for MongoDB's GridFS store === Version 0.3.4 2009-09-01 * [added] `default_url` as a replacement for `default_path` * [deprecated] `default_path` is deprecated === Version 0.3.4 2009-08-31 * [fixed] Deleting no longer causes TypeError in MongoMapper === Version 0.3.3 2009-08-29 * [added] Support for MongoMapper * [added] Support for CNamed Bucket URLs for Amazon S3 === Version 0.3.2 2009-07-18 Incremental upgrade * [added] Ruby 1.9 compatibility * [changed] Added Object#blank? implementation into CarrierWave, which removes any dpendencies on external libraries (extlib/activesupport) * [fixed] Performance issues with S3 support * [fixed] Sequel support for newer verions of Sequel (thanks Pavel!) === Version 0.3.1 2009-07-01 A bugfix release. Drop in compatible with 0.3.0. * [fixed] Saving a record with a mounted Uploader no longer removes uploaded file * [fixed] The file returned by S3 storage now has the path set to the full store path * [added] File returned by S3 storage now responds to S3 specific methods === 0.3 2009-06-20 This is a stabilization release. Most features are now working as expected and most bugs should be fixed. * [changed] Reworked how storage engines work, some internal API changes * [added] Macro-like methods for RMagick, no need to call #process any more! * [added] Ability to super to any Mount method * [fixed] Sequel support should now work as expected * [fixed] ActiveRecord no longer saves the record twice * [added] Added convenient macro style class methods to rmagick processing === 0.2.4 2009-06-11 * [added] `resize_to_limit` method for rmagick * [added] Now deletes files from Amazon S3 when record is destroyed === 0.2.3 2009-05-13 * [changed] Mount now no longer returns nil if there is no stored file, it returns a blank uploader instead * [added] Possibility to specify a default path * [added] Paperclip compatibility module === 0.2.1 2009-05-01 * [changed] Url method now optionally takes versions as parameters (like Paperclip) * [added] A field which allows files to be removed with a checkbox in mount * [added] Mount_on option for Mount, to be able to override the serialization column * [added] Added demeter friendly column_url method to Mount * [added] Option to not copy files to cache dir, to prevent writes on read only fs systems (this is a workaround and needs a better solution) === 0.2 2009-04-15 * [changed] The version is no longer stored in the store dir. This will break the paths for files uploaded with 0.1 * [changed] CarrierWave::Uploader is now a module, not a class, so you need to include it, not inherit from it. * [added] integrity checking in uploaders via a white list of extensions * [added] Validations for integrity and processing in ActiveRecord, activated by default * [added] Support for nested versions * [added] Permissions option to set the permissions of the uploaded files * [added] Support for Sequel * [added] CarrierWave::Uploader#read to read the contents of the uploaded files === 0.1 2009-03-12 This is a very experimental release that has not been well tested. All of the major features are in place though. Please note that there currently is a bug with load paths in Merb, which means you need to manually require uploaders. carrierwave-0.10.0/README.md 0000664 0000000 0000000 00000063371 12303471703 0015373 0 ustar 00root root 0000000 0000000 # CarrierWave This gem provides a simple and extremely flexible way to upload files from Ruby applications. It works well with Rack based web applications, such as Ruby on Rails. [](http://travis-ci.org/carrierwaveuploader/carrierwave) [](https://codeclimate.com/github/carrierwaveuploader/carrierwave) ## Information * RDoc documentation [available on RubyDoc.info](http://rubydoc.info/gems/carrierwave/frames) * Source code [available on GitHub](http://github.com/carrierwaveuploader/carrierwave) * More information, known limitations, and how-tos [available on the wiki](https://github.com/carrierwaveuploader/carrierwave/wiki) ## Getting Help * Please ask the [Google Group](http://groups.google.com/group/carrierwave) for help if you have any questions. * Please report bugs on the [issue tracker](http://github.com/carrierwaveuploader/carrierwave/issues) but read the "getting help" section in the wiki first. ## Installation Install the latest stable release: [sudo] gem install carrierwave In Rails, add it to your Gemfile: ```ruby gem 'carrierwave' ``` Finally, restart the server to apply the changes. Note that CarrierWave is not compatible with Rails 2 as of version 0.5. If you want to use Rails 2, please use the 0.4-stable branch on GitHub. ## Getting Started Start off by generating an uploader: rails generate uploader Avatar this should give you a file in: app/uploaders/avatar_uploader.rb Check out this file for some hints on how you can customize your uploader. It should look something like this: ```ruby class AvatarUploader < CarrierWave::Uploader::Base storage :file end ``` You can use your uploader class to store and retrieve files like this: ```ruby uploader = AvatarUploader.new uploader.store!(my_file) uploader.retrieve_from_store!('my_file.png') ``` CarrierWave gives you a `store` for permanent storage, and a `cache` for temporary storage. You can use different stores, including filesystem and cloud storage. Most of the time you are going to want to use CarrierWave together with an ORM. It is quite simple to mount uploaders on columns in your model, so you can simply assign files and get going: ### ActiveRecord Make sure you are loading CarrierWave after loading your ORM, otherwise you'll need to require the relevant extension manually, e.g.: ```ruby require 'carrierwave/orm/activerecord' ``` Add a string column to the model you want to mount the uploader by creating a migration: rails g migration add_avatar_to_users avatar:string rake db:migrate Open your model file and mount the uploader: ```ruby class User < ActiveRecord::Base mount_uploader :avatar, AvatarUploader end ``` Now you can cache files by assigning them to the attribute, they will automatically be stored when the record is saved. ```ruby u = User.new u.avatar = params[:file] u.avatar = File.open('somewhere') u.save! u.avatar.url # => '/url/to/file.png' u.avatar.current_path # => 'path/to/file.png' u.avatar.identifier # => 'file.png' ``` ### DataMapper, Mongoid, Sequel Other ORM support has been extracted into separate gems: * [carrierwave-datamapper](https://github.com/carrierwaveuploader/carrierwave-datamapper) * [carrierwave-mongoid](https://github.com/carrierwaveuploader/carrierwave-mongoid) * [carrierwave-sequel](https://github.com/jnicklas/carrierwave-sequel) There are more extensions listed in [the wiki](https://github.com/carrierwaveuploader/carrierwave/wiki) ## Changing the storage directory In order to change where uploaded files are put, just override the `store_dir` method: ```ruby class MyUploader < CarrierWave::Uploader::Base def store_dir 'public/my/upload/directory' end end ``` This works for the file storage as well as Amazon S3 and Rackspace Cloud Files. Define `store_dir` as `nil` if you'd like to store files at the root level. If you store files outside the project root folder, you may want to define `cache_dir` in the same way: ```ruby class MyUploader < CarrierWave::Uploader::Base def cache_dir '/tmp/projectname-cache' end end ``` ## Securing uploads Certain file might be dangerous if uploaded to the wrong location, such as php files or other script files. CarrierWave allows you to specify a white-list of allowed extensions. If you're mounting the uploader, uploading a file with the wrong extension will make the record invalid instead. Otherwise, an error is raised. ```ruby class MyUploader < CarrierWave::Uploader::Base def extension_white_list %w(jpg jpeg gif png) end end ``` ### Filenames and unicode chars Another security issue you should care for is the file names (see [Ruby On Rails Security Guide](http://guides.rubyonrails.org/security.html#file-uploads)). By default, CarrierWave provides only English letters, arabic numerals and '-+_.' symbols as white-listed characters in the file name. If you want to support local scripts (Cyrillic letters, letters with diacritics and so on), you have to override `sanitize_regexp` method. It should return regular expression which would match all *non*-allowed symbols. With Ruby 1.9 and higher you can simply write (as it has [Oniguruma](http://oniguruma.rubyforge.org/oniguruma/) built-in): ```ruby CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/ ``` With Ruby 1.8 you have to manually specify all character ranges. For example, for files which may contain Russian letters: ```ruby CarrierWave::SanitizedFile.sanitize_regexp = /[^a-zA-Zа-яА-ЯёЁ0-9\.\-\+_]/u ``` Also make sure that allowing non-latin characters won't cause a compatibility issue with a third-party plugins or client-side software. ## Setting the content type If you care about the content type of your files and notice that it's not being set as expected, you can configure your uploaders to use `CarrierWave::MimeTypes`. This adds a dependency on the [mime-types](http://rubygems.org/gems/mime-types) gem, but is recommended when using fog, and fog already has a dependency on mime-types. ```ruby require 'carrierwave/processing/mime_types' class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MimeTypes process :set_content_type end ``` ## Adding versions Often you'll want to add different versions of the same file. The classic example is image thumbnails. There is built in support for this*: *Note: You must have Imagemagick and MiniMagick installed to do image resizing. MiniMagick is a Ruby interface for Imagemagick which is a C program. This is why MiniMagick fails on 'bundle install' without Imagemagick installed. Some documentation refers to RMagick instead of MiniMagick but MiniMagick is recommended. To install Imagemagick on OSX with homebrew type the following: ``` $ brew install imagemagick ``` ```ruby class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process :resize_to_fit => [800, 800] version :thumb do process :resize_to_fill => [200,200] end end ``` When this uploader is used, an uploaded image would be scaled to be no larger than 800 by 800 pixels. A version called thumb is then created, which is scaled and cropped to exactly 200 by 200 pixels. The uploader could be used like this: ```ruby uploader = AvatarUploader.new uploader.store!(my_file) # size: 1024x768 uploader.url # => '/url/to/my_file.png' # size: 800x600 uploader.thumb.url # => '/url/to/thumb_my_file.png' # size: 200x200 ``` One important thing to remember is that process is called *before* versions are created. This can cut down on processing cost. It is possible to nest versions within versions: ```ruby class MyUploader < CarrierWave::Uploader::Base version :animal do version :human version :monkey version :llama end end ``` ### Conditional versions Occasionally you want to restrict the creation of versions on certain properties within the model or based on the picture itself. ```ruby class MyUploader < CarrierWave::Uploader::Base version :human, :if => :is_human? version :monkey, :if => :is_monkey? version :banner, :if => :is_landscape? protected def is_human? picture model.can_program?(:ruby) end def is_monkey? picture model.favorite_food == 'banana' end def is_landscape? picture image = MiniMagick::Image.open(picture.path) image[:width] > image[:height] end end ``` The `model` variable points to the instance object the uploader is attached to. ### Create versions from existing versions For performance reasons, it is often useful to create versions from existing ones instead of using the original file. If your uploader generates several versions where the next is smaller than the last, it will take less time to generate from a smaller, already processed image. ```ruby class MyUploader < CarrierWave::Uploader::Base version :thumb do process resize_to_fill: [280, 280] end version :small_thumb, :from_version => :thumb do process resize_to_fill: [20, 20] end end ``` The option `:from_version` uses the file cached in the `:thumb` version instead of the original version, potentially resulting in faster processing. ## Making uploads work across form redisplays Often you'll notice that uploaded files disappear when a validation fails. CarrierWave has a feature that makes it easy to remember the uploaded file even in that case. Suppose your `user` model has an uploader mounted on `avatar` file, just add a hidden field called `avatar_cache` (don't forget to add it to the attr_accessible list as necessary). In Rails, this would look like this: ```erb <%= form_for @user, :html => {:multipart => true} do |f| %>
<%= f.file_field :avatar %> <%= f.hidden_field :avatar_cache %>
<% end %> ```` It might be a good idea to show the user that a file has been uploaded, in the case of images, a small thumbnail would be a good indicator: ```erb <%= form_for @user, :html => {:multipart => true} do |f| %><%= image_tag(@user.avatar_url) if @user.avatar? %> <%= f.file_field :avatar %> <%= f.hidden_field :avatar_cache %>
<% end %> ``` ## Removing uploaded files If you want to remove a previously uploaded file on a mounted uploader, you can easily add a checkbox to the form which will remove the file when checked. ```erb <%= form_for @user, :html => {:multipart => true} do |f| %><%= image_tag(@user.avatar_url) if @user.avatar? %> <%= f.file_field :avatar %>
<% end %> ``` If you want to remove the file manually, you can call
remove_avatar!
, then save the object.
```erb
@user.remove_avatar!
@user.save
#=> true
```
## Uploading files from a remote location
Your users may find it convenient to upload a file from a location on the Internet
via a URL. CarrierWave makes this simple, just add the appropriate attribute to your
form and you're good to go:
```erb
<%= form_for @user, :html => {:multipart => true} do |f| %>
<%= image_tag(@user.avatar_url) if @user.avatar? %> <%= f.text_field :remote_avatar_url %>
<% end %> ``` If you're using ActiveRecord, CarrierWave will indicate invalid URLs and download failures automatically with attribute validation errors. If you aren't, or you disable CarrierWave's `validate_download` option, you'll need to handle those errors yourself. ## Providing a default URL In many cases, especially when working with images, it might be a good idea to provide a default url, a fallback in case no file has been uploaded. You can do this easily by overriding the `default_url` method in your uploader: ```ruby class MyUploader < CarrierWave::Uploader::Base def default_url "/images/fallback/" + [version_name, "default.png"].compact.join('_') end end ``` Or if you are using the Rails asset pipeline: ```ruby class MyUploader < CarrierWave::Uploader::Base def default_url ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) end end ``` ## Recreating versions You might come to a situation where you want to retroactively change a version or add a new one. You can use the `recreate_versions!` method to recreate the versions from the base file. This uses a naive approach which will re-upload and process the specified version or all versions, if none is passed as an argument. When you are generating random unique filenames you have to call `save!` on the model after using `recreate_versions!`. This is necessary because `recreate_versions!` doesn't save the new filename to the database. Calling `save!` yourself will prevent that the database and file system are running out of sync. ```ruby instance = MyUploader.new instance.recreate_versions!(:thumb, :large) ``` Or on a mounted uploader: ```ruby User.all.each do |user| user.avatar.recreate_versions! end ``` Note: `recreate_versions!` will throw an exception on records without an image. To avoid this, scope the records to those with images or check if an image exists within the block. If you're using ActiveRecord, recreating versions for a user avatar might look like this: ```ruby User.all.each do |user| user.avatar.recreate_versions! if user.avatar? end ``` ## Configuring CarrierWave CarrierWave has a broad range of configuration options, which you can configure, both globally and on a per-uploader basis: ```ruby CarrierWave.configure do |config| config.permissions = 0666 config.directory_permissions = 0777 config.storage = :file end ``` Or alternatively: ```ruby class AvatarUploader < CarrierWave::Uploader::Base permissions 0777 end ``` If you're using Rails, create an initializer for this: config/initializers/carrierwave.rb ## Testing with CarrierWave It's a good idea to test your uploaders in isolation. In order to speed up your tests, it's recommended to switch off processing in your tests, and to use the file storage. In Rails you could do that by adding an initializer with: ```ruby if Rails.env.test? or Rails.env.cucumber? CarrierWave.configure do |config| config.storage = :file config.enable_processing = false end end ``` Remember, if you have already set `storage :something` in your uploader, the `storage` setting from this initializer will be ignored. If you need to test your processing, you should test it in isolation, and enable processing only for those tests that need it. CarrierWave comes with some RSpec matchers which you may find useful: ```ruby require 'carrierwave/test/matchers' describe MyUploader do include CarrierWave::Test::Matchers before do MyUploader.enable_processing = true @uploader = MyUploader.new(@user, :avatar) @uploader.store!(File.open(path_to_file)) end after do MyUploader.enable_processing = false @uploader.remove! end context 'the thumb version' do it "should scale down a landscape image to be exactly 64 by 64 pixels" do @uploader.thumb.should have_dimensions(64, 64) end end context 'the small version' do it "should scale down a landscape image to fit within 200 by 200 pixels" do @uploader.small.should be_no_larger_than(200, 200) end end it "should make the image readable only to the owner and not executable" do @uploader.should have_permissions(0600) end end ``` Setting the enable_processing flag on an uploader will prevent any of the versions from processing as well. Processing can be enabled for a single version by setting the processing flag on the version like so: ```ruby @uploader.thumb.enable_processing = true ``` ## Using Amazon S3 [Fog](http://github.com/fog/fog) is used to support Amazon S3. Ensure you have it in your Gemfile: ```ruby gem "fog", "~> 1.3.1" ``` You'll need to provide your fog_credentials and a fog_directory (also known as a bucket) in an initializer. For the sake of performance it is assumed that the directory already exists, so please create it if need be. You can also pass in additional options, as documented fully in lib/carrierwave/storage/fog.rb. Here's a full example: ```ruby CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', # required :aws_access_key_id => 'xxx', # required :aws_secret_access_key => 'yyy', # required :region => 'eu-west-1', # optional, defaults to 'us-east-1' :host => 's3.example.com', # optional, defaults to nil :endpoint => 'https://s3.example.com:8080' # optional, defaults to nil } config.fog_directory = 'name_of_directory' # required config.fog_public = false # optional, defaults to true config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {} end ``` In your uploader, set the storage to :fog ```ruby class AvatarUploader < CarrierWave::Uploader::Base storage :fog end ``` That's it! You can still use the `CarrierWave::Uploader#url` method to return the url to the file on Amazon S3. ## Using Rackspace Cloud Files [Fog](http://github.com/fog/fog) is used to support Rackspace Cloud Files. Ensure you have it in your Gemfile: ```ruby gem "fog" ``` You'll need to configure a directory (also known as a container), username and API key in the initializer. For the sake of performance it is assumed that the directory already exists, so please create it if need be. Using a US-based account: ```ruby CarrierWave.configure do |config| config.fog_credentials = { :provider => 'Rackspace', :rackspace_username => 'xxxxxx', :rackspace_api_key => 'yyyyyy', :rackspace_region => :ord # optional, defaults to :dfw } config.fog_directory = 'name_of_directory' end ``` Using a UK-based account: ```ruby CarrierWave.configure do |config| config.fog_credentials = { :provider => 'Rackspace', :rackspace_username => 'xxxxxx', :rackspace_api_key => 'yyyyyy', :rackspace_auth_url => Fog::Rackspace::UK_AUTH_ENDPOINT, :rackspace_region => :lon } config.fog_directory = 'name_of_directory' end ``` You can optionally include your CDN host name in the configuration. This is *highly* recommended, as without it every request requires a lookup of this information. ```ruby config.asset_host = "http://c000000.cdn.rackspacecloud.com" ``` In your uploader, set the storage to :fog ```ruby class AvatarUploader < CarrierWave::Uploader::Base storage :fog end ``` That's it! You can still use the `CarrierWave::Uploader#url` method to return the url to the file on Rackspace Cloud Files. ## Using Google Storage for Developers [Fog](http://github.com/fog/fog) is used to support Google Storage for Developers. Ensure you have it in your Gemfile: ```ruby gem "fog" ``` You'll need to configure a directory (also known as a bucket), access key id and secret access key in the initializer. For the sake of performance it is assumed that the directory already exists, so please create it if need be. Sign up [here](http://gs-signup-redirect.appspot.com/) and get your credentials [here](https://storage.cloud.google.com/m) under the section “Interoperable Access”. ```ruby CarrierWave.configure do |config| config.fog_credentials = { :provider => 'Google', :google_storage_access_key_id => 'xxxxxx', :google_storage_secret_access_key => 'yyyyyy' } config.fog_directory = 'name_of_directory' end ``` In your uploader, set the storage to :fog ```ruby class AvatarUploader < CarrierWave::Uploader::Base storage :fog end ``` That's it! You can still use the `CarrierWave::Uploader#url` method to return the url to the file on Google. ## Dynamic Asset Host The `asset_host` config property can be assigned a proc (or anything that responds to `call`) for generating the host dynamically. The proc-compliant object gets an instance of the current `CarrierWave::Storage::Fog::File` or `CarrierWave::SanitizedFile` as its only argument. ```ruby CarrierWave.configure do |config| config.asset_host = proc do |file| identifier = # some logic "http://#{identifier}.cdn.rackspacecloud.com" end end ``` ## Using RMagick If you're uploading images, you'll probably want to manipulate them in some way, you might want to create thumbnail images for example. CarrierWave comes with a small library to make manipulating images with RMagick easier, you'll need to include it in your Uploader: ```ruby class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick end ``` The RMagick module gives you a few methods, like `CarrierWave::RMagick#resize_to_fill` which manipulate the image file in some way. You can set a `process` callback, which will call that method any time a file is uploaded. There is a demonstration of convert here. Convert will only work if the file has the same file extension, thus the use of the filename method. ```ruby class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick process :resize_to_fill => [200, 200] process :convert => 'png' def filename super.chomp(File.extname(super)) + '.png' if original_filename.present? end end ``` Check out the manipulate! method, which makes it easy for you to write your own manipulation methods. ## Using MiniMagick MiniMagick is similar to RMagick but performs all the operations using the 'mogrify' command which is part of the standard ImageMagick kit. This allows you to have the power of ImageMagick without having to worry about installing all the RMagick libraries. See the MiniMagick site for more details: https://github.com/minimagick/minimagick And the ImageMagick command line options for more for whats on offer: http://www.imagemagick.org/script/command-line-options.php Currently, the MiniMagick carrierwave processor provides exactly the same methods as for the RMagick processor. ```ruby class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process :resize_to_fill => [200, 200] end ``` ## Migrating from Paperclip If you are using Paperclip, you can use the provided compatibility module: ```ruby class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::Compatibility::Paperclip end ``` See the documentation for `CarrierWave::Compatibility::Paperclip` for more details. Be sure to use mount_on to specify the correct column: ```ruby mount_uploader :avatar, AvatarUploader, :mount_on => :avatar_file_name ``` Unfortunately attachment_fu differs too much in philosophy for there to be a sensible compatibility mode. Patches for migrating from other solutions will be happily accepted. ## i18n The Active Record validations use the Rails i18n framework. Add these keys to your translations file: ```yaml errors: messages: carrierwave_processing_error: "Cannot resize image." carrierwave_integrity_error: "Not an image." carrierwave_download_error: "Couldn't download image." extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}" extension_black_list_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}" ``` ## Large files By default, CarrierWave copies an uploaded file twice, first copying the file into the cache, then copying the file into the store. For large files, this can be prohibitively time consuming. You may change this behavior by overriding either or both of the `move_to_cache` and `move_to_store` methods: ```ruby class MyUploader < CarrierWave::Uploader::Base def move_to_cache true end def move_to_store true end end ``` When the `move_to_cache` and/or `move_to_store` methods return true, files will be moved (instead of copied) to the cache and store respectively. This has only been tested with the local filesystem store. ## Skipping ActiveRecord callbacks By default, mounting an uploader into an ActiveRecord model will add a few callbacks. For example, this code: ```ruby class User mount_uploader :avatar, AvatarUploader end ``` Will add these callbacks: ```ruby after_save :store_avatar! before_save :write_avatar_identifier after_commit :remove_avatar! :on => :destroy before_update :store_previous_model_for_avatar after_save :remove_previously_stored_avatar ``` If you want to skip any of these callbacks (eg. you want to keep the existing avatar, even after uploading a new one), you can use ActiveRecord’s `skip_callback` method. ```ruby class User mount_uploader :avatar, AvatarUploader skip_callback :save, :after, :remove_previously_stored_avatar end ``` ## Contributing to CarrierWave See [CONTRIBUTING.md](https://github.com/carrierwaveuploader/carrierwave/blob/master/CONTRIBUTING.md) ## License Copyright (c) 2008-2013 Jonas Nicklas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. carrierwave-0.10.0/Rakefile 0000664 0000000 0000000 00000001134 12303471703 0015546 0 ustar 00root root 0000000 0000000 # encoding: UTF-8 require 'rubygems' begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'bundler' Bundler::GemHelper.install_tasks require 'rake' require 'rspec/core/rake_task' require 'cucumber' require 'cucumber/rake/task' desc "Run all examples" RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = %w[--color] end desc "Run cucumber features" Cucumber::Rake::Task.new(:features) do |t| t.cucumber_opts = "features --format progress" end task :default => [:spec, :features] carrierwave-0.10.0/carrierwave.gemspec 0000664 0000000 0000000 00000003132 12303471703 0017760 0 ustar 00root root 0000000 0000000 # -*- encoding: utf-8 -*- lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require 'carrierwave/version' require 'date' Gem::Specification.new do |s| s.name = "carrierwave" s.version = CarrierWave::VERSION s.authors = ["Jonas Nicklas"] s.date = Date.today s.description = "Upload files in your Ruby applications, map them to a range of ORMs, store them on different backends." s.summary = "Ruby file upload library" s.email = ["jonas.nicklas@gmail.com"] s.extra_rdoc_files = ["README.md"] s.files = Dir.glob("{bin,lib}/**/*") + %w(README.md) s.homepage = %q{https://github.com/carrierwaveuploader/carrierwave} s.rdoc_options = ["--main"] s.require_paths = ["lib"] s.rubyforge_project = %q{carrierwave} s.rubygems_version = %q{1.3.5} s.specification_version = 3 s.licenses = ["MIT"] s.add_dependency "activesupport", ">= 3.2.0" s.add_dependency "activemodel", ">= 3.2.0" s.add_dependency "json", ">= 1.7" s.add_dependency "mime-types", ">= 1.16" s.add_development_dependency "mysql2" s.add_development_dependency "rails", ">= 3.2.0" s.add_development_dependency "cucumber", "~> 1.3.2" s.add_development_dependency "rspec", "~> 2.13.0" s.add_development_dependency "sham_rack" s.add_development_dependency "fog", ">= 1.3.1" s.add_development_dependency "mini_magick", ">= 3.6.0" s.add_development_dependency "rmagick" s.add_development_dependency "nokogiri", "~> 1.5.10" # 1.6 requires ruby > 1.8.7 s.add_development_dependency "timecop", "0.6.1" # 0.6.2 requires ruby > 1.8.7 s.add_development_dependency "generator_spec" end carrierwave-0.10.0/cucumber.yml 0000664 0000000 0000000 00000000114 12303471703 0016426 0 ustar 00root root 0000000 0000000 default: --format pretty --no-source html: --format html --out features.html carrierwave-0.10.0/features/ 0000775 0000000 0000000 00000000000 12303471703 0015720 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/features/caching.feature 0000664 0000000 0000000 00000003212 12303471703 0020667 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage In order to be able to temporarily store files to disk As a developer using CarrierWave I want to cache files Scenario: cache a file Given an uploader class that uses the 'file' storage And an instance of that class When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' Scenario: cache two files in succession Given an uploader class that uses the 'file' storage And an instance of that class When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' When I cache the file 'fixtures/monkey.txt' Then there should be a file called 'monkey.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'monkey.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/monkey.txt' Scenario: retrieving a file from cache Given an uploader class that uses the 'file' storage And an instance of that class And the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache Then the uploader should have 'public/uploads/tmp/1369894322-345-2255/bork.txt' as its current path carrierwave-0.10.0/features/download.feature 0000664 0000000 0000000 00000001567 12303471703 0021115 0 ustar 00root root 0000000 0000000 Feature: downloading files In order to allow users to upload remote files As a developer using CarrierWave I want to download files to the filesystem via HTTP Background: Given an uploader class that uses the 'file' storage And an instance of that class Scenario: download a file When I download the file 'http://s3.amazonaws.com/Monkey/testfile.txt' Then there should be a file called 'testfile.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'testfile.txt' in a subdirectory of 'public/uploads/tmp' should contain 'S3 Remote File' Scenario: downloading a file then storing When I download the file 'http://s3.amazonaws.com/Monkey/testfile.txt' And I store the file Then there should be a file at 'public/uploads/testfile.txt' And the file at 'public/uploads/testfile.txt' should contain 'S3 Remote File' carrierwave-0.10.0/features/file_storage.feature 0000664 0000000 0000000 00000003640 12303471703 0021743 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: store two files in succession When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' When I store the file 'fixtures/monkey.txt' Then there should be a file at 'public/uploads/monkey.txt' And the file at 'public/uploads/monkey.txt' should be identical to the file at 'fixtures/monkey.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' carrierwave-0.10.0/features/file_storage_overridden_filename.feature 0000664 0000000 0000000 00000004002 12303471703 0026015 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and overriden filename In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem with an overriden filename Background: Given an uploader class that uses the 'file' storage And that the uploader reverses the filename And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/txt.krob' And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt' Scenario: store two files in succession When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/txt.krob' And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt' When I store the file 'fixtures/monkey.txt' Then there should be a file at 'public/uploads/txt.yeknom' And the file at 'public/uploads/txt.yeknom' should be identical to the file at 'fixtures/monkey.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/txt.krob' When I store the file Then there should be a file at 'public/uploads/txt.krob' And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/txt.krob' And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt' carrierwave-0.10.0/features/file_storage_overridden_store_dir.feature 0000664 0000000 0000000 00000004100 12303471703 0026226 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and overridden store dir In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage And that the uploader has the store_dir overridden to 'public/monkey/llama' And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/monkey/llama/bork.txt' And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: store two files in succession When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/monkey/llama/bork.txt' And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt' When I store the file 'fixtures/monkey.txt' Then there should be a file at 'public/monkey/llama/monkey.txt' And the file at 'public/monkey/llama/monkey.txt' should be identical to the file at 'fixtures/monkey.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/monkey/llama/bork.txt' When I store the file Then there should be a file at 'public/monkey/llama/bork.txt' And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/monkey/llama/bork.txt' And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt' carrierwave-0.10.0/features/file_storage_reversing_processor.feature 0000664 0000000 0000000 00000004771 12303471703 0026134 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and a processor that reverses the file In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage And an instance of that class And the class has a method called 'reverse' that reverses the contents of a file And the class will process 'reverse' Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt' Scenario: store two files in succession When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt' When I store the file 'fixtures/monkey.txt' Then there should be a file at 'public/uploads/monkey.txt' And the file at 'public/uploads/monkey.txt' should not be identical to the file at 'fixtures/monkey.txt' And the file at 'public/uploads/monkey.txt' should be the reverse of the file at 'fixtures/monkey.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should not be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' carrierwave-0.10.0/features/fixtures/ 0000775 0000000 0000000 00000000000 12303471703 0017571 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/features/fixtures/bork.txt 0000664 0000000 0000000 00000000016 12303471703 0021264 0 ustar 00root root 0000000 0000000 this is a file carrierwave-0.10.0/features/fixtures/monkey.txt 0000664 0000000 0000000 00000000024 12303471703 0021630 0 ustar 00root root 0000000 0000000 this is another file carrierwave-0.10.0/features/fixtures/upcased_bork.txt 0000664 0000000 0000000 00000000016 12303471703 0022770 0 ustar 00root root 0000000 0000000 THIS IS A FILE carrierwave-0.10.0/features/mount_activerecord.feature 0000664 0000000 0000000 00000004530 12303471703 0023173 0 ustar 00root root 0000000 0000000 Feature: Mount an Uploader on ActiveRecord class In order to easily attach files to a form As a web developer using CarrierWave I want to mount an uploader on an ActiveRecord class Background: Given an uploader class that uses the 'file' storage And an activerecord class that uses the 'users' table And the uploader class is mounted on the 'avatar' column And an instance of the activerecord class Scenario: assign a file When I assign the file 'fixtures/bork.txt' to the 'avatar' column Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' Scenario: assign a file and save the record When I assign the file 'fixtures/bork.txt' to the 'avatar' column And I save the active record Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the url for the column 'avatar' should be '/uploads/bork.txt' Scenario: assign a file and retrieve it from cache When I assign the file 'fixtures/bork.txt' to the 'avatar' column And I retrieve the file later from the cache name for the column 'avatar' And I save the active record Then there should be a file at 'public/uploads/bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the url for the column 'avatar' should be '/uploads/bork.txt' Scenario: store a file and retrieve it later When I assign the file 'fixtures/bork.txt' to the 'avatar' column And I retrieve the file later from the cache name for the column 'avatar' And I save the active record Then there should be a file at 'public/uploads/bork.txt' When I reload the active record Then the url for the column 'avatar' should be '/uploads/bork.txt' Scenario: store a file and delete the record When I assign the file 'fixtures/bork.txt' to the 'avatar' column And I retrieve the file later from the cache name for the column 'avatar' And I save the active record Then there should be a file at 'public/uploads/bork.txt' When I delete the active record Then there should not be a file at 'public/uploads/bork.txt' carrierwave-0.10.0/features/step_definitions/ 0000775 0000000 0000000 00000000000 12303471703 0021266 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/features/step_definitions/activerecord_steps.rb 0000664 0000000 0000000 00000000745 12303471703 0025511 0 ustar 00root root 0000000 0000000 # encoding: utf-8 Given /^an activerecord class that uses the '([^\']*)' table$/ do |name| @mountee_klass = Class.new(ActiveRecord::Base) @mountee_klass.table_name = name end Given /^an instance of the activerecord class$/ do @instance = @mountee_klass.new end When /^I save the active record$/ do @instance.save! end When /^I reload the active record$/ do @instance = @instance.class.find(@instance.id) end When /^I delete the active record$/ do @instance.destroy end carrierwave-0.10.0/features/step_definitions/caching_steps.rb 0000664 0000000 0000000 00000000625 12303471703 0024430 0 ustar 00root root 0000000 0000000 # encoding: utf-8 Given /^the file '(.*?)' is cached file at '(.*?)'$/ do |file, cached| FileUtils.mkdir_p(File.dirname(file_path(cached))) FileUtils.cp(file_path(file), file_path(cached)) end When /^I cache the file '(.*?)'$/ do |file| @uploader.cache!(File.open(file_path(file))) end When /^I retrieve the cache name '(.*?)' from the cache$/ do |name| @uploader.retrieve_from_cache!(name) end carrierwave-0.10.0/features/step_definitions/datamapper_steps.rb 0000664 0000000 0000000 00000001176 12303471703 0025154 0 ustar 00root root 0000000 0000000 # encoding: utf-8 Given /^a datamapper class that has a '([^\']*)' column$/ do |column| @mountee_klass = Class.new do include DataMapper::Resource storage_names[:default] = 'users' property :id, DataMapper::Types::Serial property column.to_sym, String end @mountee_klass.auto_migrate! end Given /^an instance of the datamapper class$/ do @instance = @mountee_klass.new end When /^I save the datamapper record$/ do @instance.save end When /^I reload the datamapper record$/ do @instance = @instance.class.first(:id => @instance.key) end When /^I delete the datamapper record$/ do @instance.destroy end carrierwave-0.10.0/features/step_definitions/download_steps.rb 0000664 0000000 0000000 00000000514 12303471703 0024640 0 ustar 00root root 0000000 0000000 When /^I download the file '([^']+)'/ do |url| unless ENV['REMOTE'] == 'true' sham_rack_app = ShamRack.at('s3.amazonaws.com').stub sham_rack_app.register_resource('/Monkey/testfile.txt', 'S3 Remote File', 'text/plain') end @uploader.download!(url) unless ENV['REMOTE'] == 'true' ShamRack.unmount_all end end carrierwave-0.10.0/features/step_definitions/file_steps.rb 0000664 0000000 0000000 00000003446 12303471703 0023757 0 ustar 00root root 0000000 0000000 # encoding: utf-8 ### # EXISTENCE Then /^there should be a file at '(.*?)'$/ do |file| File.exist?(file_path(file)).should be_true end Then /^there should not be a file at '(.*?)'$/ do |file| File.exist?(file_path(file)).should be_false end Then /^there should be a file called '(.*?)' somewhere in a subdirectory of '(.*?)'$/ do |file, directory| Dir.glob(File.join(file_path(directory), '**', file)).any?.should be_true end ### # IDENTICAL Then /^the file at '(.*?)' should be identical to the file at '(.*?)'$/ do |one, two| File.read(file_path(one)).should == File.read(file_path(two)) end Then /^the file at '(.*?)' should not be identical to the file at '(.*?)'$/ do |one, two| File.read(file_path(one)).should_not == File.read(file_path(two)) end Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should be identical to the file at '(.*?)'$/ do |file, directory, other| File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should == File.read(file_path(other)) end Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should not be identical to the file at '(.*?)'$/ do |file, directory, other| File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should_not == File.read(file_path(other)) end ### # CONTENT Then /^the file called '([^']+)' in a subdirectory of '([^']+)' should contain '([^']+)'$/ do |file, directory, content| File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should include(content) end Then /^the file at '([^']+)' should contain '([^']+)'$/ do |path, content| File.read(file_path(path)).should include(content) end ### # REVERSING Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two| File.read(file_path(one)).should == File.read(file_path(two)).reverse end carrierwave-0.10.0/features/step_definitions/general_steps.rb 0000664 0000000 0000000 00000005470 12303471703 0024454 0 ustar 00root root 0000000 0000000 # encoding: utf-8 Given /^an uploader class that uses the '(.*?)' storage$/ do |kind| @klass = Class.new(CarrierWave::Uploader::Base) @klass.storage = kind.to_sym end Given /^an instance of that class$/ do @uploader = @klass.new end Given /^a processor method named :upcase$/ do @klass.class_eval do define_method(:upcase) do content = File.read(current_path) File.open(current_path, 'w') { |f| f.write content.upcase } end end end Then /^the contents of the file should be '(.*?)'$/ do |contents| @uploader.read.chomp.should == contents end Given /^that the uploader reverses the filename$/ do @klass.class_eval do def filename super.reverse unless super.blank? end end end Given /^that the uploader has the filename overridden to '(.*?)'$/ do |filename| @klass.class_eval do define_method(:filename) do filename end end end Given /^that the uploader has the store_dir overridden to '(.*?)'$/ do |store_dir| @klass.class_eval do define_method(:store_dir) do file_path(store_dir) end end end Given /^that the version '(.*?)' has the store_dir overridden to '(.*?)'$/ do |version, store_dir| @klass.versions[version.to_sym][:uploader].class_eval do define_method(:store_dir) do file_path(store_dir) end end end Given /^that the uploader class has a version named '([^\']+)'$/ do |name| @klass.version(name) end Given /^that the uploader class has a version named '([^\']+)' which process '([a-zA-Z0-9\_\?!]*)'$/ do |name, processor_name| @klass.version(name) do process processor_name.to_sym end end Given /^that the uploader class has a version named '([^\']+)' which is based on version '(.*?)'$/ do |name, based_version_name| @klass.version(name, {:from_version => based_version_name.to_sym}) end Given /^yo dawg, I put a version called '(.*?)' in your version called '(.*?)'$/ do |v2, v1| @klass.version(v1) do version(v2) end end Given /^the class has a method called 'reverse' that reverses the contents of a file$/ do @klass.class_eval do def reverse text = File.read(current_path) File.open(current_path, 'w') { |f| f.write(text.reverse) } end end end Given /^the class will process '([a-zA-Z0-9\_\?!]*)'$/ do |name| @klass.process name.to_sym end Then /^the uploader should have '(.*?)' as its current path$/ do |path| @uploader.current_path.should == file_path(path) end Then /^the uploader should have the url '(.*?)'$/ do |url| @uploader.url.should == url end Then /^the uploader's version '(.*?)' should have the url '(.*?)'$/ do |version, url| @uploader.versions[version.to_sym].url.should == url end Then /^the uploader's nested version '(.*?)' nested in '(.*?)' should have the url '(.*?)'$/ do |v2, v1, url| @uploader.versions[v1.to_sym].versions[v2.to_sym].url.should == url end carrierwave-0.10.0/features/step_definitions/mount_steps.rb 0000664 0000000 0000000 00000001236 12303471703 0024175 0 ustar 00root root 0000000 0000000 # encoding: utf-8 When /^I assign the file '([^\']*)' to the '([^\']*)' column$/ do |path, column| @instance.send("#{column}=", File.open(file_path(path))) end Given /^the uploader class is mounted on the '([^\']*)' column$/ do |column| @mountee_klass.mount_uploader column.to_sym, @klass end When /^I retrieve the file later from the cache name for the column '([^\']*)'$/ do |column| new_instance = @instance.class.new new_instance.send("#{column}_cache=", @instance.send("#{column}_cache")) @instance = new_instance end Then /^the url for the column '([^\']*)' should be '([^\']*)'$/ do |column, url| @instance.send("#{column}_url").should == url end carrierwave-0.10.0/features/step_definitions/store_steps.rb 0000664 0000000 0000000 00000000714 12303471703 0024167 0 ustar 00root root 0000000 0000000 # encoding: utf-8 Given /^the file '(.*?)' is stored at '(.*?)'$/ do |file, stored| FileUtils.mkdir_p(File.dirname(file_path(stored))) FileUtils.cp(file_path(file), file_path(stored)) end When /^I store the file$/ do @uploader.store! end When /^I store the file '(.*?)'$/ do |file| @uploader.store!(File.open(file_path(file))) end When /^I retrieve the file '(.*?)' from the store$/ do |identifier| @uploader.retrieve_from_store!(identifier) end carrierwave-0.10.0/features/support/ 0000775 0000000 0000000 00000000000 12303471703 0017434 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/features/support/activerecord.rb 0000664 0000000 0000000 00000000565 12303471703 0022441 0 ustar 00root root 0000000 0000000 # encoding: utf-8 require 'carrierwave/mount' require File.join(File.dirname(__FILE__), '..', '..', 'spec', 'support', 'activerecord') class TestMigration < ActiveRecord::Migration def self.up create_table :users, :force => true do |t| t.column :avatar, :string end end def self.down drop_table :users end end Before do TestMigration.up end carrierwave-0.10.0/features/support/env.rb 0000664 0000000 0000000 00000000661 12303471703 0020554 0 ustar 00root root 0000000 0000000 # encoding: utf-8 $:.unshift File.expand_path(File.join('..', '..', 'lib'), File.dirname(__FILE__)) require File.join(File.dirname(__FILE__), 'activerecord') require 'rspec' require 'carrierwave' require 'sham_rack' alias :running :lambda def file_path( *paths ) File.expand_path(File.join('..', *paths), File.dirname(__FILE__)) end CarrierWave.root = file_path('public') After do FileUtils.rm_rf(file_path("public")) end carrierwave-0.10.0/features/versions_basics.feature 0000664 0000000 0000000 00000006002 12303471703 0022467 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and versions In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage And that the uploader class has a version named 'thumb' And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/uploads/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/bork.txt' And there should not be a file at 'public/uploads/thumb_bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' And there should be a file at 'public/uploads/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/uploads/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt' Scenario: retrieving a file from store Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt' Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt' When I retrieve the file 'bork.txt' from the store Then the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' carrierwave-0.10.0/features/versions_caching_from_versions.feature 0000664 0000000 0000000 00000004435 12303471703 0025602 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and versions with overridden store dir In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage Given a processor method named :upcase And that the uploader class has a version named 'thumb' which process 'upcase' And that the version 'thumb' has the store_dir overridden to 'public/monkey/llama' And that the uploader class has a version named 'small_thumb' which is based on version 'thumb' And that the version 'small_thumb' has the store_dir overridden to 'public/monkey/toro' And an instance of that class Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'small_thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And the file called 'thumb_bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/upcased_bork.txt' And the file called 'small_thumb_bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/upcased_bork.txt' And there should not be a file at 'public/uploads/bork.txt' And there should not be a file at 'public/monkey/llama/thumb_bork.txt' And there should not be a file at 'public/monkey/toro/small_thumb_bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/monkey/llama/thumb_bork.txt' Then there should be a file at 'public/monkey/toro/small_thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/upcased_bork.txt' And the file at 'public/monkey/toro/small_thumb_bork.txt' should be identical to the file at 'fixtures/upcased_bork.txt' carrierwave-0.10.0/features/versions_nested_versions.feature 0000664 0000000 0000000 00000011741 12303471703 0024443 0 ustar 00root root 0000000 0000000 Feature: uploader with nested versions In order to optimize performance for processing As a developer using CarrierWave I want to set nested versions Background: Given an uploader class that uses the 'file' storage And that the uploader class has a version named 'thumb' And yo dawg, I put a version called 'mini' in your version called 'thumb' And yo dawg, I put a version called 'micro' in your version called 'thumb' And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/uploads/thumb_bork.txt' Then there should be a file at 'public/uploads/thumb_mini_bork.txt' Then there should be a file at 'public/uploads/thumb_micro_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt' And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/bork.txt' And there should not be a file at 'public/uploads/thumb_bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' And there should be a file at 'public/uploads/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt' And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_bork.txt' Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_mini_bork.txt' Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_micro_bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/uploads/thumb_bork.txt' Then there should be a file at 'public/uploads/thumb_mini_bork.txt' Then there should be a file at 'public/uploads/thumb_micro_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt' And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/monkey.txt' Scenario: retrieving a file from store Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt' Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt' Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_mini_bork.txt' Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_micro_bork.txt' When I retrieve the file 'bork.txt' from the store Then the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt' And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt' carrierwave-0.10.0/features/versions_overridden_filename.feature 0000664 0000000 0000000 00000006374 12303471703 0025240 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and overriden filename In order to customize the filaname of uploaded files As a developer using CarrierWave I want to upload files to the filesystem with an overriden filename and different verions Background: Given an uploader class that uses the 'file' storage And that the uploader class has a version named 'thumb' And that the uploader has the filename overridden to 'grark.png' And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/grark.png' Then there should be a file at 'public/uploads/thumb_grark.png' And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/grark.png' And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/grark.png' And there should not be a file at 'public/uploads/thumb_grark.png' When I store the file Then there should be a file at 'public/uploads/grark.png' And there should be a file at 'public/uploads/thumb_grark.png' And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt' And the uploader should have the url '/uploads/grark.png' And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/grark.png' Then there should be a file at 'public/uploads/thumb_grark.png' And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/monkey.txt' Scenario: retrieving a file from store Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt' Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt' When I retrieve the file 'bork.txt' from the store Then the uploader should have the url '/uploads/bork.txt' And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt' carrierwave-0.10.0/features/versions_overriden_store_dir.feature 0000664 0000000 0000000 00000005145 12303471703 0025301 0 ustar 00root root 0000000 0000000 Feature: uploader with file storage and versions with overridden store dir In order to be awesome As a developer using CarrierWave I want to upload files to the filesystem Background: Given an uploader class that uses the 'file' storage And that the uploader class has a version named 'thumb' And that the version 'thumb' has the store_dir overridden to 'public/monkey/llama' And an instance of that class Scenario: store a file When I store the file 'fixtures/bork.txt' Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/monkey/llama/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: cache a file and then store it When I cache the file 'fixtures/bork.txt' Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp' And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And the file called 'thumb_bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' And there should not be a file at 'public/uploads/bork.txt' And there should not be a file at 'public/monkey/llama/thumb_bork.txt' When I store the file Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/monkey/llama/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt' Scenario: retrieving a file from cache then storing Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/bork.txt' Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/1369894322-345-2255/thumb_bork.txt' When I retrieve the cache name '1369894322-345-2255/bork.txt' from the cache And I store the file Then there should be a file at 'public/uploads/bork.txt' Then there should be a file at 'public/monkey/llama/thumb_bork.txt' And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt' carrierwave-0.10.0/gemfiles/ 0000775 0000000 0000000 00000000000 12303471703 0015675 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/gemfiles/rails-3-2-stable.gemfile 0000664 0000000 0000000 00000000254 12303471703 0022111 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gem "rails", :git => "https://github.com/rails/rails.git", :branch => "3-2-stable" gem "carrierwave", :path => "../" gemspec :path => "../" carrierwave-0.10.0/gemfiles/rails-4-0-stable.gemfile 0000664 0000000 0000000 00000000230 12303471703 0022102 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gem "rails", :github => "rails/rails", :branch => "4-0-stable" gem "carrierwave", :path => "../" gemspec :path => "../" carrierwave-0.10.0/gemfiles/rails-4-1-stable.gemfile 0000664 0000000 0000000 00000000230 12303471703 0022103 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gem "rails", :github => "rails/rails", :branch => "4-1-stable" gem "carrierwave", :path => "../" gemspec :path => "../" carrierwave-0.10.0/gemfiles/rails-master.gemfile 0000664 0000000 0000000 00000000315 12303471703 0021631 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gem "rails", :github => "rails/rails", :branch => "master" gem "arel", :github => "rails/arel", :branch => "master" gem "carrierwave", :path => "../" gemspec :path => "../" carrierwave-0.10.0/lib/ 0000775 0000000 0000000 00000000000 12303471703 0014650 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/lib/carrierwave.rb 0000664 0000000 0000000 00000004305 12303471703 0017511 0 ustar 00root root 0000000 0000000 # encoding: utf-8 require 'fileutils' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/class/attribute' require 'active_support/concern' module CarrierWave class << self attr_accessor :root, :base_path def configure(&block) CarrierWave::Uploader::Base.configure(&block) end def clean_cached_files!(seconds=60*60*24) CarrierWave::Uploader::Base.clean_cached_files!(seconds) end end end if defined?(Merb) CarrierWave.root = Merb.dir_for(:public) Merb::BootLoader.before_app_loads do # Setup path for uploaders and load all of them before classes are loaded Merb.push_path(:uploaders, Merb.root / 'app' / 'uploaders', '*.rb') Dir.glob(File.join(Merb.load_paths[:uploaders])).each {|f| require f } end elsif defined?(Rails) module CarrierWave class Railtie < Rails::Railtie initializer "carrierwave.setup_paths" do CarrierWave.root = Rails.root.join(Rails.public_path).to_s CarrierWave.base_path = ENV['RAILS_RELATIVE_URL_ROOT'] end initializer "carrierwave.active_record" do ActiveSupport.on_load :active_record do require 'carrierwave/orm/activerecord' end end ## # Loads the Carrierwave locale files before the Rails application locales # letting the Rails application overrite the carrierwave locale defaults config.before_configuration do I18n.load_path << File.join(File.dirname(__FILE__), "carrierwave", "locale", 'en.yml') end end end elsif defined?(Sinatra) if defined?(Padrino) && defined?(PADRINO_ROOT) CarrierWave.root = File.join(PADRINO_ROOT, "public") else CarrierWave.root = if Sinatra::Application.respond_to?(:public_folder) # Sinatra >= 1.3 Sinatra::Application.public_folder else # Sinatra < 1.3 Sinatra::Application.public end end end require "carrierwave/utilities" require "carrierwave/error" require "carrierwave/sanitized_file" require "carrierwave/mount" require "carrierwave/processing" require "carrierwave/version" require "carrierwave/storage" require "carrierwave/uploader" require "carrierwave/compatibility/paperclip" require "carrierwave/test/matchers" carrierwave-0.10.0/lib/carrierwave/ 0000775 0000000 0000000 00000000000 12303471703 0017162 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/lib/carrierwave/compatibility/ 0000775 0000000 0000000 00000000000 12303471703 0022033 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/lib/carrierwave/compatibility/paperclip.rb 0000664 0000000 0000000 00000007226 12303471703 0024346 0 ustar 00root root 0000000 0000000 # encoding: utf-8 module CarrierWave module Compatibility ## # Mix this module into an Uploader to make it mimic Paperclip's storage paths # This will make your Uploader use the same default storage path as paperclip # does. If you need to override it, you can override the +paperclip_path+ method # and provide a Paperclip style path: # # class MyUploader < CarrierWave::Uploader::Base # include CarrierWave::Compatibility::Paperclip # # def paperclip_path # ":rails_root/public/uploads/:id/:attachment/:style_:basename.:extension" # end # end # # --- # # This file contains code taken from Paperclip # # LICENSE # # The MIT License # # Copyright (c) 2008 Jon Yurek and thoughtbot, inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # module Paperclip extend ActiveSupport::Concern DEFAULT_MAPPINGS = { :rails_root => lambda{|u, f| Rails.root.to_s }, :rails_env => lambda{|u, f| Rails.env }, :id_partition => lambda{|u, f| ("%09d" % u.model.id).scan(/\d{3}/).join("/")}, :id => lambda{|u, f| u.model.id }, :attachment => lambda{|u, f| u.mounted_as.to_s.downcase.pluralize }, :style => lambda{|u, f| u.paperclip_style }, :basename => lambda{|u, f| u.filename.gsub(/#{File.extname(u.filename)}$/, "") }, :extension => lambda{|u, d| File.extname(u.filename).gsub(/^\.+/, "")}, :class => lambda{|u, f| u.model.class.name.underscore.pluralize} } included do attr_accessor :filename class_attribute :mappings self.mappings ||= DEFAULT_MAPPINGS.dup end def store_path(for_file=filename) path = paperclip_path self.filename = for_file path ||= File.join(*[store_dir, paperclip_style.to_s, for_file].compact) interpolate_paperclip_path(path) end def store_dir ":rails_root/public/system/:attachment/:id" end def paperclip_default_style :original end def paperclip_path end def paperclip_style version_name || paperclip_default_style end module ClassMethods def interpolate(sym, &block) mappings[sym] = block end end private def interpolate_paperclip_path(path) mappings.each_pair.inject(path) do |agg, pair| agg.gsub(":#{pair[0]}") { pair[1].call(self, self.paperclip_style).to_s } end end end # Paperclip end # Compatibility end # CarrierWave carrierwave-0.10.0/lib/carrierwave/error.rb 0000664 0000000 0000000 00000000352 12303471703 0020640 0 ustar 00root root 0000000 0000000 module CarrierWave class UploadError < StandardError; end class IntegrityError < UploadError; end class InvalidParameter < UploadError; end class ProcessingError < UploadError; end class DownloadError < UploadError; end end carrierwave-0.10.0/lib/carrierwave/locale/ 0000775 0000000 0000000 00000000000 12303471703 0020421 5 ustar 00root root 0000000 0000000 carrierwave-0.10.0/lib/carrierwave/locale/cs.yml 0000664 0000000 0000000 00000001511 12303471703 0021547 0 ustar 00root root 0000000 0000000 cs: errors: messages: carrierwave_processing_error: se nepodařilo zpracovat carrierwave_integrity_error: není povolený typ souboru carrierwave_download_error: nemůže být stažen extension_white_list_error: "Není možné nahrávat %{extension} soubory, povolené typy: %{allowed_types}" extension_black_list_error: "Není možné nahrávat %{extension} soubory, zakázané typy: %{prohibited_types}" rmagick_processing_error: "Nepodařilo se upravit pomocí rmagick, možná se nejedná o obrázek? Hlášená Chyba: %{e}" mime_types_processing_error: "Nepodařilo se upravit s MIME::Types, možná se nejedná o content-type? Hlášená Chyba: %{e}" mini_magick_processing_error: "Nepodařilo se upravit pomocí MiniMagick, možná se nejedná o obrázek? Hlášená Chyba: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/de.yml 0000664 0000000 0000000 00000001576 12303471703 0021545 0 ustar 00root root 0000000 0000000 de: errors: messages: carrierwave_processing_error: konnte nicht verarbeitet werden carrierwave_integrity_error: ist kein erlaubter Dateityp carrierwave_download_error: konnte nicht heruntergeladen werden extension_white_list_error: "Sie sind nicht berechtigt %{extension} Dateien hochzuladen, erlaubte Typen: %{allowed_types}" extension_black_list_error: "Sie sind nicht berechtigt %{extension} Dateien hochzuladen, verbotene Typen: %{prohibited_types}" rmagick_processing_error: "Verarbeitung mit rmagick fehlgeschlagen, vielleicht ist es kein Bild? Original Fehler: %{e}" mime_types_processing_error: "Verarbeitung mit MIME::Types fehlgeschlagen, vielleicht kein gültiger content-type? Original Fehler: %{e}" mini_magick_processing_error: "Verarbeitung mit MiniMagick fehlgeschlagen, vielleicht ist es kein Bild? Original Fehler: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/el.yml 0000664 0000000 0000000 00000002234 12303471703 0021545 0 ustar 00root root 0000000 0000000 el: errors: messages: carrierwave_processing_error: "απέτυχε στην επεξεργασία" carrierwave_integrity_error: "δεν ανήκει σε επιτρεπτό τύπο αρχείου" carrierwave_download_error: "δεν ήταν δυνατό να μεταφορτωθεί" extension_white_list_error: "Δεν επιτρέπεται το ανέβασμα αρχείων %{extension}, επιτρεπτοί τύποι: %{allowed_types}" extension_black_list_error: "Δεν επιτρέπεται το ανέβασμα αρχείων %{extension}, μη επιτρεπτοί τύποι: %{prohibited_types}" rmagick_processing_error: "Απέτυχε ο χειρισμός με rmagick, ίσως δεν είναι εικόνα; Αρχικό Σφάλμα: %{e}" mime_types_processing_error: "Απέτυχε η επεξεργασία του αρχείου με MIME::Types, ίσως δεν έχει έγκυρο content-type; Αρχικό Σφάλμα: %{e}" mini_magick_processing_error: "Απέτυχε ο χειρισμός με MiniMagick, ίσως δεν είναι εικόνα; Αρχικό Σφάλμα: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/en.yml 0000664 0000000 0000000 00000001465 12303471703 0021554 0 ustar 00root root 0000000 0000000 en: errors: messages: carrierwave_processing_error: failed to be processed carrierwave_integrity_error: is not of an allowed file type carrierwave_download_error: could not be downloaded extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}" extension_black_list_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}" rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image? Original Error: %{e}" mime_types_processing_error: "Failed to process file with MIME::Types, maybe not valid content-type? Original Error: %{e}" mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/es.yml 0000664 0000000 0000000 00000001604 12303471703 0021554 0 ustar 00root root 0000000 0000000 es: errors: messages: carrierwave_processing_error: no se pudo procesar carrierwave_integrity_error: no es de un tipo de archivo permitido carrierwave_download_error: no se pudo descargar extension_white_list_error: "No se pueden subir archivos de esta extensión %{extension}, las extensiones permitidas son: %{allowed_types}" extension_black_list_error: "No se pueden subir archivos de esta extensión %{extension}, las extensiones prohibidas son: %{allowed_types}" rmagick_processing_error: "No se pudo manipular con rmagick, quizá porque no es una imágen? Error original: %{e}" mime_types_processing_error: "No se pudo procesar archivo con MIME::Types, quizá no tiene el content-type correcto? Error original: %{e}" mini_magick_processing_error: "No se pudo manipular con MiniMagick, quizá porque no es una imágen? Error original: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/fr.yml 0000664 0000000 0000000 00000001714 12303471703 0021556 0 ustar 00root root 0000000 0000000 fr: errors: messages: carrierwave_processing_error: "Impossible de redimensionner l'image." carrierwave_integrity_error: "Ce n'est pas une image." carrierwave_download_error: "Impossible de télécharger l'image." extension_white_list_error: "Vous n'êtes pas autorisé à uploader des fichiers %{extension}, types autorisés: %{allowed_types}" extension_black_list_error: "Vous n'êtes pas autorisé à uploader des fichiers %{extension}, types interdits: %{prohibited_types}" rmagick_processing_error: "La manipulation d'image avec rmagick a échoué. Peut-être que ce n'est pas une image ? Erreur originale: %{e}" mime_types_processing_error: "Le traitement de fichier avec MIME::Types a échoué. Peut-être que ce n'est pas un type valide ? Erreur originale: %{e}" mini_magick_processing_error: "La manipulation d'image avec MiniMagick a échoué. Peut-être que ce n'est pas une image ? Erreur originale: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/ja.yml 0000664 0000000 0000000 00000002141 12303471703 0021534 0 ustar 00root root 0000000 0000000 ja: errors: messages: carrierwave_processing_error: 処理できませんでした carrierwave_integrity_error: は許可されていないファイルタイプです carrierwave_download_error: はダウンロードできません extension_white_list_error: "%{extension}ファイルのアップロードは許可されていません。アップロードできるファイルタイプ: %{allowed_types}" extension_black_list_error: "%{extension}ファイルのアップロードは許可されていません。アップロードできないファイルタイプ: %{prohibited_types}" rmagick_processing_error: "rmagickがファイルを処理できませんでした。画像を確認してください。エラーメッセージ: %{e}" mime_types_processing_error: "MIME::Typesのファイルを処理できませんでした。Content-Typeを確認してください。エラーメッセージ: %{e}" mini_magick_processing_error: "MiniMagickがファイルを処理できませんでした。画像を確認してください。エラーメッセージ: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/nb.yml 0000664 0000000 0000000 00000001476 12303471703 0021553 0 ustar 00root root 0000000 0000000 nb: errors: messages: carrierwave_processing_error: kunne ikke behandles carrierwave_integrity_error: er ikke en tillatt filtype carrierwave_download_error: kunne ikke lastes ned extension_white_list_error: "Du kan ikke laste opp %{extension}-filer, tillatte filtyper: %{allowed_types}" extension_black_list_error: "Du kan ikke laste opp %{extension}-filer, forbudte filtyper: %{prohibited_types}" rmagick_processing_error: "Kunne ikke manipulere med rmagick. Er du sikker på at det er et bilde? Feilmelding: %{e}" mime_types_processing_error: "Kunne ikke behandle fil med MIME::Types. Er du sikker på at content-type er korrekt? Feilmelding: %{e}" mini_magick_processing_error: "Kunne ikke manipulere med MiniMagick. Er du sikker på at det er et bilde? Feilmelding: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/nl.yml 0000664 0000000 0000000 00000001646 12303471703 0021564 0 ustar 00root root 0000000 0000000 nl: errors: messages: carrierwave_processing_error: kon niet worden verwerkt carrierwave_integrity_error: is niet van een toegestaan bestandstype carrierwave_download_error: kon niet gedownload worden extension_white_list_error: "Het is niet toegestaan om %{extension} bestanden te uploaden; toegestane bestandstypes: %{allowed_types}" extension_black_list_error: "Het is niet toegestaan om %{extension} bestanden te uploaden; verboden bestandstypes: %{prohibited_types}" rmagick_processing_error: "Bewerking met rmagick is mislukt, misschien is het geen afbeelding? Originele foutmelding: %{e}" mime_types_processing_error: "Verwerking van bestand met MIME::Types is mislukt, misschien is het geen geldig content-type? Originele foutmelding: %{e}" mini_magick_processing_error: "Bewerking met MiniMagick is mislukt, misschien is het geen afbeelding? Originele foutmelding: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/pl.yml 0000664 0000000 0000000 00000001655 12303471703 0021566 0 ustar 00root root 0000000 0000000 pl: errors: messages: carrierwave_processing_error: nie można przetworzyć carrierwave_integrity_error: niedozwolony typ pliku carrierwave_download_error: nie można pobrać pliku extension_white_list_error: "Nie można wgrać pliku o rozszerzeniu %{extension}, dozwolone typy plików: %{allowed_types}" extension_black_list_error: "Nie można wgrać pliku o rozszerzeniu %{extension}, zakazane typy plików: %{prohibited_types}" rmagick_processing_error: "Nie udało się przetworzyć pliku przy pomocy rmagick, może to nie jest obrazek? Oryginalna treść błędu: %{e}" mime_types_processing_error: "Nie udało się przetworzyć pliku przy pomocy MIME::Types, może content-type jest niepoprawny? Oryginalna treść błędu: %{e}" mini_magick_processing_error: "Nie udało się przetworzyć pliku przy pomocy MiniMagick, może to nie jest obrazek? Oryginalna treść błędu: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/pt-BR.yml 0000664 0000000 0000000 00000001533 12303471703 0022072 0 ustar 00root root 0000000 0000000 pt-BR: errors: messages: carrierwave_processing_error: falhou em ser processado carrierwave_integrity_error: não é um tipo de arquivo permitido carrierwave_download_error: não pôde ser baixado extension_white_list_error: "Não é permitido o envio de arquivos %{extension}, tipos permitidos: %{allowed_types}" extension_black_list_error: "Não é permitido o envio de arquivos %{extension}, tipos proibidos: %{prohibited_types}" rmagick_processing_error: "Falha ao manipular com RMagick, talvez arquivo não seja uma imagem? Erro original: %{e}" mime_types_processing_error: "Falha ao processar arquivo com MIME::Types, talvez content-type seja inválido? Erro original: %{e}" mini_magick_processing_error: "Falha ao manipular com MiniMagick, talvez arquivo não seja uma imagem? Erro original: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/pt-PT.yml 0000664 0000000 0000000 00000001714 12303471703 0022113 0 ustar 00root root 0000000 0000000 pt-PT: errors: messages: carrierwave_processing_error: falhou ao ser processado carrierwave_integrity_error: não é um tipo de ficheiro permitido carrierwave_download_error: não pôde ser transferido extension_white_list_error: "Não é permitido o envio de ficheiros com a extensão %{extension}, tipos de ficheiro permitidos: %{allowed_types}" extension_black_list_error: "Não é permitido o envio de ficheiros com a extensão %{extension}, tipos de ficheiro proibidos: %{prohibited_types}" rmagick_processing_error: "Ocorreu uma falha ao processar com rmagick, talvez o ficheiro não seja uma imagem? Erro original: %{e}" mime_types_processing_error: "Ocorreu uma falha ao processar com MIME::Types, talvez o parâmetro content-type não seja válido? Erro original: %{e}" mini_magick_processing_error: "Ocorreu uma falha ao processar com MiniMagick, talvez o ficheiro não seja uma imagem? Erro original: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/ru.yml 0000664 0000000 0000000 00000002252 12303471703 0021573 0 ustar 00root root 0000000 0000000 ru: errors: messages: carrierwave_processing_error: Невозможно обработать изображение carrierwave_integrity_error: Файл не является изображением carrierwave_download_error: Невозможно скачать файл extension_white_list_error: "Вы не можете загружать файлы типа %{extension}, разрешенные типы: %{allowed_types}" extension_black_list_error: "Вы не можете загружать файлы типа %{extension}, запрещенные типы: %{prohibited_types}" rmagick_processing_error: "Ошибка взаимодействия с RMagick, может быть это не изображение? Исходная ошибка: %{e}" mime_types_processing_error: "Не получилось обработать файл с MIME::Types, возможно неправильный content-type? Исходная ошибка: %{e}" mini_magick_processing_error: "Ошибка взаимодействия с MiniMagick, может быть это не изображение? Исходная ошибка: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/sk.yml 0000664 0000000 0000000 00000001521 12303471703 0021560 0 ustar 00root root 0000000 0000000 sk: errors: messages: carrierwave_processing_error: sa nepodarilo spracovať carrierwave_integrity_error: nie je povolený typ súboru carrierwave_download_error: nie je možné stiahnuť extension_white_list_error: "Nie je možné nahrávať %{extension} súbory, povolené typy: %{allowed_types}" extension_black_list_error: "Nie je možné nahrávať %{extension} súbory, zakázané typy: %{prohibited_types}" rmagick_processing_error: "Nepodarilo sa upraviť pomocou rmagick, možno nejde o obrázok? Hlásená chyba: %{e}" mime_types_processing_error: "Súbor sa nepodarilo spracovať pomocou MIME::Types, možno nejde o valídny content-type? Hlásená chyba: %{e}" mini_magick_processing_error: "Nepodarilo sa upraviť pomocou MiniMagick, možno nejde o obrázok? Hlásená chyba: %{e}" carrierwave-0.10.0/lib/carrierwave/locale/tr.yml 0000664 0000000 0000000 00000001557 12303471703 0021601 0 ustar 00root root 0000000 0000000 tr: errors: messages: carrierwave_processing_error: işlenmesi sırasında hata oluştu carrierwave_integrity_error: izin verilebilir bir dosya türü değil carrierwave_download_error: indirilemedi extension_white_list_error: "%{extension} uzantılı dosyaları yükleme izniniz yok, izin verilen uzantılar: %{allowed_types}" extension_black_list_error: "%{extension} uzantılı dosyaları yükleme izniniz yok, izin verilmeyen uzantılar: %{prohibited_types}" rmagick_processing_error: "Resim rmagick ile düzenlenemedi, belkide resim değildir? Orjinal Hata: %{e}" mime_types_processing_error: "Dosya, MIME::Types kullanılarak işlenemedi, belkide geçerli bir içerik türü değildir? Orjinal Hata: %{e}" mini_magick_processing_error: "Resim MiniMagick ile düzenlenemedi, belkide resim değildir? Orjinal Hata: %{e}" carrierwave-0.10.0/lib/carrierwave/mount.rb 0000664 0000000 0000000 00000030340 12303471703 0020651 0 ustar 00root root 0000000 0000000 # encoding: utf-8 module CarrierWave ## # If a Class is extended with this module, it gains the mount_uploader # method, which is used for mapping attributes to uploaders and allowing # easy assignment. # # You can use mount_uploader with pretty much any class, however it is # intended to be used with some kind of persistent storage, like an ORM. # If you want to persist the uploaded files in a particular Class, it # needs to implement a `read_uploader` and a `write_uploader` method. # module Mount ## # === Returns # # [Hash{Symbol => CarrierWave}] what uploaders are mounted on which columns # def uploaders @uploaders ||= superclass.respond_to?(:uploaders) ? superclass.uploaders.dup : {} end def uploader_options @uploader_options ||= superclass.respond_to?(:uploader_options) ? superclass.uploader_options.dup : {} end ## # Return a particular option for a particular uploader # # === Parameters # # [column (Symbol)] The column the uploader is mounted at # [option (Symbol)] The option, e.g. validate_integrity # # === Returns # # [Object] The option value # def uploader_option(column, option) if uploader_options[column].has_key?(option) uploader_options[column][option] else uploaders[column].send(option) end end ## # Mounts the given uploader on the given column. This means that assigning # and reading from the column will upload and retrieve files. Supposing # that a User class has an uploader mounted on image, you can assign and # retrieve files like this: # # @user.image # =>