attached 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/attached.rb +82 -82
- data/lib/attached/attachment.rb +114 -114
- data/lib/attached/job.rb +6 -6
- data/lib/attached/processor.rb +9 -9
- data/lib/attached/processor/audio.rb +29 -29
- data/lib/attached/processor/base.rb +14 -14
- data/lib/attached/processor/image.rb +34 -34
- data/lib/attached/railtie.rb +2 -2
- data/lib/attached/storage.rb +8 -8
- data/lib/attached/storage/aws.rb +69 -69
- data/lib/attached/storage/base.rb +26 -26
- data/lib/attached/storage/google.rb +71 -71
- data/lib/attached/storage/local.rb +44 -44
- data/lib/attached/storage/rackspace.rb +68 -68
- data/lib/attached/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/application.js +2 -1
- data/test/dummy/app/assets/javascripts/{audios.js → main.js.coffee} +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +3 -10
- data/test/dummy/app/assets/stylesheets/main.css.scss +6 -0
- data/test/dummy/app/views/audios/_form.html.haml +17 -0
- data/test/dummy/app/views/audios/edit.html.haml +5 -0
- data/test/dummy/app/views/audios/index.html.haml +20 -0
- data/test/dummy/app/views/audios/new.html.haml +5 -0
- data/test/dummy/app/views/audios/show.html.haml +13 -0
- data/test/dummy/app/views/images/_form.html.haml +17 -0
- data/test/dummy/app/views/images/edit.html.haml +5 -0
- data/test/dummy/app/views/images/index.html.haml +20 -0
- data/test/dummy/app/views/images/new.html.haml +5 -0
- data/test/dummy/app/views/images/show.html.haml +13 -0
- data/test/dummy/app/views/layouts/application.html.haml +17 -0
- data/test/dummy/app/views/main/index.html.haml +8 -0
- data/test/dummy/app/views/shared/_error.html.haml +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +37 -0
- data/test/dummy/log/test.log +390 -1166
- data/test/dummy/public/system/audios/files/full/{07a3f586-805d-4c68-be01-7ba4d787aa9e.aac → 151d9dff-7259-41a3-9fc3-988a3099fe22.aac} +0 -0
- data/test/dummy/public/system/audios/files/full/{1a5d65b6-3d7f-45e3-8fc8-9221f3bca127.aac → 2b5e47b9-b441-4c49-a98f-5bf89f19848e.aac} +0 -0
- data/test/dummy/public/system/audios/files/full/{3729319f-299b-47e2-bd7e-d73d38b5cf8f.aac → 33203ced-129f-454c-870a-dc87a2809859.aac} +0 -0
- data/test/dummy/public/system/audios/files/full/{41e88b81-2804-4316-86e8-252adad0eaa3.aac → c03bdf7c-ce26-4a31-9c23-d947b2986fa7.aac} +0 -0
- data/test/dummy/public/system/audios/files/large/{07a3f586-805d-4c68-be01-7ba4d787aa9e.aac → 151d9dff-7259-41a3-9fc3-988a3099fe22.aac} +0 -0
- data/test/dummy/public/system/audios/files/large/{1a5d65b6-3d7f-45e3-8fc8-9221f3bca127.aac → 2b5e47b9-b441-4c49-a98f-5bf89f19848e.aac} +0 -0
- data/test/dummy/public/system/audios/files/large/{3729319f-299b-47e2-bd7e-d73d38b5cf8f.aac → 33203ced-129f-454c-870a-dc87a2809859.aac} +0 -0
- data/test/dummy/public/system/audios/files/large/{41e88b81-2804-4316-86e8-252adad0eaa3.aac → c03bdf7c-ce26-4a31-9c23-d947b2986fa7.aac} +0 -0
- data/test/dummy/public/system/audios/files/original/{07a3f586-805d-4c68-be01-7ba4d787aa9e.wav → 151d9dff-7259-41a3-9fc3-988a3099fe22.wav} +0 -0
- data/test/dummy/public/system/audios/files/original/{1a5d65b6-3d7f-45e3-8fc8-9221f3bca127.wav → 2b5e47b9-b441-4c49-a98f-5bf89f19848e.wav} +0 -0
- data/test/dummy/public/system/audios/files/original/{3729319f-299b-47e2-bd7e-d73d38b5cf8f.wav → 33203ced-129f-454c-870a-dc87a2809859.wav} +0 -0
- data/test/dummy/public/system/audios/files/original/{41e88b81-2804-4316-86e8-252adad0eaa3.wav → c03bdf7c-ce26-4a31-9c23-d947b2986fa7.wav} +0 -0
- data/test/dummy/public/system/audios/files/small/{07a3f586-805d-4c68-be01-7ba4d787aa9e.aac → 151d9dff-7259-41a3-9fc3-988a3099fe22.aac} +0 -0
- data/test/dummy/public/system/audios/files/small/{1a5d65b6-3d7f-45e3-8fc8-9221f3bca127.aac → 2b5e47b9-b441-4c49-a98f-5bf89f19848e.aac} +0 -0
- data/test/dummy/public/system/audios/files/small/{3729319f-299b-47e2-bd7e-d73d38b5cf8f.aac → 33203ced-129f-454c-870a-dc87a2809859.aac} +0 -0
- data/test/dummy/public/system/audios/files/small/{41e88b81-2804-4316-86e8-252adad0eaa3.aac → c03bdf7c-ce26-4a31-9c23-d947b2986fa7.aac} +0 -0
- data/test/dummy/public/system/images/files/full/15f09efb-0d03-44b3-a372-5ae156e8898e.jpg +0 -0
- data/test/dummy/public/system/images/files/full/7a1dbda7-f7f7-4b13-a7ae-be38c43f76a3.jpg +0 -0
- data/test/dummy/public/system/images/files/full/84b585ce-9430-4761-8fb1-d94302eb33bd.jpg +0 -0
- data/test/dummy/public/system/images/files/full/b8e19d15-db0f-42e7-9372-5f563486928a.jpg +0 -0
- data/test/dummy/public/system/images/files/full/baa48120-b3b9-4d2a-830a-e6ebc4db7802.jpg +0 -0
- data/test/dummy/public/system/images/files/full/caac47c3-f3c8-4ca9-a682-d79e8c1b5b29.jpg +0 -0
- data/test/dummy/public/system/images/files/large/15f09efb-0d03-44b3-a372-5ae156e8898e.jpg +0 -0
- data/test/dummy/public/system/images/files/large/7a1dbda7-f7f7-4b13-a7ae-be38c43f76a3.jpg +0 -0
- data/test/dummy/public/system/images/files/large/84b585ce-9430-4761-8fb1-d94302eb33bd.jpg +0 -0
- data/test/dummy/public/system/images/files/large/b8e19d15-db0f-42e7-9372-5f563486928a.jpg +0 -0
- data/test/dummy/public/system/images/files/large/baa48120-b3b9-4d2a-830a-e6ebc4db7802.jpg +0 -0
- data/test/dummy/public/system/images/files/large/caac47c3-f3c8-4ca9-a682-d79e8c1b5b29.jpg +0 -0
- data/test/dummy/public/system/images/files/original/{0850c86c-78a8-4319-8852-bed744b792e6.png → 15f09efb-0d03-44b3-a372-5ae156e8898e.png} +0 -0
- data/test/dummy/public/system/images/files/original/{12ace664-b553-45a6-b02b-37e15ac2981b.png → 7a1dbda7-f7f7-4b13-a7ae-be38c43f76a3.png} +0 -0
- data/test/dummy/public/system/images/files/original/{2ac8ebdb-bc96-49c4-befd-5c96b47646e5.png → 84b585ce-9430-4761-8fb1-d94302eb33bd.png} +0 -0
- data/test/dummy/public/system/images/files/original/{3e9c5921-4820-441d-9f90-90b518cd582e.png → b8e19d15-db0f-42e7-9372-5f563486928a.png} +0 -0
- data/test/dummy/public/system/images/files/original/{444d0123-908a-4616-83e3-88942a66a075.png → baa48120-b3b9-4d2a-830a-e6ebc4db7802.png} +0 -0
- data/test/dummy/public/system/images/files/original/{5af89da1-b1fa-421a-a52e-01607d89fb5d.png → caac47c3-f3c8-4ca9-a682-d79e8c1b5b29.png} +0 -0
- data/test/dummy/public/system/images/files/small/15f09efb-0d03-44b3-a372-5ae156e8898e.jpg +0 -0
- data/test/dummy/public/system/images/files/small/7a1dbda7-f7f7-4b13-a7ae-be38c43f76a3.jpg +0 -0
- data/test/dummy/public/system/images/files/small/84b585ce-9430-4761-8fb1-d94302eb33bd.jpg +0 -0
- data/test/dummy/public/system/images/files/small/b8e19d15-db0f-42e7-9372-5f563486928a.jpg +0 -0
- data/test/dummy/public/system/images/files/small/baa48120-b3b9-4d2a-830a-e6ebc4db7802.jpg +0 -0
- data/test/dummy/public/system/images/files/small/caac47c3-f3c8-4ca9-a682-d79e8c1b5b29.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/15f09efb-0d03-44b3-a372-5ae156e8898e.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/7a1dbda7-f7f7-4b13-a7ae-be38c43f76a3.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/84b585ce-9430-4761-8fb1-d94302eb33bd.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/b8e19d15-db0f-42e7-9372-5f563486928a.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/baa48120-b3b9-4d2a-830a-e6ebc4db7802.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/caac47c3-f3c8-4ca9-a682-d79e8c1b5b29.jpg +0 -0
- metadata +168 -337
- data/test/dummy/app/assets/javascripts/images.js +0 -0
- data/test/dummy/app/assets/javascripts/main.js +0 -0
- data/test/dummy/app/assets/stylesheets/audios.css +0 -0
- data/test/dummy/app/assets/stylesheets/images.css +0 -0
- data/test/dummy/app/assets/stylesheets/main.css +0 -0
- data/test/dummy/app/views/audios/_form.html.erb +0 -27
- data/test/dummy/app/views/audios/edit.html.erb +0 -3
- data/test/dummy/app/views/audios/index.html.erb +0 -17
- data/test/dummy/app/views/audios/new.html.erb +0 -3
- data/test/dummy/app/views/audios/show.html.erb +0 -17
- data/test/dummy/app/views/images/_form.html.erb +0 -27
- data/test/dummy/app/views/images/edit.html.erb +0 -3
- data/test/dummy/app/views/images/index.html.erb +0 -17
- data/test/dummy/app/views/images/new.html.erb +0 -3
- data/test/dummy/app/views/images/show.html.erb +0 -18
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/main/index.html.erb +0 -6
- data/test/dummy/public/system/audios/files/full/5d262d6b-4789-42f9-b985-1c39c9eca0c0.aac +0 -0
- data/test/dummy/public/system/audios/files/full/67645888-cf0b-47db-8202-2df3a1ce594d.aac +0 -0
- data/test/dummy/public/system/audios/files/full/6cecb6b5-46cd-47a5-bf8a-10849e30f1f6.aac +0 -0
- data/test/dummy/public/system/audios/files/full/8d116bcb-2605-429e-9edc-b1a91fa66d0a.aac +0 -0
- data/test/dummy/public/system/audios/files/full/9b084b16-eb46-4730-ad80-c5d7d8ef92d2.aac +0 -0
- data/test/dummy/public/system/audios/files/full/9dddf071-ac43-4232-9a9d-fb5d26862bd1.aac +0 -0
- data/test/dummy/public/system/audios/files/full/a6880c5f-d130-469f-9c30-d8aa1b9f7b71.aac +0 -0
- data/test/dummy/public/system/audios/files/full/a79a531d-5de4-4aa3-9c04-275cf6307d13.aac +0 -0
- data/test/dummy/public/system/audios/files/full/c6768282-9787-45dc-a39f-37d23b83f8f2.aac +0 -0
- data/test/dummy/public/system/audios/files/full/e8389286-fda2-4614-906f-bd646383333a.aac +0 -0
- data/test/dummy/public/system/audios/files/full/ee0041b9-6482-4d4f-96cc-1a6e28c93570.aac +0 -0
- data/test/dummy/public/system/audios/files/full/ffb3df30-8dbf-4938-abde-21cdfced70d1.aac +0 -0
- data/test/dummy/public/system/audios/files/large/5d262d6b-4789-42f9-b985-1c39c9eca0c0.aac +0 -0
- data/test/dummy/public/system/audios/files/large/67645888-cf0b-47db-8202-2df3a1ce594d.aac +0 -0
- data/test/dummy/public/system/audios/files/large/6cecb6b5-46cd-47a5-bf8a-10849e30f1f6.aac +0 -0
- data/test/dummy/public/system/audios/files/large/8d116bcb-2605-429e-9edc-b1a91fa66d0a.aac +0 -0
- data/test/dummy/public/system/audios/files/large/9b084b16-eb46-4730-ad80-c5d7d8ef92d2.aac +0 -0
- data/test/dummy/public/system/audios/files/large/9dddf071-ac43-4232-9a9d-fb5d26862bd1.aac +0 -0
- data/test/dummy/public/system/audios/files/large/a6880c5f-d130-469f-9c30-d8aa1b9f7b71.aac +0 -0
- data/test/dummy/public/system/audios/files/large/a79a531d-5de4-4aa3-9c04-275cf6307d13.aac +0 -0
- data/test/dummy/public/system/audios/files/large/c6768282-9787-45dc-a39f-37d23b83f8f2.aac +0 -0
- data/test/dummy/public/system/audios/files/large/e8389286-fda2-4614-906f-bd646383333a.aac +0 -0
- data/test/dummy/public/system/audios/files/large/ee0041b9-6482-4d4f-96cc-1a6e28c93570.aac +0 -0
- data/test/dummy/public/system/audios/files/large/ffb3df30-8dbf-4938-abde-21cdfced70d1.aac +0 -0
- data/test/dummy/public/system/audios/files/original/5d262d6b-4789-42f9-b985-1c39c9eca0c0.wav +0 -0
- data/test/dummy/public/system/audios/files/original/67645888-cf0b-47db-8202-2df3a1ce594d.wav +0 -0
- data/test/dummy/public/system/audios/files/original/6cecb6b5-46cd-47a5-bf8a-10849e30f1f6.wav +0 -0
- data/test/dummy/public/system/audios/files/original/8d116bcb-2605-429e-9edc-b1a91fa66d0a.wav +0 -0
- data/test/dummy/public/system/audios/files/original/9b084b16-eb46-4730-ad80-c5d7d8ef92d2.wav +0 -0
- data/test/dummy/public/system/audios/files/original/9dddf071-ac43-4232-9a9d-fb5d26862bd1.wav +0 -0
- data/test/dummy/public/system/audios/files/original/a6880c5f-d130-469f-9c30-d8aa1b9f7b71.wav +0 -0
- data/test/dummy/public/system/audios/files/original/a79a531d-5de4-4aa3-9c04-275cf6307d13.wav +0 -0
- data/test/dummy/public/system/audios/files/original/c6768282-9787-45dc-a39f-37d23b83f8f2.wav +0 -0
- data/test/dummy/public/system/audios/files/original/e8389286-fda2-4614-906f-bd646383333a.wav +0 -0
- data/test/dummy/public/system/audios/files/original/ee0041b9-6482-4d4f-96cc-1a6e28c93570.wav +0 -0
- data/test/dummy/public/system/audios/files/original/ffb3df30-8dbf-4938-abde-21cdfced70d1.wav +0 -0
- data/test/dummy/public/system/audios/files/small/5d262d6b-4789-42f9-b985-1c39c9eca0c0.aac +0 -0
- data/test/dummy/public/system/audios/files/small/67645888-cf0b-47db-8202-2df3a1ce594d.aac +0 -0
- data/test/dummy/public/system/audios/files/small/6cecb6b5-46cd-47a5-bf8a-10849e30f1f6.aac +0 -0
- data/test/dummy/public/system/audios/files/small/8d116bcb-2605-429e-9edc-b1a91fa66d0a.aac +0 -0
- data/test/dummy/public/system/audios/files/small/9b084b16-eb46-4730-ad80-c5d7d8ef92d2.aac +0 -0
- data/test/dummy/public/system/audios/files/small/9dddf071-ac43-4232-9a9d-fb5d26862bd1.aac +0 -0
- data/test/dummy/public/system/audios/files/small/a6880c5f-d130-469f-9c30-d8aa1b9f7b71.aac +0 -0
- data/test/dummy/public/system/audios/files/small/a79a531d-5de4-4aa3-9c04-275cf6307d13.aac +0 -0
- data/test/dummy/public/system/audios/files/small/c6768282-9787-45dc-a39f-37d23b83f8f2.aac +0 -0
- data/test/dummy/public/system/audios/files/small/e8389286-fda2-4614-906f-bd646383333a.aac +0 -0
- data/test/dummy/public/system/audios/files/small/ee0041b9-6482-4d4f-96cc-1a6e28c93570.aac +0 -0
- data/test/dummy/public/system/audios/files/small/ffb3df30-8dbf-4938-abde-21cdfced70d1.aac +0 -0
- data/test/dummy/public/system/images/files/full/0850c86c-78a8-4319-8852-bed744b792e6.jpg +0 -0
- data/test/dummy/public/system/images/files/full/12ace664-b553-45a6-b02b-37e15ac2981b.jpg +0 -0
- data/test/dummy/public/system/images/files/full/2ac8ebdb-bc96-49c4-befd-5c96b47646e5.jpg +0 -0
- data/test/dummy/public/system/images/files/full/3e9c5921-4820-441d-9f90-90b518cd582e.jpg +0 -0
- data/test/dummy/public/system/images/files/full/444d0123-908a-4616-83e3-88942a66a075.jpg +0 -0
- data/test/dummy/public/system/images/files/full/5af89da1-b1fa-421a-a52e-01607d89fb5d.jpg +0 -0
- data/test/dummy/public/system/images/files/full/8628fbe3-bd09-4713-babe-e38c1492788e.jpg +0 -0
- data/test/dummy/public/system/images/files/full/a0158251-8d9c-42fb-a854-e56b915713df.jpg +0 -0
- data/test/dummy/public/system/images/files/full/b7318aed-63ee-43a2-9365-755bcc2815df.jpg +0 -0
- data/test/dummy/public/system/images/files/full/c292008f-764f-4f8a-8df1-82c63d87a653.jpg +0 -0
- data/test/dummy/public/system/images/files/full/cd5745af-c9c5-4ea4-9fca-711fb58c4604.jpg +0 -0
- data/test/dummy/public/system/images/files/full/d39266e6-2426-4888-9f12-031ade4f872e.jpg +0 -0
- data/test/dummy/public/system/images/files/full/e9e4c240-1426-4951-a600-c5a07c30d80d.jpg +0 -0
- data/test/dummy/public/system/images/files/full/ee1f8491-6e52-410f-9d62-bd544715d066.jpg +0 -0
- data/test/dummy/public/system/images/files/full/f7ccd0c4-6d8d-4d26-afe7-ab62a448baf9.jpg +0 -0
- data/test/dummy/public/system/images/files/full/ffc3f5fd-ff40-4a77-8e08-0517e519f857.jpg +0 -0
- data/test/dummy/public/system/images/files/large/0850c86c-78a8-4319-8852-bed744b792e6.jpg +0 -0
- data/test/dummy/public/system/images/files/large/12ace664-b553-45a6-b02b-37e15ac2981b.jpg +0 -0
- data/test/dummy/public/system/images/files/large/2ac8ebdb-bc96-49c4-befd-5c96b47646e5.jpg +0 -0
- data/test/dummy/public/system/images/files/large/3e9c5921-4820-441d-9f90-90b518cd582e.jpg +0 -0
- data/test/dummy/public/system/images/files/large/444d0123-908a-4616-83e3-88942a66a075.jpg +0 -0
- data/test/dummy/public/system/images/files/large/5af89da1-b1fa-421a-a52e-01607d89fb5d.jpg +0 -0
- data/test/dummy/public/system/images/files/large/8628fbe3-bd09-4713-babe-e38c1492788e.jpg +0 -0
- data/test/dummy/public/system/images/files/large/a0158251-8d9c-42fb-a854-e56b915713df.jpg +0 -0
- data/test/dummy/public/system/images/files/large/b7318aed-63ee-43a2-9365-755bcc2815df.jpg +0 -0
- data/test/dummy/public/system/images/files/large/c292008f-764f-4f8a-8df1-82c63d87a653.jpg +0 -0
- data/test/dummy/public/system/images/files/large/cd5745af-c9c5-4ea4-9fca-711fb58c4604.jpg +0 -0
- data/test/dummy/public/system/images/files/large/d39266e6-2426-4888-9f12-031ade4f872e.jpg +0 -0
- data/test/dummy/public/system/images/files/large/e9e4c240-1426-4951-a600-c5a07c30d80d.jpg +0 -0
- data/test/dummy/public/system/images/files/large/ee1f8491-6e52-410f-9d62-bd544715d066.jpg +0 -0
- data/test/dummy/public/system/images/files/large/f7ccd0c4-6d8d-4d26-afe7-ab62a448baf9.jpg +0 -0
- data/test/dummy/public/system/images/files/large/ffc3f5fd-ff40-4a77-8e08-0517e519f857.jpg +0 -0
- data/test/dummy/public/system/images/files/original/8628fbe3-bd09-4713-babe-e38c1492788e.png +0 -0
- data/test/dummy/public/system/images/files/original/a0158251-8d9c-42fb-a854-e56b915713df.png +0 -0
- data/test/dummy/public/system/images/files/original/b7318aed-63ee-43a2-9365-755bcc2815df.png +0 -0
- data/test/dummy/public/system/images/files/original/c292008f-764f-4f8a-8df1-82c63d87a653.png +0 -0
- data/test/dummy/public/system/images/files/original/cd5745af-c9c5-4ea4-9fca-711fb58c4604.png +0 -0
- data/test/dummy/public/system/images/files/original/d39266e6-2426-4888-9f12-031ade4f872e.png +0 -0
- data/test/dummy/public/system/images/files/original/e9e4c240-1426-4951-a600-c5a07c30d80d.png +0 -0
- data/test/dummy/public/system/images/files/original/ee1f8491-6e52-410f-9d62-bd544715d066.png +0 -0
- data/test/dummy/public/system/images/files/original/f7ccd0c4-6d8d-4d26-afe7-ab62a448baf9.png +0 -0
- data/test/dummy/public/system/images/files/original/ffc3f5fd-ff40-4a77-8e08-0517e519f857.png +0 -0
- data/test/dummy/public/system/images/files/small/0850c86c-78a8-4319-8852-bed744b792e6.jpg +0 -0
- data/test/dummy/public/system/images/files/small/12ace664-b553-45a6-b02b-37e15ac2981b.jpg +0 -0
- data/test/dummy/public/system/images/files/small/2ac8ebdb-bc96-49c4-befd-5c96b47646e5.jpg +0 -0
- data/test/dummy/public/system/images/files/small/3e9c5921-4820-441d-9f90-90b518cd582e.jpg +0 -0
- data/test/dummy/public/system/images/files/small/444d0123-908a-4616-83e3-88942a66a075.jpg +0 -0
- data/test/dummy/public/system/images/files/small/5af89da1-b1fa-421a-a52e-01607d89fb5d.jpg +0 -0
- data/test/dummy/public/system/images/files/small/8628fbe3-bd09-4713-babe-e38c1492788e.jpg +0 -0
- data/test/dummy/public/system/images/files/small/a0158251-8d9c-42fb-a854-e56b915713df.jpg +0 -0
- data/test/dummy/public/system/images/files/small/b7318aed-63ee-43a2-9365-755bcc2815df.jpg +0 -0
- data/test/dummy/public/system/images/files/small/c292008f-764f-4f8a-8df1-82c63d87a653.jpg +0 -0
- data/test/dummy/public/system/images/files/small/cd5745af-c9c5-4ea4-9fca-711fb58c4604.jpg +0 -0
- data/test/dummy/public/system/images/files/small/d39266e6-2426-4888-9f12-031ade4f872e.jpg +0 -0
- data/test/dummy/public/system/images/files/small/e9e4c240-1426-4951-a600-c5a07c30d80d.jpg +0 -0
- data/test/dummy/public/system/images/files/small/ee1f8491-6e52-410f-9d62-bd544715d066.jpg +0 -0
- data/test/dummy/public/system/images/files/small/f7ccd0c4-6d8d-4d26-afe7-ab62a448baf9.jpg +0 -0
- data/test/dummy/public/system/images/files/small/ffc3f5fd-ff40-4a77-8e08-0517e519f857.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/0850c86c-78a8-4319-8852-bed744b792e6.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/12ace664-b553-45a6-b02b-37e15ac2981b.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/2ac8ebdb-bc96-49c4-befd-5c96b47646e5.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/3e9c5921-4820-441d-9f90-90b518cd582e.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/444d0123-908a-4616-83e3-88942a66a075.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/5af89da1-b1fa-421a-a52e-01607d89fb5d.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/8628fbe3-bd09-4713-babe-e38c1492788e.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/a0158251-8d9c-42fb-a854-e56b915713df.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/b7318aed-63ee-43a2-9365-755bcc2815df.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/c292008f-764f-4f8a-8df1-82c63d87a653.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/cd5745af-c9c5-4ea4-9fca-711fb58c4604.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/d39266e6-2426-4888-9f12-031ade4f872e.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/e9e4c240-1426-4951-a600-c5a07c30d80d.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/ee1f8491-6e52-410f-9d62-bd544715d066.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/f7ccd0c4-6d8d-4d26-afe7-ab62a448baf9.jpg +0 -0
- data/test/dummy/public/system/images/files/thumb/ffc3f5fd-ff40-4a77-8e08-0517e519f857.jpg +0 -0
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/lib/attached.rb
CHANGED
@@ -2,19 +2,19 @@ require 'attached/attachment'
|
|
2
2
|
require 'attached/railtie'
|
3
3
|
|
4
4
|
|
5
|
-
module Attached
|
6
|
-
|
7
|
-
|
5
|
+
module Attached
|
6
|
+
|
7
|
+
|
8
8
|
def self.included(base)
|
9
9
|
base.extend ClassMethods
|
10
10
|
base.class_attribute :attached_options
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
|
14
14
|
module Definition
|
15
15
|
def attachment(*args)
|
16
16
|
options = args.extract_options!
|
17
|
-
|
17
|
+
|
18
18
|
args.each do |name|
|
19
19
|
column("#{name}_identifier", :string, options)
|
20
20
|
column("#{name}_extension", :string, options)
|
@@ -22,11 +22,11 @@ module Attached
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
|
27
27
|
module ClassMethods
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
|
30
30
|
# Add an attachment to a class.
|
31
31
|
#
|
32
32
|
# Options:
|
@@ -40,21 +40,21 @@ module Attached
|
|
40
40
|
# has_attached :video
|
41
41
|
# has_attached :video, :storage => :aws
|
42
42
|
# has_attached :video, styles => { :mov => { :size => "480p", :format => "mov" } }
|
43
|
-
|
43
|
+
|
44
44
|
def has_attached(name, options = {})
|
45
|
-
|
45
|
+
|
46
46
|
include InstanceMethods
|
47
|
-
|
47
|
+
|
48
48
|
self.attached_options ||= {}
|
49
49
|
self.attached_options[name] = options
|
50
|
-
|
50
|
+
|
51
51
|
before_save :save_attached
|
52
52
|
before_destroy :destroy_attached
|
53
|
-
|
53
|
+
|
54
54
|
define_method name do
|
55
55
|
attachment_for(name)
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
define_method "#{name}=" do |file|
|
59
59
|
attachment_for(name).assign(file)
|
60
60
|
end
|
@@ -62,43 +62,43 @@ module Attached
|
|
62
62
|
define_method "#{name}?" do
|
63
63
|
attachment_for(name).attached?
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
validates_each(name) do |record, attr, value|
|
67
67
|
attachment = record.attachment_for(name)
|
68
68
|
attachment.errors.each do |error|
|
69
69
|
record.errors.add(name, error)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
after_validation do
|
74
|
-
|
74
|
+
|
75
75
|
if self.errors.include?(:"#{name}_size")
|
76
76
|
self.errors[:"#{name}_size"].each do |message|
|
77
77
|
self.errors.add(name, message)
|
78
78
|
end
|
79
79
|
self.errors[:"#{name}_size"].clear
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
if self.errors.include?(:"#{name}_extension")
|
83
83
|
self.errors[:"#{name}_extension"].each do |message|
|
84
84
|
self.errors.add(name, message)
|
85
85
|
end
|
86
86
|
self.errors[:"#{name}_extension"].clear
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
if self.errors.include?(:"#{name}_identifier")
|
90
90
|
self.errors[:"#{name}_identifier"].each do |message|
|
91
91
|
self.errors.add(name, message)
|
92
92
|
end
|
93
93
|
self.errors[:"#{name}_identifier"].clear
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
end
|
99
|
-
|
100
|
-
|
101
|
-
# Validates an attached size in a specified range or minimum and maximum.
|
99
|
+
|
100
|
+
|
101
|
+
# Validates an attached size in a specified range or minimum and maximum.
|
102
102
|
#
|
103
103
|
# Options:
|
104
104
|
#
|
@@ -108,64 +108,64 @@ module Attached
|
|
108
108
|
# * :in - range of bytes for file
|
109
109
|
#
|
110
110
|
# Usage:
|
111
|
-
#
|
111
|
+
#
|
112
112
|
# validates_attached_size :avatar, :range => 10.megabytes .. 20.megabytes
|
113
113
|
# validates_attached_size :avatar, :minimum => 10.megabytes, :maximum => 20.megabytes
|
114
114
|
# validates_attached_size :avatar, :message => "size must be between :minimum and :maximum bytes"
|
115
|
-
|
115
|
+
|
116
116
|
def validates_attached_size(name, options = {})
|
117
|
-
|
117
|
+
|
118
118
|
zero = (0.0 / 1.0)
|
119
119
|
infi = (1.0 / 0.0)
|
120
|
-
|
120
|
+
|
121
121
|
minimum = options[:minimum] || options[:in] && options[:in].first || zero
|
122
122
|
maximum = options[:maximum] || options[:in] && options[:in].last || infi
|
123
|
-
|
123
|
+
|
124
124
|
message = options[:message]
|
125
125
|
message ||= "size must be specified" if minimum == zero && maximum == infi
|
126
126
|
message ||= "size must be a minimum of :minimum" if maximum == infi
|
127
127
|
message ||= "size must be a maximum of :maximum" if minimum == zero
|
128
128
|
message ||= "size must be between :minimum and :maximum"
|
129
|
-
|
129
|
+
|
130
130
|
range = minimum..maximum
|
131
|
-
|
131
|
+
|
132
132
|
message.gsub!(/:minimum/, number_to_size(minimum)) unless minimum == zero
|
133
133
|
message.gsub!(/:maximum/, number_to_size(maximum)) unless maximum == infi
|
134
|
-
|
135
|
-
validates_inclusion_of :"#{name}_size", :in => range, :message => message,
|
134
|
+
|
135
|
+
validates_inclusion_of :"#{name}_size", :in => range, :message => message,
|
136
136
|
:if => options[:if], :unless => options[:unless]
|
137
|
-
|
137
|
+
|
138
138
|
end
|
139
|
-
|
140
|
-
|
141
|
-
# Validates an attached extension in a specified set.
|
139
|
+
|
140
|
+
|
141
|
+
# Validates an attached extension in a specified set.
|
142
142
|
#
|
143
143
|
# Options:
|
144
144
|
#
|
145
145
|
# * :in - allowed values for attached
|
146
146
|
#
|
147
147
|
# Usage:
|
148
|
-
#
|
148
|
+
#
|
149
149
|
# validates_attached_extension :avatar, :is => 'png'
|
150
150
|
# validates_attached_extension :avatar, :in => %w(png jpg)
|
151
151
|
# validates_attached_extension :avatar, :in => [:png, :jpg]
|
152
152
|
# validates_attached_extension :avatar, :in => %w(png jpg), :message => "extension must be :in"
|
153
153
|
# validates_attached_extension :avatar, :in => %w(png jpg), :message => "extension must be :in"
|
154
|
-
|
154
|
+
|
155
155
|
def validates_attached_extension(name, options = {})
|
156
|
-
|
156
|
+
|
157
157
|
message = options[:message]
|
158
158
|
message ||= "extension is invalid"
|
159
|
-
|
159
|
+
|
160
160
|
options[:in] ||= [options[:is]] if options[:is]
|
161
|
-
|
161
|
+
|
162
162
|
range = options[:in].map { |element| ".#{element}" }
|
163
|
-
|
163
|
+
|
164
164
|
validates_inclusion_of :"#{name}_extension", :in => range, :message => message,
|
165
165
|
:if => options[:if], :unless => options[:unless]
|
166
166
|
end
|
167
|
-
|
168
|
-
|
167
|
+
|
168
|
+
|
169
169
|
# Validates that an attachment is included.
|
170
170
|
#
|
171
171
|
# Options:
|
@@ -176,21 +176,21 @@ module Attached
|
|
176
176
|
#
|
177
177
|
# validates_attached_presence :avatar
|
178
178
|
# validates_attached_presence :avatar, :message => "must be attached"
|
179
|
-
|
179
|
+
|
180
180
|
def validates_attached_presence(name, options = {})
|
181
|
-
|
181
|
+
|
182
182
|
message = options[:message]
|
183
183
|
message ||= "must be attached"
|
184
|
-
|
184
|
+
|
185
185
|
validates_presence_of :"#{name}_identifier", :message => message,
|
186
186
|
:if => options[:if], :unless => options[:unless]
|
187
|
-
|
187
|
+
|
188
188
|
end
|
189
|
-
|
190
|
-
|
189
|
+
|
190
|
+
|
191
191
|
private
|
192
|
-
|
193
|
-
|
192
|
+
|
193
|
+
|
194
194
|
# Convert a number to a human readable size.
|
195
195
|
#
|
196
196
|
# Usage:
|
@@ -199,75 +199,75 @@ module Attached
|
|
199
199
|
# number_to_size(2) # 2 bytes
|
200
200
|
# number_to_size(1024) # 1 kilobyte
|
201
201
|
# number_to_size(2048) # 2 kilobytes
|
202
|
-
|
202
|
+
|
203
203
|
def number_to_size(number, options = {})
|
204
204
|
return if number == 0.0 / 1.0
|
205
205
|
return if number == 1.0 / 0.0
|
206
|
-
|
206
|
+
|
207
207
|
singular = options['singular'] || 1
|
208
208
|
base = options['base'] || 1024
|
209
209
|
units = options['units'] || ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte", "petabyte"]
|
210
|
-
|
210
|
+
|
211
211
|
exponent = (Math.log(number) / Math.log(base)).floor
|
212
|
-
|
212
|
+
|
213
213
|
number /= base ** exponent
|
214
214
|
unit = units[exponent]
|
215
|
-
|
215
|
+
|
216
216
|
number == singular ? unit.gsub!(/s$/, '') : unit.gsub!(/$/, 's')
|
217
|
-
|
217
|
+
|
218
218
|
"#{number} #{unit}"
|
219
219
|
end
|
220
|
-
|
221
|
-
|
220
|
+
|
221
|
+
|
222
222
|
end
|
223
|
-
|
224
|
-
|
223
|
+
|
224
|
+
|
225
225
|
module InstanceMethods
|
226
|
-
|
227
|
-
|
226
|
+
|
227
|
+
|
228
228
|
# Create or access attachment.
|
229
229
|
#
|
230
230
|
# Usage:
|
231
|
-
#
|
231
|
+
#
|
232
232
|
# attachment_for :avatar
|
233
|
-
|
233
|
+
|
234
234
|
def attachment_for(name)
|
235
235
|
@_attached_attachments ||= {}
|
236
236
|
@_attached_attachments[name] ||= Attachment.new(name, self, self.class.attached_options[name])
|
237
237
|
end
|
238
|
-
|
239
|
-
|
238
|
+
|
239
|
+
|
240
240
|
# Log and save all attached (using specified storage).
|
241
241
|
#
|
242
242
|
# Usage:
|
243
243
|
#
|
244
244
|
# before_save :save_attached
|
245
|
-
|
245
|
+
|
246
246
|
def save_attached
|
247
247
|
logger.info "[attached] save attached"
|
248
|
-
|
249
|
-
self.class.attached_options.each do |name, options|
|
248
|
+
|
249
|
+
self.class.attached_options.each do |name, options|
|
250
250
|
attachment_for(name).save
|
251
251
|
end
|
252
252
|
end
|
253
|
-
|
254
|
-
|
253
|
+
|
254
|
+
|
255
255
|
# Log and destroy all attached (using specified storage).
|
256
256
|
#
|
257
257
|
# Usage:
|
258
258
|
#
|
259
259
|
# before_save :destroy_attached
|
260
|
-
|
260
|
+
|
261
261
|
def destroy_attached
|
262
262
|
logger.info "[attached] destroy attached"
|
263
|
-
|
263
|
+
|
264
264
|
self.class.attached_options.each do |name, options|
|
265
265
|
attachment_for(name).destroy
|
266
266
|
end
|
267
267
|
end
|
268
|
-
|
269
|
-
|
268
|
+
|
269
|
+
|
270
270
|
end
|
271
|
-
|
272
|
-
|
271
|
+
|
272
|
+
|
273
273
|
end
|
data/lib/attached/attachment.rb
CHANGED
@@ -7,10 +7,10 @@ require 'attached/processor'
|
|
7
7
|
require 'attached/processor/error'
|
8
8
|
|
9
9
|
module Attached
|
10
|
-
|
10
|
+
|
11
11
|
class Attachment
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
|
14
14
|
attr_reader :file
|
15
15
|
attr_reader :name
|
16
16
|
attr_reader :instance
|
@@ -30,14 +30,14 @@ module Attached
|
|
30
30
|
attr_reader :alias
|
31
31
|
attr_reader :storage
|
32
32
|
attr_reader :host
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
|
35
35
|
# A default set of options that can be extended to customize the path, storage or credentials.
|
36
36
|
#
|
37
37
|
# Usage:
|
38
38
|
#
|
39
39
|
# Attached::Attachment.options = { :storage => :fs, :path => ":name/:style/:identifier:extension" }
|
40
|
-
|
40
|
+
|
41
41
|
def self.options
|
42
42
|
@options ||= {
|
43
43
|
:path => ":name/:style/:identifier:extension",
|
@@ -47,12 +47,12 @@ module Attached
|
|
47
47
|
:credentials => {},
|
48
48
|
}
|
49
49
|
end
|
50
|
-
|
51
|
-
|
50
|
+
|
51
|
+
|
52
52
|
# Initialize a new attachment by providing a name and the instance the attachment is associated with.
|
53
53
|
#
|
54
54
|
# Parameters:
|
55
|
-
#
|
55
|
+
#
|
56
56
|
# * name - The name for the attachment such as 'avatar' or 'photo'
|
57
57
|
# * instance - The instance the attachment is attached to
|
58
58
|
#
|
@@ -64,23 +64,23 @@ module Attached
|
|
64
64
|
# * :medium - A symbol or subclass of 'Attached::Storage::Base' to be used
|
65
65
|
# * :processor - A symbol or subclass of 'Attached::Processor::Base' to be used
|
66
66
|
# * :alias - A string representing a fully qualified host alias
|
67
|
-
# * :processors - An array of processors
|
67
|
+
# * :processors - An array of processors
|
68
68
|
# * :aliases - An array of aliases
|
69
|
-
|
69
|
+
|
70
70
|
def initialize(name, instance, options = {})
|
71
71
|
options = self.class.options.clone.merge(options)
|
72
|
-
|
72
|
+
|
73
73
|
options[:styles] ||= {}
|
74
74
|
options[:aliases] ||= []
|
75
75
|
options[:processors] ||= []
|
76
|
-
|
76
|
+
|
77
77
|
@name = name
|
78
78
|
@instance = instance
|
79
|
-
|
79
|
+
|
80
80
|
@queue = {}
|
81
81
|
@purge = []
|
82
82
|
@errors = []
|
83
|
-
|
83
|
+
|
84
84
|
@path = options[:path]
|
85
85
|
@missing = options[:missing]
|
86
86
|
@styles = options[:styles]
|
@@ -92,116 +92,116 @@ module Attached
|
|
92
92
|
@processor = options[:processor]
|
93
93
|
@aliases = options[:aliases]
|
94
94
|
@alias = options[:alias]
|
95
|
-
|
95
|
+
|
96
96
|
@aliases = self.aliases << self.alias if self.alias
|
97
97
|
@processors = self.processors << self.processor if self.processor
|
98
|
-
|
98
|
+
|
99
99
|
@storage = Attached::Storage.storage(self.medium, self.credentials)
|
100
|
-
|
100
|
+
|
101
101
|
@host = self.storage.host
|
102
102
|
end
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
|
105
105
|
# Check if an attachment has been modified.
|
106
106
|
#
|
107
107
|
# Usage:
|
108
108
|
#
|
109
109
|
# @object.avatar.changed?
|
110
|
-
|
110
|
+
|
111
111
|
def changed?
|
112
112
|
instance.changed.include? "#{name}_identifier"
|
113
113
|
end
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
|
116
116
|
# Check if an attachment is present.
|
117
117
|
#
|
118
118
|
# Usage:
|
119
119
|
#
|
120
120
|
# @object.avatar.file?
|
121
|
-
|
121
|
+
|
122
122
|
def file?
|
123
123
|
not identifier.blank?
|
124
124
|
end
|
125
|
-
|
126
|
-
|
125
|
+
|
126
|
+
|
127
127
|
# Check if an attachment is present.
|
128
128
|
#
|
129
129
|
# Usage:
|
130
130
|
#
|
131
131
|
# @object.avatar.attached?
|
132
|
-
|
132
|
+
|
133
133
|
def attached?
|
134
134
|
not identifier.blank?
|
135
135
|
end
|
136
|
-
|
137
|
-
|
136
|
+
|
137
|
+
|
138
138
|
# Custom setter for specifying an attachment.
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# Usage:
|
141
141
|
#
|
142
142
|
# @object.avatar.file = File.open(...)
|
143
|
-
|
143
|
+
|
144
144
|
def file=(file)
|
145
145
|
@file = file
|
146
146
|
@file = file.tempfile if file.respond_to?(:tempfile)
|
147
147
|
end
|
148
|
-
|
149
|
-
|
148
|
+
|
149
|
+
|
150
150
|
# Assign an attachment to a file.
|
151
151
|
#
|
152
152
|
# Usage:
|
153
153
|
#
|
154
154
|
# @object.avatar.assign(...)
|
155
|
-
|
155
|
+
|
156
156
|
def assign(file, identifier = Identifier.generate)
|
157
157
|
self.file = file
|
158
|
-
|
158
|
+
|
159
159
|
if file
|
160
160
|
extension ||= file.extension if file.respond_to? :extension
|
161
161
|
extension ||= File.extname(file.original_filename) if file.respond_to? :original_filename
|
162
162
|
extension ||= File.extname(file.path) if file.respond_to? :path
|
163
|
-
|
163
|
+
|
164
164
|
size ||= file.size if file.respond_to? :size
|
165
165
|
size ||= File.size(file.path) if file.respond_to? :path
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
@purge = [self.path, *self.styles.map { |style, options| self.path(style) }] if attached?
|
169
|
-
|
169
|
+
|
170
170
|
self.size = file ? size : nil
|
171
171
|
self.extension = file ? extension : nil
|
172
172
|
self.identifier = file ? identifier : nil
|
173
|
-
|
173
|
+
|
174
174
|
process if file
|
175
175
|
end
|
176
|
-
|
177
|
-
|
176
|
+
|
177
|
+
|
178
178
|
# Save an attachment.
|
179
179
|
#
|
180
180
|
# Usage:
|
181
181
|
#
|
182
182
|
# @object.avatar.save
|
183
|
-
|
184
|
-
def save
|
183
|
+
|
184
|
+
def save
|
185
185
|
self.queue.each do |style, file|
|
186
186
|
path = self.path(style)
|
187
187
|
self.storage.save(file, path) if file and path
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
self.purge.each do |path|
|
191
191
|
self.storage.destroy(path)
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
@purge = []
|
195
195
|
@queue = {}
|
196
196
|
end
|
197
|
-
|
198
|
-
|
197
|
+
|
198
|
+
|
199
199
|
# Destroy an attachment.
|
200
200
|
#
|
201
201
|
# Usage:
|
202
202
|
#
|
203
203
|
# @object.avatar.destroy
|
204
|
-
|
204
|
+
|
205
205
|
def destroy
|
206
206
|
if attached?
|
207
207
|
self.storage.destroy(self.path)
|
@@ -209,12 +209,12 @@ module Attached
|
|
209
209
|
self.storage.destroy(self.path(style))
|
210
210
|
end
|
211
211
|
end
|
212
|
-
|
212
|
+
|
213
213
|
@purge = []
|
214
214
|
@queue = {}
|
215
215
|
end
|
216
|
-
|
217
|
-
|
216
|
+
|
217
|
+
|
218
218
|
# Acesss the URL for an attachment.
|
219
219
|
#
|
220
220
|
# Usage:
|
@@ -222,28 +222,28 @@ module Attached
|
|
222
222
|
# @object.avatar.url
|
223
223
|
# @object.avatar.url(:small)
|
224
224
|
# @object.avatar.url(:large)
|
225
|
-
|
225
|
+
|
226
226
|
def url(style = self.default)
|
227
227
|
path = self.path(style)
|
228
|
-
|
228
|
+
|
229
229
|
host = self.host
|
230
230
|
host = self.aliases[path.hash % self.aliases.count] unless self.aliases.empty?
|
231
|
-
|
231
|
+
|
232
232
|
return "#{host}#{path}"
|
233
233
|
end
|
234
|
-
|
235
|
-
|
236
|
-
# Access the path for an attachment.
|
234
|
+
|
235
|
+
|
236
|
+
# Access the path for an attachment.
|
237
237
|
#
|
238
238
|
# Usage:
|
239
239
|
#
|
240
240
|
# @object.avatar.url
|
241
241
|
# @object.avatar.url(:small)
|
242
242
|
# @object.avatar.url(:large)
|
243
|
-
|
243
|
+
|
244
244
|
def path(style = self.default)
|
245
245
|
path = self.attached? ? @path.clone : @missing.clone
|
246
|
-
|
246
|
+
|
247
247
|
path.gsub!(/:name/, name.to_s)
|
248
248
|
path.gsub!(/:style/, style.to_s)
|
249
249
|
path.gsub!(/:extension/, extension(style).to_s)
|
@@ -251,168 +251,168 @@ module Attached
|
|
251
251
|
|
252
252
|
return path
|
253
253
|
end
|
254
|
-
|
255
|
-
|
254
|
+
|
255
|
+
|
256
256
|
# Access the size for an attachment.
|
257
257
|
#
|
258
258
|
# Usage:
|
259
259
|
#
|
260
260
|
# @object.avatar.size
|
261
|
-
|
261
|
+
|
262
262
|
def size
|
263
263
|
return instance_get(:size)
|
264
264
|
end
|
265
|
-
|
266
|
-
|
265
|
+
|
266
|
+
|
267
267
|
# Access the status for an attachment.
|
268
268
|
#
|
269
269
|
# Usage:
|
270
270
|
#
|
271
271
|
# @object.avatar.status
|
272
|
-
|
272
|
+
|
273
273
|
def status
|
274
274
|
instance_get(:status)
|
275
275
|
end
|
276
|
-
|
277
|
-
|
278
|
-
# Access the extension for an attachment. It will first check the styles
|
276
|
+
|
277
|
+
|
278
|
+
# Access the extension for an attachment. It will first check the styles
|
279
279
|
# to see if one is specified before checking the instance.
|
280
280
|
#
|
281
281
|
# Usage:
|
282
282
|
#
|
283
283
|
# @object.avatar.extension
|
284
|
-
|
284
|
+
|
285
285
|
def extension(style = nil)
|
286
286
|
style and
|
287
|
-
self.styles and
|
288
|
-
self.styles[style] and
|
289
|
-
self.styles[style][:extension] or
|
287
|
+
self.styles and
|
288
|
+
self.styles[style] and
|
289
|
+
self.styles[style][:extension] or
|
290
290
|
instance_get(:extension)
|
291
291
|
end
|
292
|
-
|
293
|
-
|
294
|
-
# Access the identifier for an attachment. It will first check the styles
|
292
|
+
|
293
|
+
|
294
|
+
# Access the identifier for an attachment. It will first check the styles
|
295
295
|
# to see if one is specified before checking the instance.
|
296
296
|
#
|
297
297
|
# Usage:
|
298
298
|
#
|
299
299
|
# @object.avatar.identifier
|
300
|
-
|
300
|
+
|
301
301
|
def identifier(style = nil)
|
302
302
|
style and
|
303
|
-
self.styles and
|
304
|
-
self.styles[style] and
|
305
|
-
self.styles[style][:identifier] or
|
303
|
+
self.styles and
|
304
|
+
self.styles[style] and
|
305
|
+
self.styles[style][:identifier] or
|
306
306
|
instance_get(:identifier)
|
307
307
|
end
|
308
|
-
|
309
|
-
|
308
|
+
|
309
|
+
|
310
310
|
# Set the size for an attachment.
|
311
311
|
#
|
312
312
|
# Usage:
|
313
313
|
#
|
314
314
|
# @object.avatar.size = 1024
|
315
|
-
|
315
|
+
|
316
316
|
def size=(size)
|
317
317
|
instance_set(:size, size)
|
318
318
|
end
|
319
|
-
|
320
|
-
|
319
|
+
|
320
|
+
|
321
321
|
# Set the status for an attachment.
|
322
322
|
#
|
323
323
|
# Usage:
|
324
324
|
#
|
325
325
|
# @object.avatar.status = 'processing'
|
326
|
-
|
326
|
+
|
327
327
|
def status=(status)
|
328
328
|
instance_set(:size, status)
|
329
329
|
end
|
330
|
-
|
331
|
-
|
332
|
-
# Set the extension for an attachment. It will act independently of the
|
330
|
+
|
331
|
+
|
332
|
+
# Set the extension for an attachment. It will act independently of the
|
333
333
|
# defined style.
|
334
334
|
#
|
335
335
|
# Usage:
|
336
336
|
#
|
337
337
|
# @object.avatar.extension = ".png"
|
338
|
-
|
338
|
+
|
339
339
|
def extension=(extension)
|
340
340
|
instance_set(:extension, extension)
|
341
341
|
end
|
342
|
-
|
343
|
-
|
344
|
-
# Set the identifier for an attachment. It will act independently of the
|
342
|
+
|
343
|
+
|
344
|
+
# Set the identifier for an attachment. It will act independently of the
|
345
345
|
# defined style.
|
346
346
|
#
|
347
347
|
# Usage:
|
348
348
|
#
|
349
349
|
# @object.avatar.identifier = "1234"
|
350
|
-
|
350
|
+
|
351
351
|
def identifier=(identifier)
|
352
352
|
instance_set(:identifier, identifier)
|
353
353
|
end
|
354
|
-
|
355
|
-
|
354
|
+
|
355
|
+
|
356
356
|
# Access the original file .
|
357
|
-
|
357
|
+
|
358
358
|
def reprocess!
|
359
359
|
self.file = self.storage.retrieve(self.path)
|
360
|
-
|
360
|
+
|
361
361
|
process
|
362
362
|
end
|
363
|
-
|
364
|
-
|
363
|
+
|
364
|
+
|
365
365
|
private
|
366
|
-
|
367
|
-
|
366
|
+
|
367
|
+
|
368
368
|
# Helper function for calling processors (will queue default).
|
369
369
|
#
|
370
370
|
# Usage:
|
371
371
|
#
|
372
372
|
# self.process
|
373
|
-
|
373
|
+
|
374
374
|
def process
|
375
375
|
self.queue[self.default] = self.file
|
376
|
-
|
376
|
+
|
377
377
|
begin
|
378
|
-
|
378
|
+
|
379
379
|
self.processors.each do |processor|
|
380
380
|
processor = Attached::Processor.processor(processor)
|
381
381
|
self.styles.each do |style, options|
|
382
382
|
self.queue[style] = processor.process(self.queue[style] || self.file, options, self)
|
383
383
|
end
|
384
384
|
end
|
385
|
-
|
385
|
+
|
386
386
|
rescue Attached::Processor::Error => error
|
387
387
|
self.errors << error.message
|
388
388
|
end
|
389
389
|
end
|
390
|
-
|
391
|
-
|
390
|
+
|
391
|
+
|
392
392
|
# Helper function for setting instance variables.
|
393
|
-
#
|
393
|
+
#
|
394
394
|
# Usage:
|
395
395
|
#
|
396
396
|
# self.instance_set(size, 12345)
|
397
|
-
|
397
|
+
|
398
398
|
def instance_set(attribute, value)
|
399
399
|
setter = :"#{self.name}_#{attribute}="
|
400
400
|
self.instance.send(setter, value) if instance.respond_to?(setter)
|
401
401
|
end
|
402
|
-
|
403
|
-
|
402
|
+
|
403
|
+
|
404
404
|
# Helper function for getting instance variables.
|
405
405
|
#
|
406
406
|
# Usage:
|
407
407
|
#
|
408
408
|
# self.instance_get(size)
|
409
|
-
|
409
|
+
|
410
410
|
def instance_get(attribute)
|
411
411
|
getter = :"#{self.name}_#{attribute}"
|
412
412
|
self.instance.send(getter) if instance.respond_to?(getter)
|
413
413
|
end
|
414
414
|
|
415
|
-
|
415
|
+
|
416
416
|
end
|
417
|
-
|
417
|
+
|
418
418
|
end
|