lockbox_middleware 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/Capfile +4 -0
- data/Gemfile +11 -0
- data/Rakefile +12 -0
- data/VERSION +1 -0
- data/app/controllers/admin/partners_controller.rb +14 -0
- data/app/controllers/admin_controller.rb +8 -0
- data/app/controllers/application_controller.rb +32 -0
- data/app/controllers/authentication_controller.rb +58 -0
- data/app/controllers/confirmation_controller.rb +14 -0
- data/app/controllers/fetch_password_controller.rb +44 -0
- data/app/controllers/home_controller.rb +11 -0
- data/app/controllers/partner_sessions_controller.rb +30 -0
- data/app/controllers/partners_controller.rb +58 -0
- data/app/helpers/admin/partners_helper.rb +3 -0
- data/app/helpers/admin_helper.rb +2 -0
- data/app/helpers/application_helper.rb +20 -0
- data/app/helpers/authentication_helper.rb +2 -0
- data/app/helpers/fetch_password_helper.rb +2 -0
- data/app/helpers/home_helper.rb +2 -0
- data/app/helpers/labeled_builder.rb +76 -0
- data/app/helpers/partners_helper.rb +2 -0
- data/app/models/partner.rb +129 -0
- data/app/models/partner_mailer.rb +25 -0
- data/app/models/partner_session.rb +2 -0
- data/app/views/admin/show.html.erb +6 -0
- data/app/views/authentication/four_two_oh.html.erb +4 -0
- data/app/views/fetch_password/index.html.erb +4 -0
- data/app/views/fetch_password/show.html.erb +6 -0
- data/app/views/home/show.html.erb +20 -0
- data/app/views/layouts/admin.html.erb +42 -0
- data/app/views/layouts/application.html.erb +48 -0
- data/app/views/partner_mailer/confirmation.text.html.erb +30 -0
- data/app/views/partner_mailer/confirmation.text.plain.erb +5 -0
- data/app/views/partner_mailer/fetch_password.text.html.erb +32 -0
- data/app/views/partner_mailer/fetch_password.text.plain.erb +5 -0
- data/app/views/partner_sessions/new.html.erb +9 -0
- data/app/views/partners/_form.html.erb +7 -0
- data/app/views/partners/edit.html.erb +5 -0
- data/app/views/partners/index.html.erb +0 -0
- data/app/views/partners/new.html.erb +6 -0
- data/app/views/partners/show.html.erb +48 -0
- data/app/views/shared/_footer.html.erb +0 -0
- data/app/views/shared/_header.html.erb +3 -0
- data/app/views/shared/_logged_in_menu.html.erb +1 -0
- data/app/views/shared/_logged_out_menu.html.erb +2 -0
- data/config/asset_packages.yml +19 -0
- data/config/boot.rb +110 -0
- data/config/database.yml.example +25 -0
- data/config/environment.rb +56 -0
- data/config/environments/development.rb +22 -0
- data/config/environments/production.rb +30 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/inflections.rb +10 -0
- data/config/initializers/mime_types.rb +7 -0
- data/config/initializers/new_rails_defaults.rb +21 -0
- data/config/initializers/session_store.rb +15 -0
- data/config/initializers/settings.rb +1 -0
- data/config/initializers/string.rb +25 -0
- data/config/locales/en.yml +5 -0
- data/config/lockbox.yml.example +12 -0
- data/config/routes.rb +23 -0
- data/db/migrate/20091104170848_create_partners.rb +34 -0
- data/db/migrate/20091106213802_add_index_on_api_key.rb +9 -0
- data/db/migrate/20100507193948_add_partner_slug.rb +11 -0
- data/db/seeds.rb +7 -0
- data/lib/admin_authentication.rb +9 -0
- data/lib/authentication.rb +48 -0
- data/lib/rfc822.rb +18 -0
- data/lib/tasks/jeweler.rake +14 -0
- data/lib/tasks/rspec.rake +144 -0
- data/public/404.html +30 -0
- data/public/422.html +30 -0
- data/public/500.html +30 -0
- data/public/blank.html +33 -0
- data/public/favicon.ico +0 -0
- data/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/images/active_scaffold/default/add.gif +0 -0
- data/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/public/images/active_scaffold/default/close.gif +0 -0
- data/public/images/active_scaffold/default/cross.png +0 -0
- data/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/public/images/active_scaffold/default/indicator.gif +0 -0
- data/public/images/active_scaffold/default/magnifier.png +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/javascripts/active_scaffold/default/active_scaffold.js +434 -0
- data/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
- data/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/csshover.htc +120 -0
- data/public/javascripts/dragdrop.js +973 -0
- data/public/javascripts/effects.js +1128 -0
- data/public/javascripts/prototype.js +4320 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/public/stylesheets/active_scaffold/default/stylesheet.css +822 -0
- data/public/stylesheets/application.css +189 -0
- data/public/stylesheets/ie.css +11 -0
- data/public/stylesheets/reset.css +42 -0
- data/public/stylesheets/screen.css +257 -0
- data/script/about +4 -0
- data/script/autospec +6 -0
- data/script/console +3 -0
- data/script/cucumber +17 -0
- data/script/dbconsole +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/script/spec +10 -0
- data/spec/controllers/admin/partners_controller_spec.rb +55 -0
- data/spec/controllers/admin_controller_spec.rb +29 -0
- data/spec/controllers/application_controller_spec.rb +36 -0
- data/spec/controllers/authentication_controller_spec.rb +120 -0
- data/spec/controllers/confirmation_controller_spec.rb +36 -0
- data/spec/controllers/fetch_password_controller_spec.rb +155 -0
- data/spec/controllers/home_controller_spec.rb +15 -0
- data/spec/controllers/partner_sessions_controller_spec.rb +84 -0
- data/spec/controllers/partners_controller_spec.rb +132 -0
- data/spec/factories/partners.rb +14 -0
- data/spec/models/partner_mailer_spec.rb +47 -0
- data/spec/models/partner_spec.rb +155 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/helper_methods.rb +31 -0
- data/spec/support/mocha.rb +2 -0
- data/vendor/gems/authlogic-2.1.3/.gitignore +9 -0
- data/vendor/gems/authlogic-2.1.3/CHANGELOG.rdoc +345 -0
- data/vendor/gems/authlogic-2.1.3/LICENSE +20 -0
- data/vendor/gems/authlogic-2.1.3/README.rdoc +246 -0
- data/vendor/gems/authlogic-2.1.3/Rakefile +42 -0
- data/vendor/gems/authlogic-2.1.3/VERSION.yml +5 -0
- data/vendor/gems/authlogic-2.1.3/authlogic.gemspec +217 -0
- data/vendor/gems/authlogic-2.1.3/generators/session/session_generator.rb +9 -0
- data/vendor/gems/authlogic-2.1.3/generators/session/templates/session.rb +2 -0
- data/vendor/gems/authlogic-2.1.3/init.rb +1 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic.rb +57 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/base.rb +107 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/email.rb +110 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/logged_in_status.rb +60 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/login.rb +141 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/magic_columns.rb +24 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/password.rb +344 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/perishable_token.rb +105 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/persistence_token.rb +68 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/restful_authentication.rb +61 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/session_maintenance.rb +139 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/single_access_token.rb +65 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/acts_as_authentic/validations_scope.rb +32 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/authenticates_many/association.rb +42 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/authenticates_many/base.rb +55 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/abstract_adapter.rb +67 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/merb_adapter.rb +30 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/rails_adapter.rb +48 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/sinatra_adapter.rb +61 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/aes256.rb +43 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/bcrypt.rb +90 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/md5.rb +34 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/sha1.rb +35 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/sha256.rb +50 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/sha512.rb +50 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/wordpress.rb +43 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/i18n.rb +83 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/i18n/translator.rb +15 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/random.rb +33 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/regex.rb +25 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/activation.rb +58 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/active_record_trickery.rb +61 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/base.rb +37 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/brute_force_protection.rb +96 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/callbacks.rb +88 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/cookies.rb +130 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/existence.rb +93 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/foundation.rb +63 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/http_auth.rb +58 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/id.rb +41 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/klass.rb +78 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/magic_columns.rb +95 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/magic_states.rb +59 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/params.rb +101 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/password.rb +240 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/perishable_token.rb +18 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/persistence.rb +70 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/priority_record.rb +34 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/scopes.rb +101 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/session.rb +62 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/timeout.rb +82 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/unauthorized_record.rb +50 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/session/validation.rb +82 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case.rb +120 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case/mock_controller.rb +45 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case/mock_cookie_jar.rb +14 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case/mock_logger.rb +10 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case/mock_request.rb +19 -0
- data/vendor/gems/authlogic-2.1.3/lib/authlogic/test_case/rails_request_adapter.rb +30 -0
- data/vendor/gems/authlogic-2.1.3/rails/init.rb +1 -0
- data/vendor/gems/authlogic-2.1.3/shoulda_macros/authlogic.rb +69 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/base_test.rb +18 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/email_test.rb +97 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/logged_in_status_test.rb +36 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/login_test.rb +109 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/magic_columns_test.rb +27 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/password_test.rb +236 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/perishable_token_test.rb +90 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/persistence_token_test.rb +55 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/restful_authentication_test.rb +40 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/session_maintenance_test.rb +84 -0
- data/vendor/gems/authlogic-2.1.3/test/acts_as_authentic_test/single_access_test.rb +44 -0
- data/vendor/gems/authlogic-2.1.3/test/authenticates_many_test.rb +16 -0
- data/vendor/gems/authlogic-2.1.3/test/crypto_provider_test/aes256_test.rb +14 -0
- data/vendor/gems/authlogic-2.1.3/test/crypto_provider_test/bcrypt_test.rb +14 -0
- data/vendor/gems/authlogic-2.1.3/test/crypto_provider_test/sha1_test.rb +23 -0
- data/vendor/gems/authlogic-2.1.3/test/crypto_provider_test/sha256_test.rb +14 -0
- data/vendor/gems/authlogic-2.1.3/test/crypto_provider_test/sha512_test.rb +14 -0
- data/vendor/gems/authlogic-2.1.3/test/fixtures/companies.yml +5 -0
- data/vendor/gems/authlogic-2.1.3/test/fixtures/employees.yml +17 -0
- data/vendor/gems/authlogic-2.1.3/test/fixtures/projects.yml +3 -0
- data/vendor/gems/authlogic-2.1.3/test/fixtures/users.yml +24 -0
- data/vendor/gems/authlogic-2.1.3/test/i18n_test.rb +33 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/affiliate.rb +7 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/company.rb +6 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/employee.rb +7 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/employee_session.rb +2 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/ldaper.rb +3 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/ordered_hash.rb +9 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/project.rb +3 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/user.rb +5 -0
- data/vendor/gems/authlogic-2.1.3/test/libs/user_session.rb +6 -0
- data/vendor/gems/authlogic-2.1.3/test/random_test.rb +49 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/activation_test.rb +43 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/active_record_trickery_test.rb +36 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/brute_force_protection_test.rb +101 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/callbacks_test.rb +6 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/cookies_test.rb +112 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/credentials_test.rb +0 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/existence_test.rb +64 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/http_auth_test.rb +28 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/id_test.rb +17 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/klass_test.rb +40 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/magic_columns_test.rb +62 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/magic_states_test.rb +60 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/params_test.rb +53 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/password_test.rb +106 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/perishability_test.rb +15 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/persistence_test.rb +21 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/scopes_test.rb +60 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/session_test.rb +59 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/timeout_test.rb +52 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/unauthorized_record_test.rb +13 -0
- data/vendor/gems/authlogic-2.1.3/test/session_test/validation_test.rb +23 -0
- data/vendor/gems/authlogic-2.1.3/test/test_helper.rb +182 -0
- data/vendor/gems/factory_girl-1.2.3/.specification +121 -0
- data/vendor/gems/factory_girl-1.2.3/CONTRIBUTION_GUIDELINES.rdoc +9 -0
- data/vendor/gems/factory_girl-1.2.3/Changelog +29 -0
- data/vendor/gems/factory_girl-1.2.3/LICENSE +19 -0
- data/vendor/gems/factory_girl-1.2.3/README.rdoc +228 -0
- data/vendor/gems/factory_girl-1.2.3/Rakefile +81 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl.rb +35 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/aliases.rb +50 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/attribute.rb +29 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/attribute/association.rb +20 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/attribute/callback.rb +16 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/attribute/dynamic.rb +20 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/attribute/static.rb +17 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb +395 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/proxy.rb +79 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/proxy/attributes_for.rb +21 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/proxy/build.rb +30 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/proxy/create.rb +12 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/proxy/stub.rb +50 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/sequence.rb +63 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/step_definitions.rb +54 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/syntax.rb +12 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/syntax/blueprint.rb +42 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/syntax/generate.rb +68 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/syntax/make.rb +39 -0
- data/vendor/gems/factory_girl-1.2.3/lib/factory_girl/syntax/sham.rb +42 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/aliases_spec.rb +29 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/attribute/association_spec.rb +29 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/attribute/callback_spec.rb +23 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/attribute/dynamic_spec.rb +49 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/attribute/static_spec.rb +29 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/attribute_spec.rb +30 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/factory_spec.rb +571 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy/attributes_for_spec.rb +52 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy/build_spec.rb +81 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy/create_spec.rb +94 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy/stub_spec.rb +79 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy_spec.rb +84 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/sequence_spec.rb +66 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/syntax/blueprint_spec.rb +34 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/syntax/generate_spec.rb +57 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/syntax/make_spec.rb +35 -0
- data/vendor/gems/factory_girl-1.2.3/spec/factory_girl/syntax/sham_spec.rb +35 -0
- data/vendor/gems/factory_girl-1.2.3/spec/integration_spec.rb +304 -0
- data/vendor/gems/factory_girl-1.2.3/spec/models.rb +43 -0
- data/vendor/gems/factory_girl-1.2.3/spec/spec_helper.rb +18 -0
- data/vendor/gems/paperclip-2.3.1.1/.specification +161 -0
- data/vendor/gems/paperclip-2.3.1.1/LICENSE +26 -0
- data/vendor/gems/paperclip-2.3.1.1/README.rdoc +174 -0
- data/vendor/gems/paperclip-2.3.1.1/Rakefile +103 -0
- data/vendor/gems/paperclip-2.3.1.1/generators/paperclip/USAGE +5 -0
- data/vendor/gems/paperclip-2.3.1.1/generators/paperclip/paperclip_generator.rb +27 -0
- data/vendor/gems/paperclip-2.3.1.1/generators/paperclip/templates/paperclip_migration.rb.erb +19 -0
- data/vendor/gems/paperclip-2.3.1.1/init.rb +1 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip.rb +353 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/attachment.rb +414 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/callback_compatability.rb +33 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/geometry.rb +115 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/interpolations.rb +108 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/iostream.rb +58 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/matchers.rb +4 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/matchers/have_attached_file_matcher.rb +49 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +66 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +48 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/matchers/validate_attachment_size_matcher.rb +83 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/processor.rb +49 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/storage.rb +243 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/thumbnail.rb +73 -0
- data/vendor/gems/paperclip-2.3.1.1/lib/paperclip/upfile.rb +49 -0
- data/vendor/gems/paperclip-2.3.1.1/shoulda_macros/paperclip.rb +117 -0
- data/vendor/gems/paperclip-2.3.1.1/tasks/paperclip_tasks.rake +79 -0
- data/vendor/gems/paperclip-2.3.1.1/test/attachment_test.rb +780 -0
- data/vendor/gems/paperclip-2.3.1.1/test/database.yml +4 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/12k.png +0 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/50x50.png +0 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/5k.png +0 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/bad.png +1 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/s3.yml +8 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/text.txt +0 -0
- data/vendor/gems/paperclip-2.3.1.1/test/fixtures/twopage.pdf +0 -0
- data/vendor/gems/paperclip-2.3.1.1/test/geometry_test.rb +177 -0
- data/vendor/gems/paperclip-2.3.1.1/test/helper.rb +108 -0
- data/vendor/gems/paperclip-2.3.1.1/test/integration_test.rb +483 -0
- data/vendor/gems/paperclip-2.3.1.1/test/interpolations_test.rb +124 -0
- data/vendor/gems/paperclip-2.3.1.1/test/iostream_test.rb +71 -0
- data/vendor/gems/paperclip-2.3.1.1/test/matchers/have_attached_file_matcher_test.rb +21 -0
- data/vendor/gems/paperclip-2.3.1.1/test/matchers/validate_attachment_content_type_matcher_test.rb +30 -0
- data/vendor/gems/paperclip-2.3.1.1/test/matchers/validate_attachment_presence_matcher_test.rb +21 -0
- data/vendor/gems/paperclip-2.3.1.1/test/matchers/validate_attachment_size_matcher_test.rb +50 -0
- data/vendor/gems/paperclip-2.3.1.1/test/paperclip_test.rb +327 -0
- data/vendor/gems/paperclip-2.3.1.1/test/processor_test.rb +10 -0
- data/vendor/gems/paperclip-2.3.1.1/test/storage_test.rb +303 -0
- data/vendor/gems/paperclip-2.3.1.1/test/thumbnail_test.rb +227 -0
- data/vendor/gems/paperclip-2.3.1.1/test/upfile_test.rb +28 -0
- data/vendor/gems/shoulda-2.10.2/.specification +224 -0
- data/vendor/gems/shoulda-2.10.2/CONTRIBUTION_GUIDELINES.rdoc +10 -0
- data/vendor/gems/shoulda-2.10.2/MIT-LICENSE +22 -0
- data/vendor/gems/shoulda-2.10.2/README.rdoc +171 -0
- data/vendor/gems/shoulda-2.10.2/Rakefile +72 -0
- data/vendor/gems/shoulda-2.10.2/bin/convert_to_should_syntax +42 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda.rb +9 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller.rb +26 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/macros.rb +240 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers.rb +37 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/assign_to_matcher.rb +109 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/filter_param_matcher.rb +57 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb +81 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb +74 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/respond_with_matcher.rb +81 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/route_matcher.rb +93 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/set_session_matcher.rb +87 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_controller/matchers/set_the_flash_matcher.rb +85 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_mailer.rb +10 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_mailer/assertions.rb +38 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_view.rb +10 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/action_view/macros.rb +61 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record.rb +16 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/assertions.rb +69 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/helpers.rb +27 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/macros.rb +512 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers.rb +43 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb +83 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/allow_value_matcher.rb +102 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/association_matcher.rb +226 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb +87 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb +141 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/have_db_column_matcher.rb +169 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/have_db_index_matcher.rb +112 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/have_named_scope_matcher.rb +128 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb +59 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb +41 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validate_format_of_matcher.rb +67 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb +39 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb +60 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb +148 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/active_record/matchers/validation_matcher.rb +57 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/assertions.rb +71 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/autoload_macros.rb +46 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/context.rb +402 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/helpers.rb +8 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/macros.rb +133 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/private_helpers.rb +13 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/proc_extensions.rb +14 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/rails.rb +13 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/rspec.rb +11 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/tasks.rb +3 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/tasks/list_tests.rake +29 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/tasks/yaml_to_shoulda.rake +28 -0
- data/vendor/gems/shoulda-2.10.2/lib/shoulda/test_unit.rb +22 -0
- data/vendor/gems/shoulda-2.10.2/rails/init.rb +7 -0
- data/vendor/gems/shoulda-2.10.2/test/README +36 -0
- data/vendor/gems/shoulda-2.10.2/test/fail_macros.rb +39 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/addresses.yml +3 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/friendships.yml +0 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/posts.yml +5 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/products.yml +0 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/taggings.yml +0 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/tags.yml +9 -0
- data/vendor/gems/shoulda-2.10.2/test/fixtures/users.yml +6 -0
- data/vendor/gems/shoulda-2.10.2/test/functional/posts_controller_test.rb +121 -0
- data/vendor/gems/shoulda-2.10.2/test/functional/users_controller_test.rb +19 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/allow_mass_assignment_of_matcher_test.rb +68 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/allow_value_matcher_test.rb +64 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/association_matcher_test.rb +263 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/ensure_inclusion_of_matcher_test.rb +80 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/ensure_length_of_matcher_test.rb +158 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/have_db_column_matcher_test.rb +169 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/have_db_index_matcher_test.rb +91 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/have_named_scope_matcher_test.rb +65 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/have_readonly_attributes_matcher_test.rb +29 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/validate_acceptance_of_matcher_test.rb +44 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/validate_format_of_matcher_test.rb +39 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/validate_numericality_of_matcher_test.rb +52 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/validate_presence_of_matcher_test.rb +86 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/active_record/validate_uniqueness_of_matcher_test.rb +147 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/assign_to_matcher_test.rb +35 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/filter_param_matcher_test.rb +32 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/render_with_layout_matcher_test.rb +33 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/respond_with_content_type_matcher_test.rb +32 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/respond_with_matcher_test.rb +106 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/route_matcher_test.rb +58 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/set_session_matcher_test.rb +38 -0
- data/vendor/gems/shoulda-2.10.2/test/matchers/controller/set_the_flash_matcher.rb +41 -0
- data/vendor/gems/shoulda-2.10.2/test/model_builder.rb +106 -0
- data/vendor/gems/shoulda-2.10.2/test/other/autoload_macro_test.rb +18 -0
- data/vendor/gems/shoulda-2.10.2/test/other/context_test.rb +189 -0
- data/vendor/gems/shoulda-2.10.2/test/other/convert_to_should_syntax_test.rb +63 -0
- data/vendor/gems/shoulda-2.10.2/test/other/helpers_test.rb +340 -0
- data/vendor/gems/shoulda-2.10.2/test/other/private_helpers_test.rb +32 -0
- data/vendor/gems/shoulda-2.10.2/test/other/should_test.rb +271 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/controllers/application_controller.rb +25 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/controllers/posts_controller.rb +87 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/controllers/users_controller.rb +84 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/helpers/posts_helper.rb +2 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/helpers/users_helper.rb +2 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/address.rb +7 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/flea.rb +3 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/friendship.rb +4 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/pets/cat.rb +7 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/pets/dog.rb +10 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/post.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/product.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/profile.rb +2 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/registration.rb +2 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/tag.rb +8 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/tagging.rb +4 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/treat.rb +3 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/models/user.rb +32 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/layouts/posts.rhtml +19 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/layouts/users.rhtml +17 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/layouts/wide.html.erb +1 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/posts/edit.rhtml +27 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/posts/index.rhtml +25 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/posts/new.rhtml +26 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/posts/show.rhtml +18 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/users/edit.rhtml +22 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/users/index.rhtml +22 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/users/new.rhtml +21 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/app/views/users/show.rhtml +13 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/boot.rb +110 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/database.yml +4 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/environment.rb +18 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/environments/test.rb +0 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/initializers/new_rails_defaults.rb +15 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/initializers/shoulda.rb +8 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/config/routes.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/001_create_users.rb +19 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/002_create_posts.rb +13 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/003_create_taggings.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/004_create_tags.rb +11 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/005_create_dogs.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/006_create_addresses.rb +14 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/007_create_fleas.rb +11 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/008_create_dogs_fleas.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/009_create_products.rb +17 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/010_create_friendships.rb +14 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/011_create_treats.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/20090506203502_create_profiles.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/20090506203536_create_registrations.rb +14 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/migrate/20090513104502_create_cats.rb +12 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/db/schema.rb +0 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/public/404.html +30 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/public/422.html +30 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/public/500.html +30 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/script/console +3 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/script/generate +3 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/test/shoulda_macros/custom_macro.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/rspec_test.rb +207 -0
- data/vendor/gems/shoulda-2.10.2/test/test_helper.rb +28 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/address_test.rb +10 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/cat_test.rb +7 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/dog_test.rb +9 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/flea_test.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/friendship_test.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/post_test.rb +19 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/product_test.rb +23 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/tag_test.rb +15 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/tagging_test.rb +6 -0
- data/vendor/gems/shoulda-2.10.2/test/unit/user_test.rb +80 -0
- data/vendor/plugins/active_scaffold/.autotest +27 -0
- data/vendor/plugins/active_scaffold/CHANGELOG +152 -0
- data/vendor/plugins/active_scaffold/MIT-LICENSE +20 -0
- data/vendor/plugins/active_scaffold/README +31 -0
- data/vendor/plugins/active_scaffold/Rakefile +24 -0
- data/vendor/plugins/active_scaffold/environment.rb +17 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/add.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_down.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_up.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/close.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/cross.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator-small.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/magnifier.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +434 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +867 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +117 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/rico_corner.js +370 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +35 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +822 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +40 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +51 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form_on_list.html.erb +38 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +45 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +18 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +42 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +12 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_messages.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +19 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_header.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_record.html.erb +29 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +37 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +22 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +32 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +14 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +30 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +36 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +23 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_messages.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +44 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +12 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +55 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform.html.erb +12 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform_record.html.erb +31 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +16 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing_form.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/create.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +14 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/field_search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +48 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +25 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/render_field.js.rjs +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/show.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +12 -0
- data/vendor/plugins/active_scaffold/init.rb +18 -0
- data/vendor/plugins/active_scaffold/install.rb +39 -0
- data/vendor/plugins/active_scaffold/install_assets.rb +36 -0
- data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +128 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +213 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +158 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +58 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +95 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +57 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +217 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +50 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +54 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +126 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +192 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +45 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +230 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +25 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +53 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +134 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +34 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +36 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +36 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +29 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +181 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +97 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +140 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb +47 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb +45 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +311 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +75 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/error_message.rb +24 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +62 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +159 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +216 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +41 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +347 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +301 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +129 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +234 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +39 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +172 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +202 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/de.rb +67 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +67 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +65 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/fr.rb +65 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +62 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ja.yml +63 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ru.yml +61 -0
- data/vendor/plugins/active_scaffold/lib/bridges/bridge.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/bridge.rb +11 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +86 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/bridge.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb +51 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/mock_model.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/test_helper.rb +15 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/lib/tiny_mce_bridge.rb +45 -0
- data/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb +54 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +88 -0
- data/vendor/plugins/active_scaffold/lib/extensions/array.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/component_response_with_namespacing.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +33 -0
- data/vendor/plugins/active_scaffold/lib/extensions/localize.rb +10 -0
- data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +27 -0
- data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +56 -0
- data/vendor/plugins/active_scaffold/lib/extensions/to_label.rb +8 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +61 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/usa_state.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/paginator.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +68 -0
- data/vendor/plugins/active_scaffold/public/blank.html +33 -0
- data/vendor/plugins/active_scaffold/uninstall.rb +13 -0
- data/vendor/plugins/asset_packager/CHANGELOG +122 -0
- data/vendor/plugins/asset_packager/README +178 -0
- data/vendor/plugins/asset_packager/Rakefile +22 -0
- data/vendor/plugins/asset_packager/about.yml +8 -0
- data/vendor/plugins/asset_packager/init.rb +3 -0
- data/vendor/plugins/asset_packager/install.rb +1 -0
- data/vendor/plugins/asset_packager/lib/jsmin.rb +211 -0
- data/vendor/plugins/asset_packager/lib/synthesis/asset_package.rb +210 -0
- data/vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb +39 -0
- data/vendor/plugins/asset_packager/lib/tasks/asset_packager_tasks.rake +23 -0
- data/vendor/plugins/asset_packager/test/asset_package_helper_development_test.rb +102 -0
- data/vendor/plugins/asset_packager/test/asset_package_helper_production_test.rb +142 -0
- data/vendor/plugins/asset_packager/test/asset_packager_test.rb +91 -0
- data/vendor/plugins/asset_packager/test/asset_packages.yml +20 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/application.js +2 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/bar.js +4 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/controls.js +815 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/dragdrop.js +913 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/effects.js +958 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/foo.js +4 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/prototype.js +2006 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/bar.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/foo.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/header.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/screen.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/subdir/bar.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/subdir/foo.css +16 -0
- data/vendor/plugins/exception_notification/README +111 -0
- data/vendor/plugins/exception_notification/init.rb +1 -0
- data/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
- data/vendor/plugins/exception_notification/lib/exception_notifier.rb +66 -0
- data/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +78 -0
- data/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
- data/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +4 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
- data/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
- data/vendor/plugins/required_attributes/MIT-LICENSE +20 -0
- data/vendor/plugins/required_attributes/README +13 -0
- data/vendor/plugins/required_attributes/Rakefile +22 -0
- data/vendor/plugins/required_attributes/init.rb +1 -0
- data/vendor/plugins/required_attributes/install.rb +1 -0
- data/vendor/plugins/required_attributes/lib/required_attributes.rb +68 -0
- data/vendor/plugins/required_attributes/required_attributes/MIT-LICENSE +20 -0
- data/vendor/plugins/required_attributes/required_attributes/README +13 -0
- data/vendor/plugins/required_attributes/required_attributes/Rakefile +22 -0
- data/vendor/plugins/required_attributes/required_attributes/init.rb +1 -0
- data/vendor/plugins/required_attributes/required_attributes/install.rb +1 -0
- data/vendor/plugins/required_attributes/required_attributes/lib/required_attributes.rb +68 -0
- data/vendor/plugins/required_attributes/required_attributes/tasks/required_attributes_tasks.rake +4 -0
- data/vendor/plugins/required_attributes/required_attributes/uninstall.rb +1 -0
- data/vendor/plugins/required_attributes/tasks/required_attributes_tasks.rake +4 -0
- data/vendor/plugins/required_attributes/uninstall.rb +1 -0
- metadata +771 -51
@@ -0,0 +1,27 @@
|
|
1
|
+
class PaperclipGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_accessor :attachments, :migration_name
|
3
|
+
|
4
|
+
def initialize(args, options = {})
|
5
|
+
super
|
6
|
+
@class_name, @attachments = args[0], args[1..-1]
|
7
|
+
end
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
file_name = generate_file_name
|
11
|
+
@migration_name = file_name.camelize
|
12
|
+
record do |m|
|
13
|
+
m.migration_template "paperclip_migration.rb.erb",
|
14
|
+
File.join('db', 'migrate'),
|
15
|
+
:migration_file_name => file_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def generate_file_name
|
22
|
+
names = attachments.map{|a| a.underscore }
|
23
|
+
names = names[0..-2] + ["and", names[-1]] if names.length > 1
|
24
|
+
"add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
<% attachments.each do |attachment| -%>
|
4
|
+
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
|
5
|
+
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
|
6
|
+
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
|
7
|
+
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
|
8
|
+
<% end -%>
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
<% attachments.each do |attachment| -%>
|
13
|
+
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
|
14
|
+
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
|
15
|
+
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
|
16
|
+
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
|
17
|
+
<% end -%>
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "lib", "paperclip")
|
@@ -0,0 +1,353 @@
|
|
1
|
+
# Paperclip allows file attachments that are stored in the filesystem. All graphical
|
2
|
+
# transformations are done using the Graphics/ImageMagick command line utilities and
|
3
|
+
# are stored in Tempfiles until the record is saved. Paperclip does not require a
|
4
|
+
# separate model for storing the attachment's information, instead adding a few simple
|
5
|
+
# columns to your table.
|
6
|
+
#
|
7
|
+
# Author:: Jon Yurek
|
8
|
+
# Copyright:: Copyright (c) 2008-2009 thoughtbot, inc.
|
9
|
+
# License:: MIT License (http://www.opensource.org/licenses/mit-license.php)
|
10
|
+
#
|
11
|
+
# Paperclip defines an attachment as any file, though it makes special considerations
|
12
|
+
# for image files. You can declare that a model has an attached file with the
|
13
|
+
# +has_attached_file+ method:
|
14
|
+
#
|
15
|
+
# class User < ActiveRecord::Base
|
16
|
+
# has_attached_file :avatar, :styles => { :thumb => "100x100" }
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# user = User.new
|
20
|
+
# user.avatar = params[:user][:avatar]
|
21
|
+
# user.avatar.url
|
22
|
+
# # => "/users/avatars/4/original_me.jpg"
|
23
|
+
# user.avatar.url(:thumb)
|
24
|
+
# # => "/users/avatars/4/thumb_me.jpg"
|
25
|
+
#
|
26
|
+
# See the +has_attached_file+ documentation for more details.
|
27
|
+
|
28
|
+
require 'erb'
|
29
|
+
require 'tempfile'
|
30
|
+
require 'paperclip/upfile'
|
31
|
+
require 'paperclip/iostream'
|
32
|
+
require 'paperclip/geometry'
|
33
|
+
require 'paperclip/processor'
|
34
|
+
require 'paperclip/thumbnail'
|
35
|
+
require 'paperclip/storage'
|
36
|
+
require 'paperclip/interpolations'
|
37
|
+
require 'paperclip/attachment'
|
38
|
+
if defined? RAILS_ROOT
|
39
|
+
Dir.glob(File.join(File.expand_path(RAILS_ROOT), "lib", "paperclip_processors", "*.rb")).each do |processor|
|
40
|
+
require processor
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# The base module that gets included in ActiveRecord::Base. See the
|
45
|
+
# documentation for Paperclip::ClassMethods for more useful information.
|
46
|
+
module Paperclip
|
47
|
+
|
48
|
+
VERSION = "2.3.1.1"
|
49
|
+
|
50
|
+
class << self
|
51
|
+
# Provides configurability to Paperclip. There are a number of options available, such as:
|
52
|
+
# * whiny: Will raise an error if Paperclip cannot process thumbnails of
|
53
|
+
# an uploaded image. Defaults to true.
|
54
|
+
# * log: Logs progress to the Rails log. Uses ActiveRecord's logger, so honors
|
55
|
+
# log levels, etc. Defaults to true.
|
56
|
+
# * command_path: Defines the path at which to find the command line
|
57
|
+
# programs if they are not visible to Rails the system's search path. Defaults to
|
58
|
+
# nil, which uses the first executable found in the user's search path.
|
59
|
+
# * image_magick_path: Deprecated alias of command_path.
|
60
|
+
def options
|
61
|
+
@options ||= {
|
62
|
+
:whiny => true,
|
63
|
+
:image_magick_path => nil,
|
64
|
+
:command_path => nil,
|
65
|
+
:log => true,
|
66
|
+
:log_command => false,
|
67
|
+
:swallow_stderr => true
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def path_for_command command #:nodoc:
|
72
|
+
if options[:image_magick_path]
|
73
|
+
warn("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead")
|
74
|
+
end
|
75
|
+
path = [options[:command_path] || options[:image_magick_path], command].compact
|
76
|
+
File.join(*path)
|
77
|
+
end
|
78
|
+
|
79
|
+
def interpolates key, &block
|
80
|
+
Paperclip::Interpolations[key] = block
|
81
|
+
end
|
82
|
+
|
83
|
+
# The run method takes a command to execute and a string of parameters
|
84
|
+
# that get passed to it. The command is prefixed with the :command_path
|
85
|
+
# option from Paperclip.options. If you have many commands to run and
|
86
|
+
# they are in different paths, the suggested course of action is to
|
87
|
+
# symlink them so they are all in the same directory.
|
88
|
+
#
|
89
|
+
# If the command returns with a result code that is not one of the
|
90
|
+
# expected_outcodes, a PaperclipCommandLineError will be raised. Generally
|
91
|
+
# a code of 0 is expected, but a list of codes may be passed if necessary.
|
92
|
+
#
|
93
|
+
# This method can log the command being run when
|
94
|
+
# Paperclip.options[:log_command] is set to true (defaults to false). This
|
95
|
+
# will only log if logging in general is set to true as well.
|
96
|
+
def run cmd, params = "", expected_outcodes = 0
|
97
|
+
command = %Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")
|
98
|
+
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
|
99
|
+
Paperclip.log(command) if Paperclip.options[:log_command]
|
100
|
+
output = `#{command}`
|
101
|
+
unless [expected_outcodes].flatten.include?($?.exitstatus)
|
102
|
+
raise PaperclipCommandLineError, "Error while running #{cmd}"
|
103
|
+
end
|
104
|
+
output
|
105
|
+
end
|
106
|
+
|
107
|
+
def bit_bucket #:nodoc:
|
108
|
+
File.exists?("/dev/null") ? "/dev/null" : "NUL"
|
109
|
+
end
|
110
|
+
|
111
|
+
def included base #:nodoc:
|
112
|
+
base.extend ClassMethods
|
113
|
+
unless base.respond_to?(:define_callbacks)
|
114
|
+
base.send(:include, Paperclip::CallbackCompatability)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def processor name #:nodoc:
|
119
|
+
name = name.to_s.camelize
|
120
|
+
processor = Paperclip.const_get(name)
|
121
|
+
unless processor.ancestors.include?(Paperclip::Processor)
|
122
|
+
raise PaperclipError.new("Processor #{name} was not found")
|
123
|
+
end
|
124
|
+
processor
|
125
|
+
end
|
126
|
+
|
127
|
+
# Log a paperclip-specific line. Uses ActiveRecord::Base.logger
|
128
|
+
# by default. Set Paperclip.options[:log] to false to turn off.
|
129
|
+
def log message
|
130
|
+
logger.info("[paperclip] #{message}") if logging?
|
131
|
+
end
|
132
|
+
|
133
|
+
def logger #:nodoc:
|
134
|
+
ActiveRecord::Base.logger
|
135
|
+
end
|
136
|
+
|
137
|
+
def logging? #:nodoc:
|
138
|
+
options[:log]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class PaperclipError < StandardError #:nodoc:
|
143
|
+
end
|
144
|
+
|
145
|
+
class PaperclipCommandLineError < StandardError #:nodoc:
|
146
|
+
end
|
147
|
+
|
148
|
+
class NotIdentifiedByImageMagickError < PaperclipError #:nodoc:
|
149
|
+
end
|
150
|
+
|
151
|
+
class InfiniteInterpolationError < PaperclipError #:nodoc:
|
152
|
+
end
|
153
|
+
|
154
|
+
module ClassMethods
|
155
|
+
# +has_attached_file+ gives the class it is called on an attribute that maps to a file. This
|
156
|
+
# is typically a file stored somewhere on the filesystem and has been uploaded by a user.
|
157
|
+
# The attribute returns a Paperclip::Attachment object which handles the management of
|
158
|
+
# that file. The intent is to make the attachment as much like a normal attribute. The
|
159
|
+
# thumbnails will be created when the new file is assigned, but they will *not* be saved
|
160
|
+
# until +save+ is called on the record. Likewise, if the attribute is set to +nil+ is
|
161
|
+
# called on it, the attachment will *not* be deleted until +save+ is called. See the
|
162
|
+
# Paperclip::Attachment documentation for more specifics. There are a number of options
|
163
|
+
# you can set to change the behavior of a Paperclip attachment:
|
164
|
+
# * +url+: The full URL of where the attachment is publically accessible. This can just
|
165
|
+
# as easily point to a directory served directly through Apache as it can to an action
|
166
|
+
# that can control permissions. You can specify the full domain and path, but usually
|
167
|
+
# just an absolute path is sufficient. The leading slash *must* be included manually for
|
168
|
+
# absolute paths. The default value is
|
169
|
+
# "/system/:attachment/:id/:style/:filename". See
|
170
|
+
# Paperclip::Attachment#interpolate for more information on variable interpolaton.
|
171
|
+
# :url => "/:class/:attachment/:id/:style_:filename"
|
172
|
+
# :url => "http://some.other.host/stuff/:class/:id_:extension"
|
173
|
+
# * +default_url+: The URL that will be returned if there is no attachment assigned.
|
174
|
+
# This field is interpolated just as the url is. The default value is
|
175
|
+
# "/:attachment/:style/missing.png"
|
176
|
+
# has_attached_file :avatar, :default_url => "/images/default_:style_avatar.png"
|
177
|
+
# User.new.avatar_url(:small) # => "/images/default_small_avatar.png"
|
178
|
+
# * +styles+: A hash of thumbnail styles and their geometries. You can find more about
|
179
|
+
# geometry strings at the ImageMagick website
|
180
|
+
# (http://www.imagemagick.org/script/command-line-options.php#resize). Paperclip
|
181
|
+
# also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally
|
182
|
+
# inside the dimensions and then crop the rest off (weighted at the center). The
|
183
|
+
# default value is to generate no thumbnails.
|
184
|
+
# * +default_style+: The thumbnail style that will be used by default URLs.
|
185
|
+
# Defaults to +original+.
|
186
|
+
# has_attached_file :avatar, :styles => { :normal => "100x100#" },
|
187
|
+
# :default_style => :normal
|
188
|
+
# user.avatar.url # => "/avatars/23/normal_me.png"
|
189
|
+
# * +whiny+: Will raise an error if Paperclip cannot post_process an uploaded file due
|
190
|
+
# to a command line error. This will override the global setting for this attachment.
|
191
|
+
# Defaults to true. This option used to be called :whiny_thumbanils, but this is
|
192
|
+
# deprecated.
|
193
|
+
# * +convert_options+: When creating thumbnails, use this free-form options
|
194
|
+
# field to pass in various convert command options. Typical options are "-strip" to
|
195
|
+
# remove all Exif data from the image (save space for thumbnails and avatars) or
|
196
|
+
# "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick
|
197
|
+
# convert documentation for more options: (http://www.imagemagick.org/script/convert.php)
|
198
|
+
# Note that this option takes a hash of options, each of which correspond to the style
|
199
|
+
# of thumbnail being generated. You can also specify :all as a key, which will apply
|
200
|
+
# to all of the thumbnails being generated. If you specify options for the :original,
|
201
|
+
# it would be best if you did not specify destructive options, as the intent of keeping
|
202
|
+
# the original around is to regenerate all the thumbnails when requirements change.
|
203
|
+
# has_attached_file :avatar, :styles => { :large => "300x300", :negative => "100x100" }
|
204
|
+
# :convert_options => {
|
205
|
+
# :all => "-strip",
|
206
|
+
# :negative => "-negate"
|
207
|
+
# }
|
208
|
+
# NOTE: While not deprecated yet, it is not recommended to specify options this way.
|
209
|
+
# It is recommended that :convert_options option be included in the hash passed to each
|
210
|
+
# :styles for compatability with future versions.
|
211
|
+
# * +storage+: Chooses the storage backend where the files will be stored. The current
|
212
|
+
# choices are :filesystem and :s3. The default is :filesystem. Make sure you read the
|
213
|
+
# documentation for Paperclip::Storage::Filesystem and Paperclip::Storage::S3
|
214
|
+
# for backend-specific options.
|
215
|
+
def has_attached_file name, options = {}
|
216
|
+
include InstanceMethods
|
217
|
+
|
218
|
+
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
|
219
|
+
attachment_definitions[name] = {:validations => []}.merge(options)
|
220
|
+
|
221
|
+
after_save :save_attached_files
|
222
|
+
before_destroy :destroy_attached_files
|
223
|
+
|
224
|
+
define_callbacks :before_post_process, :after_post_process
|
225
|
+
define_callbacks :"before_#{name}_post_process", :"after_#{name}_post_process"
|
226
|
+
|
227
|
+
define_method name do |*args|
|
228
|
+
a = attachment_for(name)
|
229
|
+
(args.length > 0) ? a.to_s(args.first) : a
|
230
|
+
end
|
231
|
+
|
232
|
+
define_method "#{name}=" do |file|
|
233
|
+
attachment_for(name).assign(file)
|
234
|
+
end
|
235
|
+
|
236
|
+
define_method "#{name}?" do
|
237
|
+
attachment_for(name).file?
|
238
|
+
end
|
239
|
+
|
240
|
+
validates_each(name) do |record, attr, value|
|
241
|
+
attachment = record.attachment_for(name)
|
242
|
+
attachment.send(:flush_errors) unless attachment.valid?
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# Places ActiveRecord-style validations on the size of the file assigned. The
|
247
|
+
# possible options are:
|
248
|
+
# * +in+: a Range of bytes (i.e. +1..1.megabyte+),
|
249
|
+
# * +less_than+: equivalent to :in => 0..options[:less_than]
|
250
|
+
# * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
|
251
|
+
# * +message+: error message to display, use :min and :max as replacements
|
252
|
+
# * +if+: A lambda or name of a method on the instance. Validation will only
|
253
|
+
# be run is this lambda or method returns true.
|
254
|
+
# * +unless+: Same as +if+ but validates if lambda or method returns false.
|
255
|
+
def validates_attachment_size name, options = {}
|
256
|
+
min = options[:greater_than] || (options[:in] && options[:in].first) || 0
|
257
|
+
max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0)
|
258
|
+
range = (min..max)
|
259
|
+
message = options[:message] || "file size must be between :min and :max bytes."
|
260
|
+
|
261
|
+
attachment_definitions[name][:validations] << [:size, {:min => min,
|
262
|
+
:max => max,
|
263
|
+
:range => range,
|
264
|
+
:message => message,
|
265
|
+
:if => options[:if],
|
266
|
+
:unless => options[:unless]}]
|
267
|
+
end
|
268
|
+
|
269
|
+
# Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
|
270
|
+
def validates_attachment_thumbnails name, options = {}
|
271
|
+
warn('[DEPRECATION] validates_attachment_thumbnail is deprecated. ' +
|
272
|
+
'This validation is on by default and will be removed from future versions. ' +
|
273
|
+
'If you wish to turn it off, supply :whiny => false in your definition.')
|
274
|
+
attachment_definitions[name][:whiny_thumbnails] = true
|
275
|
+
end
|
276
|
+
|
277
|
+
# Places ActiveRecord-style validations on the presence of a file.
|
278
|
+
# Options:
|
279
|
+
# * +if+: A lambda or name of a method on the instance. Validation will only
|
280
|
+
# be run is this lambda or method returns true.
|
281
|
+
# * +unless+: Same as +if+ but validates if lambda or method returns false.
|
282
|
+
def validates_attachment_presence name, options = {}
|
283
|
+
message = options[:message] || "must be set."
|
284
|
+
attachment_definitions[name][:validations] << [:presence, {:message => message,
|
285
|
+
:if => options[:if],
|
286
|
+
:unless => options[:unless]}]
|
287
|
+
end
|
288
|
+
|
289
|
+
# Places ActiveRecord-style validations on the content type of the file
|
290
|
+
# assigned. The possible options are:
|
291
|
+
# * +content_type+: Allowed content types. Can be a single content type
|
292
|
+
# or an array. Each type can be a String or a Regexp. It should be
|
293
|
+
# noted that Internet Explorer upload files with content_types that you
|
294
|
+
# may not expect. For example, JPEG images are given image/pjpeg and
|
295
|
+
# PNGs are image/x-png, so keep that in mind when determining how you
|
296
|
+
# match. Allows all by default.
|
297
|
+
# * +message+: The message to display when the uploaded file has an invalid
|
298
|
+
# content type.
|
299
|
+
# * +if+: A lambda or name of a method on the instance. Validation will only
|
300
|
+
# be run is this lambda or method returns true.
|
301
|
+
# * +unless+: Same as +if+ but validates if lambda or method returns false.
|
302
|
+
# NOTE: If you do not specify an [attachment]_content_type field on your
|
303
|
+
# model, content_type validation will work _ONLY upon assignment_ and
|
304
|
+
# re-validation after the instance has been reloaded will always succeed.
|
305
|
+
def validates_attachment_content_type name, options = {}
|
306
|
+
attachment_definitions[name][:validations] << [:content_type, {:content_type => options[:content_type],
|
307
|
+
:message => options[:message],
|
308
|
+
:if => options[:if],
|
309
|
+
:unless => options[:unless]}]
|
310
|
+
end
|
311
|
+
|
312
|
+
# Returns the attachment definitions defined by each call to
|
313
|
+
# has_attached_file.
|
314
|
+
def attachment_definitions
|
315
|
+
read_inheritable_attribute(:attachment_definitions)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
module InstanceMethods #:nodoc:
|
320
|
+
def attachment_for name
|
321
|
+
@_paperclip_attachments ||= {}
|
322
|
+
@_paperclip_attachments[name] ||= Attachment.new(name, self, self.class.attachment_definitions[name])
|
323
|
+
end
|
324
|
+
|
325
|
+
def each_attachment
|
326
|
+
self.class.attachment_definitions.each do |name, definition|
|
327
|
+
yield(name, attachment_for(name))
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def save_attached_files
|
332
|
+
logger.info("[paperclip] Saving attachments.")
|
333
|
+
each_attachment do |name, attachment|
|
334
|
+
attachment.send(:save)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def destroy_attached_files
|
339
|
+
logger.info("[paperclip] Deleting attachments.")
|
340
|
+
each_attachment do |name, attachment|
|
341
|
+
attachment.send(:queue_existing_for_delete)
|
342
|
+
attachment.send(:flush_deletes)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
# Set it all up.
|
350
|
+
if Object.const_defined?("ActiveRecord")
|
351
|
+
ActiveRecord::Base.send(:include, Paperclip)
|
352
|
+
File.send(:include, Paperclip::Upfile)
|
353
|
+
end
|
@@ -0,0 +1,414 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Paperclip
|
3
|
+
# The Attachment class manages the files for a given attachment. It saves
|
4
|
+
# when the model saves, deletes when the model is destroyed, and processes
|
5
|
+
# the file upon assignment.
|
6
|
+
class Attachment
|
7
|
+
|
8
|
+
def self.default_options
|
9
|
+
@default_options ||= {
|
10
|
+
:url => "/system/:attachment/:id/:style/:filename",
|
11
|
+
:path => ":rails_root/public:url",
|
12
|
+
:styles => {},
|
13
|
+
:default_url => "/:attachment/:style/missing.png",
|
14
|
+
:default_style => :original,
|
15
|
+
:validations => [],
|
16
|
+
:storage => :filesystem,
|
17
|
+
:whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :name, :instance, :styles, :default_style, :convert_options, :queued_for_write, :options
|
22
|
+
|
23
|
+
# Creates an Attachment object. +name+ is the name of the attachment,
|
24
|
+
# +instance+ is the ActiveRecord object instance it's attached to, and
|
25
|
+
# +options+ is the same as the hash passed to +has_attached_file+.
|
26
|
+
def initialize name, instance, options = {}
|
27
|
+
@name = name
|
28
|
+
@instance = instance
|
29
|
+
|
30
|
+
options = self.class.default_options.merge(options)
|
31
|
+
|
32
|
+
@url = options[:url]
|
33
|
+
@url = @url.call(self) if @url.is_a?(Proc)
|
34
|
+
@path = options[:path]
|
35
|
+
@path = @path.call(self) if @path.is_a?(Proc)
|
36
|
+
@styles = options[:styles]
|
37
|
+
@styles = @styles.call(self) if @styles.is_a?(Proc)
|
38
|
+
@default_url = options[:default_url]
|
39
|
+
@validations = options[:validations]
|
40
|
+
@default_style = options[:default_style]
|
41
|
+
@storage = options[:storage]
|
42
|
+
@whiny = options[:whiny_thumbnails] || options[:whiny]
|
43
|
+
@convert_options = options[:convert_options] || {}
|
44
|
+
@processors = options[:processors] || [:thumbnail]
|
45
|
+
@options = options
|
46
|
+
@queued_for_delete = []
|
47
|
+
@queued_for_write = {}
|
48
|
+
@errors = {}
|
49
|
+
@validation_errors = nil
|
50
|
+
@dirty = false
|
51
|
+
|
52
|
+
normalize_style_definition
|
53
|
+
initialize_storage
|
54
|
+
end
|
55
|
+
|
56
|
+
# What gets called when you call instance.attachment = File. It clears
|
57
|
+
# errors, assigns attributes, processes the file, and runs validations. It
|
58
|
+
# also queues up the previous file for deletion, to be flushed away on
|
59
|
+
# #save of its host. In addition to form uploads, you can also assign
|
60
|
+
# another Paperclip attachment:
|
61
|
+
# new_user.avatar = old_user.avatar
|
62
|
+
# If the file that is assigned is not valid, the processing (i.e.
|
63
|
+
# thumbnailing, etc) will NOT be run.
|
64
|
+
def assign uploaded_file
|
65
|
+
ensure_required_accessors!
|
66
|
+
|
67
|
+
if uploaded_file.is_a?(Paperclip::Attachment)
|
68
|
+
uploaded_file = uploaded_file.to_file(:original)
|
69
|
+
close_uploaded_file = uploaded_file.respond_to?(:close)
|
70
|
+
end
|
71
|
+
|
72
|
+
return nil unless valid_assignment?(uploaded_file)
|
73
|
+
|
74
|
+
uploaded_file.binmode if uploaded_file.respond_to? :binmode
|
75
|
+
self.clear
|
76
|
+
|
77
|
+
return nil if uploaded_file.nil?
|
78
|
+
|
79
|
+
@queued_for_write[:original] = uploaded_file.to_tempfile
|
80
|
+
instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
|
81
|
+
instance_write(:content_type, uploaded_file.content_type.to_s.strip)
|
82
|
+
instance_write(:file_size, uploaded_file.size.to_i)
|
83
|
+
instance_write(:updated_at, Time.now)
|
84
|
+
|
85
|
+
@dirty = true
|
86
|
+
|
87
|
+
post_process if valid?
|
88
|
+
|
89
|
+
# Reset the file size if the original file was reprocessed.
|
90
|
+
instance_write(:file_size, @queued_for_write[:original].size.to_i)
|
91
|
+
ensure
|
92
|
+
uploaded_file.close if close_uploaded_file
|
93
|
+
validate
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns the public URL of the attachment, with a given style. Note that
|
97
|
+
# this does not necessarily need to point to a file that your web server
|
98
|
+
# can access and can point to an action in your app, if you need fine
|
99
|
+
# grained security. This is not recommended if you don't need the
|
100
|
+
# security, however, for performance reasons. set
|
101
|
+
# include_updated_timestamp to false if you want to stop the attachment
|
102
|
+
# update time appended to the url
|
103
|
+
def url style = default_style, include_updated_timestamp = true
|
104
|
+
url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style)
|
105
|
+
include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns the path of the attachment as defined by the :path option. If the
|
109
|
+
# file is stored in the filesystem the path refers to the path of the file
|
110
|
+
# on disk. If the file is stored in S3, the path is the "key" part of the
|
111
|
+
# URL, and the :bucket option refers to the S3 bucket.
|
112
|
+
def path style = default_style
|
113
|
+
original_filename.nil? ? nil : interpolate(@path, style)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Alias to +url+
|
117
|
+
def to_s style = nil
|
118
|
+
url(style)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Returns true if there are no errors on this attachment.
|
122
|
+
def valid?
|
123
|
+
validate
|
124
|
+
errors.empty?
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns an array containing the errors on this attachment.
|
128
|
+
def errors
|
129
|
+
@errors
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns true if there are changes that need to be saved.
|
133
|
+
def dirty?
|
134
|
+
@dirty
|
135
|
+
end
|
136
|
+
|
137
|
+
# Saves the file, if there are no errors. If there are, it flushes them to
|
138
|
+
# the instance's errors and returns false, cancelling the save.
|
139
|
+
def save
|
140
|
+
if valid?
|
141
|
+
flush_deletes
|
142
|
+
flush_writes
|
143
|
+
@dirty = false
|
144
|
+
true
|
145
|
+
else
|
146
|
+
flush_errors
|
147
|
+
false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Clears out the attachment. Has the same effect as previously assigning
|
152
|
+
# nil to the attachment. Does NOT save. If you wish to clear AND save,
|
153
|
+
# use #destroy.
|
154
|
+
def clear
|
155
|
+
queue_existing_for_delete
|
156
|
+
@errors = {}
|
157
|
+
@validation_errors = nil
|
158
|
+
end
|
159
|
+
|
160
|
+
# Destroys the attachment. Has the same effect as previously assigning
|
161
|
+
# nil to the attachment *and saving*. This is permanent. If you wish to
|
162
|
+
# wipe out the existing attachment but not save, use #clear.
|
163
|
+
def destroy
|
164
|
+
clear
|
165
|
+
save
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns the name of the file as originally assigned, and lives in the
|
169
|
+
# <attachment>_file_name attribute of the model.
|
170
|
+
def original_filename
|
171
|
+
instance_read(:file_name)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the size of the file as originally assigned, and lives in the
|
175
|
+
# <attachment>_file_size attribute of the model.
|
176
|
+
def size
|
177
|
+
instance_read(:file_size) || (@queued_for_write[:original] && @queued_for_write[:original].size)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns the content_type of the file as originally assigned, and lives
|
181
|
+
# in the <attachment>_content_type attribute of the model.
|
182
|
+
def content_type
|
183
|
+
instance_read(:content_type)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the last modified time of the file as originally assigned, and
|
187
|
+
# lives in the <attachment>_updated_at attribute of the model.
|
188
|
+
def updated_at
|
189
|
+
time = instance_read(:updated_at)
|
190
|
+
time && time.to_f.to_i
|
191
|
+
end
|
192
|
+
|
193
|
+
# Paths and URLs can have a number of variables interpolated into them
|
194
|
+
# to vary the storage location based on name, id, style, class, etc.
|
195
|
+
# This method is a deprecated access into supplying and retrieving these
|
196
|
+
# interpolations. Future access should use either Paperclip.interpolates
|
197
|
+
# or extend the Paperclip::Interpolations module directly.
|
198
|
+
def self.interpolations
|
199
|
+
warn('[DEPRECATION] Paperclip::Attachment.interpolations is deprecated ' +
|
200
|
+
'and will be removed from future versions. ' +
|
201
|
+
'Use Paperclip.interpolates instead')
|
202
|
+
Paperclip::Interpolations
|
203
|
+
end
|
204
|
+
|
205
|
+
# This method really shouldn't be called that often. It's expected use is
|
206
|
+
# in the paperclip:refresh rake task and that's it. It will regenerate all
|
207
|
+
# thumbnails forcefully, by reobtaining the original file and going through
|
208
|
+
# the post-process again.
|
209
|
+
def reprocess!
|
210
|
+
new_original = Tempfile.new("paperclip-reprocess")
|
211
|
+
new_original.binmode
|
212
|
+
if old_original = to_file(:original)
|
213
|
+
new_original.write( old_original.read )
|
214
|
+
new_original.rewind
|
215
|
+
|
216
|
+
@queued_for_write = { :original => new_original }
|
217
|
+
post_process
|
218
|
+
|
219
|
+
old_original.close if old_original.respond_to?(:close)
|
220
|
+
|
221
|
+
save
|
222
|
+
else
|
223
|
+
true
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns true if a file has been assigned.
|
228
|
+
def file?
|
229
|
+
!original_filename.blank?
|
230
|
+
end
|
231
|
+
|
232
|
+
# Writes the attachment-specific attribute on the instance. For example,
|
233
|
+
# instance_write(:file_name, "me.jpg") will write "me.jpg" to the instance's
|
234
|
+
# "avatar_file_name" field (assuming the attachment is called avatar).
|
235
|
+
def instance_write(attr, value)
|
236
|
+
setter = :"#{name}_#{attr}="
|
237
|
+
responds = instance.respond_to?(setter)
|
238
|
+
self.instance_variable_set("@_#{setter.to_s.chop}", value)
|
239
|
+
instance.send(setter, value) if responds || attr.to_s == "file_name"
|
240
|
+
end
|
241
|
+
|
242
|
+
# Reads the attachment-specific attribute on the instance. See instance_write
|
243
|
+
# for more details.
|
244
|
+
def instance_read(attr)
|
245
|
+
getter = :"#{name}_#{attr}"
|
246
|
+
responds = instance.respond_to?(getter)
|
247
|
+
cached = self.instance_variable_get("@_#{getter}")
|
248
|
+
return cached if cached
|
249
|
+
instance.send(getter) if responds || attr.to_s == "file_name"
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
|
254
|
+
def ensure_required_accessors! #:nodoc:
|
255
|
+
%w(file_name).each do |field|
|
256
|
+
unless @instance.respond_to?("#{name}_#{field}") && @instance.respond_to?("#{name}_#{field}=")
|
257
|
+
raise PaperclipError.new("#{@instance.class} model missing required attr_accessor for '#{name}_#{field}'")
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def log message #:nodoc:
|
263
|
+
Paperclip.log(message)
|
264
|
+
end
|
265
|
+
|
266
|
+
def valid_assignment? file #:nodoc:
|
267
|
+
file.nil? || (file.respond_to?(:original_filename) && file.respond_to?(:content_type))
|
268
|
+
end
|
269
|
+
|
270
|
+
def validate #:nodoc:
|
271
|
+
unless @validation_errors
|
272
|
+
@validation_errors = @validations.inject({}) do |errors, validation|
|
273
|
+
name, options = validation
|
274
|
+
errors[name] = send(:"validate_#{name}", options) if allow_validation?(options)
|
275
|
+
errors
|
276
|
+
end
|
277
|
+
@validation_errors.reject!{|k,v| v == nil }
|
278
|
+
@errors.merge!(@validation_errors)
|
279
|
+
end
|
280
|
+
@validation_errors
|
281
|
+
end
|
282
|
+
|
283
|
+
def allow_validation? options #:nodoc:
|
284
|
+
(options[:if].nil? || check_guard(options[:if])) && (options[:unless].nil? || !check_guard(options[:unless]))
|
285
|
+
end
|
286
|
+
|
287
|
+
def check_guard guard #:nodoc:
|
288
|
+
if guard.respond_to? :call
|
289
|
+
guard.call(instance)
|
290
|
+
elsif ! guard.blank?
|
291
|
+
instance.send(guard.to_s)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def validate_size options #:nodoc:
|
296
|
+
if file? && !options[:range].include?(size.to_i)
|
297
|
+
options[:message].gsub(/:min/, options[:min].to_s).gsub(/:max/, options[:max].to_s)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def validate_presence options #:nodoc:
|
302
|
+
options[:message] unless file?
|
303
|
+
end
|
304
|
+
|
305
|
+
def validate_content_type options #:nodoc:
|
306
|
+
valid_types = [options[:content_type]].flatten
|
307
|
+
unless original_filename.blank?
|
308
|
+
unless valid_types.blank?
|
309
|
+
content_type = instance_read(:content_type)
|
310
|
+
unless valid_types.any?{|t| content_type.nil? || t === content_type }
|
311
|
+
options[:message] || "is not one of the allowed file types."
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
def normalize_style_definition #:nodoc:
|
318
|
+
@styles.each do |name, args|
|
319
|
+
unless args.is_a? Hash
|
320
|
+
dimensions, format = [args, nil].flatten[0..1]
|
321
|
+
format = nil if format.blank?
|
322
|
+
@styles[name] = {
|
323
|
+
:processors => @processors,
|
324
|
+
:geometry => dimensions,
|
325
|
+
:format => format,
|
326
|
+
:whiny => @whiny,
|
327
|
+
:convert_options => extra_options_for(name)
|
328
|
+
}
|
329
|
+
else
|
330
|
+
@styles[name] = {
|
331
|
+
:processors => @processors,
|
332
|
+
:whiny => @whiny,
|
333
|
+
:convert_options => extra_options_for(name)
|
334
|
+
}.merge(@styles[name])
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
def solidify_style_definitions #:nodoc:
|
340
|
+
@styles.each do |name, args|
|
341
|
+
@styles[name][:geometry] = @styles[name][:geometry].call(instance) if @styles[name][:geometry].respond_to?(:call)
|
342
|
+
@styles[name][:processors] = @styles[name][:processors].call(instance) if @styles[name][:processors].respond_to?(:call)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def initialize_storage #:nodoc:
|
347
|
+
@storage_module = Paperclip::Storage.const_get(@storage.to_s.capitalize)
|
348
|
+
self.extend(@storage_module)
|
349
|
+
end
|
350
|
+
|
351
|
+
def extra_options_for(style) #:nodoc:
|
352
|
+
all_options = convert_options[:all]
|
353
|
+
all_options = all_options.call(instance) if all_options.respond_to?(:call)
|
354
|
+
style_options = convert_options[style]
|
355
|
+
style_options = style_options.call(instance) if style_options.respond_to?(:call)
|
356
|
+
|
357
|
+
[ style_options, all_options ].compact.join(" ")
|
358
|
+
end
|
359
|
+
|
360
|
+
def post_process #:nodoc:
|
361
|
+
return if @queued_for_write[:original].nil?
|
362
|
+
solidify_style_definitions
|
363
|
+
return if fire_events(:before)
|
364
|
+
post_process_styles
|
365
|
+
return if fire_events(:after)
|
366
|
+
end
|
367
|
+
|
368
|
+
def fire_events(which) #:nodoc:
|
369
|
+
return true if callback(:"#{which}_post_process") == false
|
370
|
+
return true if callback(:"#{which}_#{name}_post_process") == false
|
371
|
+
end
|
372
|
+
|
373
|
+
def callback which #:nodoc:
|
374
|
+
instance.run_callbacks(which, @queued_for_write){|result, obj| result == false }
|
375
|
+
end
|
376
|
+
|
377
|
+
def post_process_styles #:nodoc:
|
378
|
+
@styles.each do |name, args|
|
379
|
+
begin
|
380
|
+
raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank?
|
381
|
+
@queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor|
|
382
|
+
Paperclip.processor(processor).make(file, args, self)
|
383
|
+
end
|
384
|
+
rescue PaperclipError => e
|
385
|
+
log("An error was received while processing: #{e.inspect}")
|
386
|
+
(@errors[:processing] ||= []) << e.message if @whiny
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
def interpolate pattern, style = default_style #:nodoc:
|
392
|
+
Paperclip::Interpolations.interpolate(pattern, self, style)
|
393
|
+
end
|
394
|
+
|
395
|
+
def queue_existing_for_delete #:nodoc:
|
396
|
+
return unless file?
|
397
|
+
@queued_for_delete += [:original, *@styles.keys].uniq.map do |style|
|
398
|
+
path(style) if exists?(style)
|
399
|
+
end.compact
|
400
|
+
instance_write(:file_name, nil)
|
401
|
+
instance_write(:content_type, nil)
|
402
|
+
instance_write(:file_size, nil)
|
403
|
+
instance_write(:updated_at, nil)
|
404
|
+
end
|
405
|
+
|
406
|
+
def flush_errors #:nodoc:
|
407
|
+
@errors.each do |error, message|
|
408
|
+
[message].flatten.each {|m| instance.errors.add(name, m) }
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|