card 1.19.0 → 1.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +3 -3
  4. data/config/initializers/{02_extensions → 02_patches}/kaminari.rb +16 -5
  5. data/config/initializers/patches.rb +7 -0
  6. data/config/locales/en.yml +15 -6
  7. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +11 -11
  8. data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +2 -1
  9. data/db/seed/new/card_actions.yml +915 -443
  10. data/db/seed/new/card_acts.yml +348 -186
  11. data/db/seed/new/card_changes.yml +4409 -3329
  12. data/db/seed/new/card_references.yml +220 -3
  13. data/db/seed/new/cards.yml +6687 -3445
  14. data/db/seed/test/fixtures/card_actions.yml +1953 -1513
  15. data/db/seed/test/fixtures/card_acts.yml +615 -453
  16. data/db/seed/test/fixtures/card_changes.yml +7596 -6516
  17. data/db/seed/test/fixtures/card_references.yml +892 -675
  18. data/db/seed/test/fixtures/cards.yml +8803 -5561
  19. data/db/seeds.rb +8 -0
  20. data/lib/card.rb +10 -0
  21. data/lib/card/auth/setup.rb +6 -6
  22. data/lib/card/mod/dirs.rb +13 -3
  23. data/lib/card/set/advanced_api.rb +5 -4
  24. data/lib/cardio.rb +7 -3
  25. data/mod/Modfile +2 -2
  26. data/mod/admin/set/self/admin.rb +47 -30
  27. data/mod/admin/set/self/admin_info.rb +11 -11
  28. data/mod/basic_formats/set/self/head.rb +1 -1
  29. data/mod/{basic_types → basic_formats}/spec/set/all/all_css_spec.rb +0 -0
  30. data/mod/{basic_types → basic_formats}/spec/set/all/all_csv_spec.rb +0 -0
  31. data/mod/{basic_types → basic_formats}/spec/set/all/base_spec.rb +0 -0
  32. data/mod/{basic_types → basic_formats}/spec/set/all/file_spec.rb +0 -0
  33. data/mod/{basic_types → basic_formats}/spec/set/all/json_spec.rb +0 -0
  34. data/mod/{basic_types → basic_formats}/spec/set/all/rss_spec.rb +0 -0
  35. data/mod/{basic_types → basic_formats}/spec/set/all/text_spec.rb +0 -0
  36. data/mod/bootstrap/lib/stylesheets/bootstrap/_variables.scss +1 -1
  37. data/mod/bootstrap/set/all/bootstrap/table.rb +1 -1
  38. data/mod/bootstrap/set/self/bootswatch_shared.rb +1 -1
  39. data/mod/carrierwave/Gemfile +4 -0
  40. data/mod/carrierwave/lib/carrier_wave/cardmount.rb +24 -13
  41. data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +189 -57
  42. data/mod/carrierwave/lib/carrier_wave/image_card_uploader.rb +5 -0
  43. data/mod/carrierwave/set/abstract/attachment.rb +26 -190
  44. data/mod/carrierwave/set/abstract/attachment/paths.rb +50 -0
  45. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +319 -0
  46. data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +77 -0
  47. data/mod/carrierwave/set/all/file_utils.rb +28 -0
  48. data/mod/carrierwave/set/self/admin.rb +23 -0
  49. data/mod/carrierwave/set/type/file.rb +26 -23
  50. data/mod/carrierwave/set/type/image.rb +1 -0
  51. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +67 -0
  52. data/mod/carrierwave/spec/set/type/file_spec.rb +557 -0
  53. data/mod/{standard → carrierwave}/spec/set/type/image_spec.rb +22 -4
  54. data/mod/core/set/abstract/code_file.rb +3 -3
  55. data/mod/core/set/all/debug.rb +23 -0
  56. data/mod/core/set/all/name.rb +1 -1
  57. data/mod/core/set/all/permissions.rb +22 -12
  58. data/mod/core/set/all/tracked_attributes.rb +0 -76
  59. data/mod/core/set/all/trash.rb +50 -0
  60. data/mod/core/set/all/update_read_rules.rb +84 -0
  61. data/mod/core/set/all/utils.rb +1 -75
  62. data/mod/email/set/type_plus_right/user/follow.rb +4 -8
  63. data/mod/history/lib/card/act.rb +3 -1
  64. data/mod/history/lib/card/action.rb +3 -1
  65. data/mod/history/lib/card/action/differ.rb +12 -1
  66. data/mod/history/set/all/history.rb +2 -1
  67. data/mod/machines/file/all_script_machine_output/file.js +211 -0
  68. data/mod/machines/file/all_style_machine_output/file.css +19 -0
  69. data/mod/machines/set/abstract/machine.rb +270 -0
  70. data/mod/machines/set/abstract/machine_input.rb +76 -0
  71. data/mod/machines/set/right/machine_output.rb +9 -1
  72. data/mod/machines/set/type/coffee_script.rb +2 -6
  73. data/mod/machines/set/type/css.rb +2 -2
  74. data/mod/machines/set/type/java_script.rb +2 -2
  75. data/mod/machines/set/type/skin.rb +2 -2
  76. data/mod/machines/spec/set/abstract/machine_spec.rb +10 -0
  77. data/mod/{basic_types → pointer}/spec/set/type/pointer_spec.rb +10 -26
  78. data/mod/settings/set/right/script.rb +1 -1
  79. data/mod/settings/set/right/style.rb +1 -1
  80. data/mod/solid_cache/set/all/solid_cache.rb +1 -1
  81. data/mod/standard/file/credit_image/image-icon.png +0 -0
  82. data/mod/standard/file/credit_image/image-large.png +0 -0
  83. data/mod/standard/file/credit_image/image-medium.png +0 -0
  84. data/mod/standard/file/credit_image/image-small.png +0 -0
  85. data/mod/standard/file/favicon/image-icon.png +0 -0
  86. data/mod/standard/file/favicon/image-large.png +0 -0
  87. data/mod/standard/file/favicon/image-medium.png +0 -0
  88. data/mod/standard/file/favicon/image-small.png +0 -0
  89. data/mod/standard/file/logo/image-icon.png +0 -0
  90. data/mod/standard/file/logo/image-large.png +0 -0
  91. data/mod/standard/file/logo/image-medium.png +0 -0
  92. data/mod/standard/file/logo/image-small.png +0 -0
  93. data/mod/standard/set/all/links.rb +2 -2
  94. data/spec/spec_helper.rb +15 -3
  95. data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin.rb +47 -30
  96. data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin_info.rb +11 -11
  97. data/tmpsets/set/{mod014-admin → mod001-admin}/self/version.rb +0 -0
  98. data/tmpsets/set/{mod001-core → mod002-core}/abstract/code_file.rb +0 -0
  99. data/tmpsets/set/{mod001-core → mod002-core}/all/actify.rb +6 -5
  100. data/tmpsets/set/{mod001-core → mod002-core}/all/active_card.rb +0 -0
  101. data/tmpsets/set/{mod001-core → mod002-core}/all/collection.rb +0 -0
  102. data/tmpsets/set/{mod001-core → mod002-core}/all/content.rb +0 -0
  103. data/tmpsets/set/mod002-core/all/debug.rb +30 -0
  104. data/tmpsets/set/{mod001-core → mod002-core}/all/erb.rb +0 -0
  105. data/tmpsets/set/{mod001-core → mod002-core}/all/event.rb +0 -0
  106. data/tmpsets/set/{mod001-core → mod002-core}/all/export.rb +0 -0
  107. data/tmpsets/set/{mod001-core → mod002-core}/all/fetch.rb +0 -0
  108. data/tmpsets/set/{mod001-core → mod002-core}/all/haml.rb +0 -0
  109. data/tmpsets/set/{mod001-core → mod002-core}/all/initialize.rb +0 -0
  110. data/tmpsets/set/{mod001-core → mod002-core}/all/location_history.rb +0 -0
  111. data/tmpsets/set/{mod001-core → mod002-core}/all/name.rb +1 -1
  112. data/tmpsets/set/{mod001-core → mod002-core}/all/name_validations.rb +0 -0
  113. data/tmpsets/set/{mod001-core → mod002-core}/all/pattern.rb +0 -0
  114. data/tmpsets/set/{mod001-core → mod002-core}/all/permissions.rb +22 -12
  115. data/tmpsets/set/{mod001-core → mod002-core}/all/phases.rb +0 -0
  116. data/tmpsets/set/{mod001-core → mod002-core}/all/references.rb +0 -0
  117. data/tmpsets/set/{mod001-core → mod002-core}/all/rules.rb +0 -0
  118. data/tmpsets/set/{mod001-core → mod002-core}/all/stages.rb +0 -0
  119. data/tmpsets/set/{mod001-core → mod002-core}/all/states.rb +0 -0
  120. data/tmpsets/set/{mod001-core → mod002-core}/all/subcards.rb +0 -0
  121. data/tmpsets/set/{mod001-core → mod002-core}/all/templating.rb +0 -0
  122. data/tmpsets/set/mod002-core/all/tracked_attributes.rb +78 -0
  123. data/tmpsets/set/{mod001-core → mod002-core}/all/trash.rb +50 -0
  124. data/tmpsets/set/{mod001-core → mod002-core}/all/type.rb +0 -0
  125. data/tmpsets/set/mod002-core/all/update_read_rules.rb +91 -0
  126. data/tmpsets/set/mod002-core/all/utils.rb +62 -0
  127. data/tmpsets/set/{mod001-core → mod002-core}/all/view_cache.rb +0 -0
  128. data/tmpsets/set/{mod002-history → mod003-history}/all/actions.rb +0 -0
  129. data/tmpsets/set/{mod002-history → mod003-history}/all/content_history.rb +0 -0
  130. data/tmpsets/set/{mod002-history → mod003-history}/all/history.rb +2 -1
  131. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_css.rb +0 -0
  132. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_csv.rb +0 -0
  133. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_js.rb +0 -0
  134. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/base.rb +0 -0
  135. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/file.rb +0 -0
  136. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/json.rb +0 -0
  137. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/rss.rb +0 -0
  138. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/text.rb +0 -0
  139. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/01_head/javascript.rb +0 -0
  140. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/head.rb +1 -1
  141. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer.rb +0 -0
  142. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer/edit.rb +0 -0
  143. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/code_pointer.rb +0 -0
  144. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_editors.rb +0 -0
  145. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_mods.rb +0 -0
  146. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_pointer_config.rb +0 -0
  147. data/tmpsets/set/{mod004-pointer → mod005-pointer}/type/pointer.rb +0 -0
  148. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/abstract/ace_editor.rb +0 -0
  149. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace.rb +0 -0
  150. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace_config.rb +0 -0
  151. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
  152. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror.rb +0 -0
  153. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
  154. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/abstract/solid_cache.rb +0 -0
  155. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/all/solid_cache.rb +0 -0
  156. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/right/solid_cache.rb +0 -0
  157. data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/html.rb +0 -0
  158. data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/plain_text.rb +0 -0
  159. data/tmpsets/set/mod011-machines/abstract/machine.rb +277 -0
  160. data/tmpsets/set/mod011-machines/abstract/machine_input.rb +83 -0
  161. data/tmpsets/set/{mod010-machines → mod011-machines}/abstract/script.rb +0 -0
  162. data/tmpsets/set/{mod010-machines → mod011-machines}/all/reset_machines.rb +0 -0
  163. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_cache.rb +0 -0
  164. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_input.rb +0 -0
  165. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_output.rb +9 -1
  166. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_card_menu.rb +0 -0
  167. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_html5shiv_printshiv.rb +0 -0
  168. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery.rb +0 -0
  169. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery_helper.rb +0 -0
  170. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_slot.rb +0 -0
  171. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_bootstrap_compatible.rb +0 -0
  172. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_cards.rb +0 -0
  173. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_jquery_ui_smoothness.rb +0 -0
  174. data/tmpsets/set/{mod010-machines → mod011-machines}/type/coffee_script.rb +2 -6
  175. data/tmpsets/set/{mod010-machines → mod011-machines}/type/css.rb +2 -2
  176. data/tmpsets/set/{mod010-machines → mod011-machines}/type/java_script.rb +2 -2
  177. data/tmpsets/set/{mod010-machines → mod011-machines}/type/scss.rb +0 -0
  178. data/tmpsets/set/{mod010-machines → mod011-machines}/type/skin.rb +2 -2
  179. data/tmpsets/set/{mod011-settings → mod012-settings}/abstract/permission.rb +0 -0
  180. data/tmpsets/set/{mod011-settings → mod012-settings}/right/add_help.rb +0 -0
  181. data/tmpsets/set/{mod011-settings → mod012-settings}/right/comment.rb +0 -0
  182. data/tmpsets/set/{mod011-settings → mod012-settings}/right/create.rb +0 -0
  183. data/tmpsets/set/{mod011-settings → mod012-settings}/right/default.rb +0 -0
  184. data/tmpsets/set/{mod011-settings → mod012-settings}/right/delete.rb +0 -0
  185. data/tmpsets/set/{mod011-settings → mod012-settings}/right/help.rb +0 -0
  186. data/tmpsets/set/{mod011-settings → mod012-settings}/right/read.rb +0 -0
  187. data/tmpsets/set/{mod011-settings → mod012-settings}/right/script.rb +1 -1
  188. data/tmpsets/set/{mod011-settings → mod012-settings}/right/structure.rb +0 -0
  189. data/tmpsets/set/{mod011-settings → mod012-settings}/right/style.rb +1 -1
  190. data/tmpsets/set/{mod011-settings → mod012-settings}/right/update.rb +0 -0
  191. data/tmpsets/set/{mod011-settings → mod012-settings}/self/accountable.rb +0 -0
  192. data/tmpsets/set/{mod011-settings → mod012-settings}/self/add_help.rb +0 -0
  193. data/tmpsets/set/{mod011-settings → mod012-settings}/self/autoname.rb +0 -0
  194. data/tmpsets/set/{mod011-settings → mod012-settings}/self/captcha.rb +0 -0
  195. data/tmpsets/set/{mod011-settings → mod012-settings}/self/create.rb +0 -0
  196. data/tmpsets/set/{mod011-settings → mod012-settings}/self/default.rb +0 -0
  197. data/tmpsets/set/{mod011-settings → mod012-settings}/self/default_html_view.rb +0 -0
  198. data/tmpsets/set/{mod011-settings → mod012-settings}/self/delete.rb +0 -0
  199. data/tmpsets/set/{mod011-settings → mod012-settings}/self/follow_fields.rb +0 -0
  200. data/tmpsets/set/{mod011-settings → mod012-settings}/self/help.rb +0 -0
  201. data/tmpsets/set/{mod011-settings → mod012-settings}/self/input.rb +0 -0
  202. data/tmpsets/set/{mod011-settings → mod012-settings}/self/layout.rb +0 -0
  203. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_create.rb +0 -0
  204. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_delete.rb +0 -0
  205. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_update.rb +0 -0
  206. data/tmpsets/set/{mod011-settings → mod012-settings}/self/options.rb +0 -0
  207. data/tmpsets/set/{mod011-settings → mod012-settings}/self/options_label.rb +0 -0
  208. data/tmpsets/set/{mod011-settings → mod012-settings}/self/read.rb +0 -0
  209. data/tmpsets/set/{mod011-settings → mod012-settings}/self/recent_settings.rb +0 -0
  210. data/tmpsets/set/{mod011-settings → mod012-settings}/self/script.rb +0 -0
  211. data/tmpsets/set/{mod011-settings → mod012-settings}/self/structure.rb +0 -0
  212. data/tmpsets/set/{mod011-settings → mod012-settings}/self/style.rb +0 -0
  213. data/tmpsets/set/{mod011-settings → mod012-settings}/self/table_of_contents.rb +0 -0
  214. data/tmpsets/set/{mod011-settings → mod012-settings}/self/thanks.rb +0 -0
  215. data/tmpsets/set/{mod011-settings → mod012-settings}/self/update.rb +0 -0
  216. data/tmpsets/set/{mod011-settings → mod012-settings}/type/setting.rb +0 -0
  217. data/tmpsets/set/{mod012-email → mod013-email}/all/email_html.rb +0 -0
  218. data/tmpsets/set/{mod012-email → mod013-email}/all/email_text.rb +0 -0
  219. data/tmpsets/set/{mod012-email → mod013-email}/all/follow.rb +0 -0
  220. data/tmpsets/set/{mod012-email → mod013-email}/all/notify.rb +0 -0
  221. data/tmpsets/set/{mod012-email → mod013-email}/all/observer.rb +0 -0
  222. data/tmpsets/set/{mod012-email → mod013-email}/right/bcc.rb +0 -0
  223. data/tmpsets/set/{mod012-email → mod013-email}/right/cc.rb +0 -0
  224. data/tmpsets/set/{mod012-email → mod013-email}/right/follow.rb +0 -0
  225. data/tmpsets/set/{mod012-email → mod013-email}/right/follow_fields.rb +0 -0
  226. data/tmpsets/set/{mod012-email → mod013-email}/right/followers.rb +0 -0
  227. data/tmpsets/set/{mod012-email → mod013-email}/right/following.rb +0 -0
  228. data/tmpsets/set/{mod012-email → mod013-email}/right/from.rb +0 -0
  229. data/tmpsets/set/{mod012-email → mod013-email}/right/html_message.rb +0 -0
  230. data/tmpsets/set/{mod012-email → mod013-email}/right/to.rb +0 -0
  231. data/tmpsets/set/{mod012-email → mod013-email}/self/always.rb +0 -0
  232. data/tmpsets/set/{mod012-email → mod013-email}/self/created.rb +0 -0
  233. data/tmpsets/set/{mod012-email → mod013-email}/self/edited.rb +0 -0
  234. data/tmpsets/set/{mod012-email → mod013-email}/self/follow.rb +0 -0
  235. data/tmpsets/set/{mod012-email → mod013-email}/self/follow_defaults.rb +0 -0
  236. data/tmpsets/set/{mod012-email → mod013-email}/self/never.rb +0 -0
  237. data/tmpsets/set/{mod012-email → mod013-email}/type/email_template.rb +0 -0
  238. data/tmpsets/set/{mod012-email → mod013-email}/type_plus_right/user/follow.rb +4 -8
  239. data/tmpsets/set/{mod015-developer → mod014-developer}/all/event_viz.rb +0 -0
  240. data/tmpsets/set/{mod015-developer → mod014-developer}/all/view_viz.rb +0 -0
  241. data/tmpsets/set/{mod015-developer → mod014-developer}/right/debug.rb +0 -0
  242. data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +118 -0
  243. data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +57 -0
  244. data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +326 -0
  245. data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +84 -0
  246. data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +35 -0
  247. data/tmpsets/set/mod015-carrierwave/self/admin.rb +30 -0
  248. data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/file.rb +27 -24
  249. data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/image.rb +1 -0
  250. data/tmpsets/set/mod016-standard/all/links.rb +2 -2
  251. data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
  252. data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
  253. data/vendor/carrierwave/.gitignore +19 -0
  254. data/vendor/carrierwave/.rubocop.yml +262 -0
  255. data/vendor/carrierwave/.travis.yml +58 -0
  256. data/vendor/carrierwave/CHANGELOG.md +81 -0
  257. data/vendor/carrierwave/CONTRIBUTING.md +37 -0
  258. data/vendor/carrierwave/Gemfile +5 -0
  259. data/vendor/carrierwave/README.md +995 -0
  260. data/vendor/carrierwave/Rakefile +26 -0
  261. data/vendor/carrierwave/carrierwave.gemspec +45 -0
  262. data/vendor/carrierwave/cucumber.yml +2 -0
  263. data/vendor/carrierwave/features/caching.feature +28 -0
  264. data/vendor/carrierwave/features/download.feature +20 -0
  265. data/vendor/carrierwave/features/file_storage.feature +37 -0
  266. data/vendor/carrierwave/features/file_storage_overridden_filename.feature +38 -0
  267. data/vendor/carrierwave/features/file_storage_overridden_store_dir.feature +38 -0
  268. data/vendor/carrierwave/features/file_storage_reversing_processor.feature +43 -0
  269. data/vendor/carrierwave/features/fixtures/bork.txt +1 -0
  270. data/vendor/carrierwave/features/fixtures/monkey.txt +1 -0
  271. data/vendor/carrierwave/features/fixtures/upcased_bork.txt +1 -0
  272. data/vendor/carrierwave/features/mount_activerecord.feature +46 -0
  273. data/vendor/carrierwave/features/step_definitions/activerecord_steps.rb +20 -0
  274. data/vendor/carrierwave/features/step_definitions/caching_steps.rb +12 -0
  275. data/vendor/carrierwave/features/step_definitions/datamapper_steps.rb +27 -0
  276. data/vendor/carrierwave/features/step_definitions/download_steps.rb +8 -0
  277. data/vendor/carrierwave/features/step_definitions/file_steps.rb +51 -0
  278. data/vendor/carrierwave/features/step_definitions/general_steps.rb +102 -0
  279. data/vendor/carrierwave/features/step_definitions/mount_steps.rb +17 -0
  280. data/vendor/carrierwave/features/step_definitions/store_steps.rb +16 -0
  281. data/vendor/carrierwave/features/support/activerecord.rb +18 -0
  282. data/vendor/carrierwave/features/support/env.rb +19 -0
  283. data/vendor/carrierwave/features/versions_basics.feature +50 -0
  284. data/vendor/carrierwave/features/versions_caching_from_versions.feature +32 -0
  285. data/vendor/carrierwave/features/versions_nested_versions.feature +70 -0
  286. data/vendor/carrierwave/features/versions_overridden_filename.feature +51 -0
  287. data/vendor/carrierwave/features/versions_overriden_store_dir.feature +41 -0
  288. data/vendor/carrierwave/gemfiles/rails-4-0-stable.gemfile +5 -0
  289. data/vendor/carrierwave/gemfiles/rails-4-1-stable.gemfile +5 -0
  290. data/vendor/carrierwave/gemfiles/rails-4-2-stable.gemfile +5 -0
  291. data/vendor/carrierwave/gemfiles/rails-master.gemfile +11 -0
  292. data/vendor/carrierwave/lib/carrierwave.rb +93 -0
  293. data/vendor/carrierwave/lib/carrierwave/compatibility/paperclip.rb +103 -0
  294. data/vendor/carrierwave/lib/carrierwave/error.rb +8 -0
  295. data/vendor/carrierwave/lib/carrierwave/locale/cs.yml +14 -0
  296. data/vendor/carrierwave/lib/carrierwave/locale/de.yml +14 -0
  297. data/vendor/carrierwave/lib/carrierwave/locale/el.yml +14 -0
  298. data/vendor/carrierwave/lib/carrierwave/locale/en.yml +14 -0
  299. data/vendor/carrierwave/lib/carrierwave/locale/es.yml +14 -0
  300. data/vendor/carrierwave/lib/carrierwave/locale/fr-CA.yml +14 -0
  301. data/vendor/carrierwave/lib/carrierwave/locale/fr.yml +14 -0
  302. data/vendor/carrierwave/lib/carrierwave/locale/id.yml +14 -0
  303. data/vendor/carrierwave/lib/carrierwave/locale/ja.yml +14 -0
  304. data/vendor/carrierwave/lib/carrierwave/locale/nb.yml +14 -0
  305. data/vendor/carrierwave/lib/carrierwave/locale/nl.yml +14 -0
  306. data/vendor/carrierwave/lib/carrierwave/locale/pl.yml +14 -0
  307. data/vendor/carrierwave/lib/carrierwave/locale/pt-BR.yml +14 -0
  308. data/vendor/carrierwave/lib/carrierwave/locale/pt-PT.yml +14 -0
  309. data/vendor/carrierwave/lib/carrierwave/locale/ru.yml +14 -0
  310. data/vendor/carrierwave/lib/carrierwave/locale/sk.yml +14 -0
  311. data/vendor/carrierwave/lib/carrierwave/locale/tr.yml +14 -0
  312. data/vendor/carrierwave/lib/carrierwave/locale/zh-CN.yml +14 -0
  313. data/vendor/carrierwave/lib/carrierwave/locale/zh-TW.yml +14 -0
  314. data/vendor/carrierwave/lib/carrierwave/mount.rb +444 -0
  315. data/vendor/carrierwave/lib/carrierwave/mounter.rb +163 -0
  316. data/vendor/carrierwave/lib/carrierwave/orm/activerecord.rb +103 -0
  317. data/vendor/carrierwave/lib/carrierwave/processing.rb +2 -0
  318. data/vendor/carrierwave/lib/carrierwave/processing/mini_magick.rb +328 -0
  319. data/vendor/carrierwave/lib/carrierwave/processing/rmagick.rb +379 -0
  320. data/vendor/carrierwave/lib/carrierwave/sanitized_file.rb +348 -0
  321. data/vendor/carrierwave/lib/carrierwave/storage.rb +2 -0
  322. data/vendor/carrierwave/lib/carrierwave/storage/abstract.rb +43 -0
  323. data/vendor/carrierwave/lib/carrierwave/storage/file.rb +118 -0
  324. data/vendor/carrierwave/lib/carrierwave/storage/fog.rb +462 -0
  325. data/vendor/carrierwave/lib/carrierwave/test/matchers.rb +394 -0
  326. data/vendor/carrierwave/lib/carrierwave/uploader.rb +67 -0
  327. data/vendor/carrierwave/lib/carrierwave/uploader/cache.rb +207 -0
  328. data/vendor/carrierwave/lib/carrierwave/uploader/callbacks.rb +33 -0
  329. data/vendor/carrierwave/lib/carrierwave/uploader/configuration.rb +203 -0
  330. data/vendor/carrierwave/lib/carrierwave/uploader/content_type_blacklist.rb +48 -0
  331. data/vendor/carrierwave/lib/carrierwave/uploader/content_type_whitelist.rb +48 -0
  332. data/vendor/carrierwave/lib/carrierwave/uploader/default_url.rb +17 -0
  333. data/vendor/carrierwave/lib/carrierwave/uploader/download.rb +92 -0
  334. data/vendor/carrierwave/lib/carrierwave/uploader/extension_blacklist.rb +51 -0
  335. data/vendor/carrierwave/lib/carrierwave/uploader/extension_whitelist.rb +51 -0
  336. data/vendor/carrierwave/lib/carrierwave/uploader/file_size.rb +41 -0
  337. data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_blacklist.rb +94 -0
  338. data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_whitelist.rb +94 -0
  339. data/vendor/carrierwave/lib/carrierwave/uploader/mountable.rb +38 -0
  340. data/vendor/carrierwave/lib/carrierwave/uploader/processing.rb +88 -0
  341. data/vendor/carrierwave/lib/carrierwave/uploader/proxy.rb +86 -0
  342. data/vendor/carrierwave/lib/carrierwave/uploader/remove.rb +21 -0
  343. data/vendor/carrierwave/lib/carrierwave/uploader/serialization.rb +28 -0
  344. data/vendor/carrierwave/lib/carrierwave/uploader/store.rb +93 -0
  345. data/vendor/carrierwave/lib/carrierwave/uploader/url.rb +41 -0
  346. data/vendor/carrierwave/lib/carrierwave/uploader/versions.rb +295 -0
  347. data/vendor/carrierwave/lib/carrierwave/utilities.rb +6 -0
  348. data/vendor/carrierwave/lib/carrierwave/utilities/uri.rb +21 -0
  349. data/vendor/carrierwave/lib/carrierwave/validations/active_model.rb +78 -0
  350. data/vendor/carrierwave/lib/carrierwave/version.rb +3 -0
  351. data/vendor/carrierwave/lib/generators/templates/uploader.rb +49 -0
  352. data/vendor/carrierwave/lib/generators/uploader_generator.rb +7 -0
  353. data/vendor/carrierwave/script/console +10 -0
  354. data/vendor/carrierwave/script/destroy +14 -0
  355. data/vendor/carrierwave/script/generate +14 -0
  356. data/vendor/carrierwave/spec/compatibility/paperclip_spec.rb +138 -0
  357. data/vendor/carrierwave/spec/fixtures/Uppercase.jpg +1 -0
  358. data/vendor/carrierwave/spec/fixtures/bork.ttxt +1 -0
  359. data/vendor/carrierwave/spec/fixtures/bork.txt +1 -0
  360. data/vendor/carrierwave/spec/fixtures/bork.txtt +1 -0
  361. data/vendor/carrierwave/spec/fixtures/case.JPG +1 -0
  362. data/vendor/carrierwave/spec/fixtures/landscape.jpg +0 -0
  363. data/vendor/carrierwave/spec/fixtures/multi_page.pdf +0 -0
  364. data/vendor/carrierwave/spec/fixtures/new.jpeg +1 -0
  365. data/vendor/carrierwave/spec/fixtures/new.txt +1 -0
  366. data/vendor/carrierwave/spec/fixtures/old.jpeg +1 -0
  367. data/vendor/carrierwave/spec/fixtures/old.txt +1 -0
  368. data/vendor/carrierwave/spec/fixtures/portrait.jpg +0 -0
  369. data/vendor/carrierwave/spec/fixtures/ruby.gif +0 -0
  370. data/vendor/carrierwave/spec/fixtures/sponsored.doc +1 -0
  371. data/vendor/carrierwave/spec/fixtures/test+.jpg +1 -0
  372. data/vendor/carrierwave/spec/fixtures/test.jpeg +1 -0
  373. data/vendor/carrierwave/spec/fixtures/test.jpg +1 -0
  374. data/vendor/carrierwave/spec/generators/uploader_generator_spec.rb +19 -0
  375. data/vendor/carrierwave/spec/mount_multiple_spec.rb +913 -0
  376. data/vendor/carrierwave/spec/mount_single_spec.rb +793 -0
  377. data/vendor/carrierwave/spec/orm/activerecord_spec.rb +1556 -0
  378. data/vendor/carrierwave/spec/processing/mini_magick_spec.rb +210 -0
  379. data/vendor/carrierwave/spec/processing/rmagick_spec.rb +250 -0
  380. data/vendor/carrierwave/spec/sanitized_file_spec.rb +805 -0
  381. data/vendor/carrierwave/spec/spec_helper.rb +105 -0
  382. data/vendor/carrierwave/spec/storage/file_spec.rb +82 -0
  383. data/vendor/carrierwave/spec/storage/fog_credentials.rb +46 -0
  384. data/vendor/carrierwave/spec/storage/fog_helper.rb +428 -0
  385. data/vendor/carrierwave/spec/storage/fog_spec.rb +48 -0
  386. data/vendor/carrierwave/spec/support/activerecord.rb +31 -0
  387. data/vendor/carrierwave/spec/support/file_utils_helper.rb +15 -0
  388. data/vendor/carrierwave/spec/uploader/cache_spec.rb +324 -0
  389. data/vendor/carrierwave/spec/uploader/callback_spec.rb +30 -0
  390. data/vendor/carrierwave/spec/uploader/configuration_spec.rb +133 -0
  391. data/vendor/carrierwave/spec/uploader/content_type_blacklist_spec.rb +61 -0
  392. data/vendor/carrierwave/spec/uploader/content_type_whitelist_spec.rb +63 -0
  393. data/vendor/carrierwave/spec/uploader/default_url_spec.rb +77 -0
  394. data/vendor/carrierwave/spec/uploader/download_spec.rb +204 -0
  395. data/vendor/carrierwave/spec/uploader/extension_blacklist_spec.rb +112 -0
  396. data/vendor/carrierwave/spec/uploader/extension_whitelist_spec.rb +102 -0
  397. data/vendor/carrierwave/spec/uploader/file_size_spec.rb +52 -0
  398. data/vendor/carrierwave/spec/uploader/mountable_spec.rb +26 -0
  399. data/vendor/carrierwave/spec/uploader/overrides_spec.rb +71 -0
  400. data/vendor/carrierwave/spec/uploader/paths_spec.rb +18 -0
  401. data/vendor/carrierwave/spec/uploader/processing_spec.rb +159 -0
  402. data/vendor/carrierwave/spec/uploader/proxy_spec.rb +79 -0
  403. data/vendor/carrierwave/spec/uploader/remove_spec.rb +71 -0
  404. data/vendor/carrierwave/spec/uploader/store_spec.rb +400 -0
  405. data/vendor/carrierwave/spec/uploader/url_spec.rb +273 -0
  406. data/vendor/carrierwave/spec/uploader/versions_spec.rb +633 -0
  407. metadata +339 -187
  408. data/config/initializers/extensions.rb +0 -3
  409. data/mod/05_standard/file/favicon/image-icon.png +0 -0
  410. data/mod/05_standard/file/favicon/image-large.png +0 -0
  411. data/mod/05_standard/file/favicon/image-medium.png +0 -0
  412. data/mod/05_standard/file/favicon/image-original.png +0 -0
  413. data/mod/05_standard/file/favicon/image-small.png +0 -0
  414. data/mod/machines/lib/card/machine.rb +0 -261
  415. data/mod/machines/lib/card/machine_input.rb +0 -80
  416. data/mod/standard/file/credit/icon-image.png +0 -0
  417. data/mod/standard/file/credit/large-image.png +0 -0
  418. data/mod/standard/file/credit/medium-image.png +0 -0
  419. data/mod/standard/file/credit/original-image.png +0 -0
  420. data/mod/standard/file/credit/small-image.png +0 -0
  421. data/mod/standard/spec/set/type/file_spec.rb +0 -99
  422. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +0 -154
  423. data/tmpsets/set/mod001-core/all/utils.rb +0 -132
  424. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +0 -282
@@ -0,0 +1,81 @@
1
+ # Carrierwave History/Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+ * Add a test matcher for the format (@yanivpr [#1758](https://github.com/carrierwaveuploader/carrierwave/pull/1758))
10
+ * Support of MiniMagick's Combine options (@bernabas [#1754](https://github.com/carrierwaveuploader/carrierwave/pull/1754))
11
+ * Validate with the actual content-type of files (@eavgerinos)
12
+ * Support for multiple file uploads with `mount_uploaders` method (@jnicklas and @lisarutan [#1481](https://github.com/carrierwaveuploader/carrierwave/pull/1481))
13
+ * Add a `cache_only` configuration option, useful for testing (@jeffkreeftmeijer [#1456](https://github.com/carrierwaveuploader/carrierwave/pull/1456))
14
+ * Add `#width` and `#height` methods to MiniMagick processor (@ShivaVS [#1405](https://github.com/carrierwaveuploader/carrierwave/pull/1405))
15
+ * Add `#width` and `#height` methods to the RMagick processor (@mehlah [#1805](https://github.com/carrierwaveuploader/carrierwave/pull/1805))
16
+ * Support for jRuby (@lephyrius [#1377](https://github.com/carrierwaveuploader/carrierwave/pull/1377))
17
+ * Make cache storage configurable (@mshibuya [#1312](https://github.com/carrierwaveuploader/carrierwave/pull/1312))
18
+ * Errors on file size (@gautampunhani [#1026](https://github.com/carrierwaveuploader/carrierwave/pull/1026))
19
+ * Add Indonesian, Taiwanese and Chinese i18n translations for errors (@saveav, @st0012, @msyesyan)
20
+
21
+ ### Changed
22
+ * [BREAKING CHANGE] Allow non-ASCII filename by default (@shuhei [#1772](https://github.com/carrierwaveuploader/carrierwave/pull/1772))
23
+ * [BREAKING CHANGE] `to_json` behavior changed when serializing an uploader (@jnicklas and @lisarutan [#1481](https://github.com/carrierwaveuploader/carrierwave/pull/1481))
24
+ * [BREAKING CHANGE] Rename `extension_white_list` ~> `extension_whitelist` (@mehlah [#1819](https://github.com/carrierwaveuploader/carrierwave/pull/1819))
25
+ * [BREAKING CHANGE] Rename `extension_black_list` ~> `extension_blacklist` (@mehlah [#1819](https://github.com/carrierwaveuploader/carrierwave/pull/1819))
26
+ * [BREAKING CHANGE] Rename i18n keys `extension_black_list_error` ~> `extension_blacklist_error` and `extension_white_list_error` ~> `extension_whitelist_error` (@mehlah)
27
+ * Better error when the configured storage is unknown (@st0012 [#1779](https://github.com/carrierwaveuploader/carrierwave/pull/1779))
28
+ * Allow to pass additionnal options to Rackspace `authenticated_url` (@duhast [#1722](https://github.com/carrierwaveuploader/carrierwave/pull/1722))
29
+ * Reduced memory footprint (@schneems [#1652](https://github.com/carrierwaveuploader/carrierwave/pull/1652), @simonprev [#1706](https://github.com/carrierwaveuploader/carrierwave/pull/1706))
30
+ * Improve Fog Loading (@plribeiro3000 [#1620](https://github.com/carrierwaveuploader/carrierwave/pull/1620), @eavgerinos)
31
+ * All locales from `config.i18n.available_locales` are added to load_path (@printercu [#1521](https://github.com/carrierwaveuploader/carrierwave/pull/1521))
32
+ * Do not display RMagick exception in I18n message (manuelpradal [#1361](https://github.com/carrierwaveuploader/carrierwave/pull/1361))
33
+ * `#default_url` now accepts the same args passed to `#url` (@shekibobo [#1347](https://github.com/carrierwaveuploader/carrierwave/pull/1347))
34
+ * Accept an array of strings or regexps to white/blacklist content types (@mehlah [#1816](https://github.com/carrierwaveuploader/carrierwave/pull/1816))
35
+ * `#content_type_whitelist` and `extension_whitelist` now takes either a string, a regexp, or an array of values (same thing for blacklists) (@mehlah [#1825](https://github.com/carrierwaveuploader/carrierwave/pull/1825))
36
+ * Blank uploaders are now memoized on the model instance (@DarthSim [#1860](https://github.com/carrierwaveuploader/carrierwave/pull/1860))
37
+
38
+ ### Removed
39
+ * Remove `CarrierWave::MimeTypes` processor module (@mehlah [#1813](https://github.com/carrierwaveuploader/carrierwave/pull/1813))
40
+ * Remove `CarrierWave::MagicMimeTypes` processor module (@mehlah [#1816](https://github.com/carrierwaveuploader/carrierwave/pull/1816))
41
+ * Remove dependency on `ruby-filemagic` in white/blacklist content types (@mehlah [#1816](https://github.com/carrierwaveuploader/carrierwave/pull/1816))
42
+
43
+ ### Fixed
44
+ * Fix `Mounter.blank?` method (@Bonias [#1746](https://github.com/carrierwaveuploader/carrierwave/pull/1746))
45
+ * Reset `remove_#{column}` after invoking `remove_#{column}` (@eavgerinos [#1668](https://github.com/carrierwaveuploader/carrierwave/pull/1668))
46
+ * Change Google's url to the `public_url` (@m7moud [#1683](https://github.com/carrierwaveuploader/carrierwave/pull/1683))
47
+ * Do not write to `ActiveModel::Dirty` changes when assigning something blank to a mounter that was originally blank (@eavgerinos [#1635](https://github.com/carrierwaveuploader/carrierwave/pull/1635))
48
+ * Various grammar and typos fixes to error messages translations
49
+ * Don't error when size is called on a deleted file (@danielevans [#1561](https://github.com/carrierwaveuploader/carrierwave/pull/1561))
50
+ * Flush mounters on `#dup` of active record model (@danielevans [#1544](https://github.com/carrierwaveuploader/carrierwave/pull/1544))
51
+ * `Fog::File.read` returns its contents after upload instead of "closed stream" error (@stormsilver [#1517](https://github.com/carrierwaveuploader/carrierwave/pull/1517))
52
+ * Don't read file twice when calling `sanitized_file` or `cache!` (@felixbuenemann [#1476](https://github.com/carrierwaveuploader/carrierwave/pull/1476))
53
+ * Change image extension when converting formats (@nashby [#1446](https://github.com/carrierwaveuploader/carrierwave/pull/1446))
54
+ * Fix file delete being called twice on remove (@adamcrown [#1441](https://github.com/carrierwaveuploader/carrierwave/pull/1441))
55
+ * RSpec 3 support (@randoum #1421[](https://github.com/carrierwaveuploader/carrierwave/pull/1421), @akiomik [#1370](https://github.com/carrierwaveuploader/carrierwave/pull/1370))
56
+ * MiniMagick convert to a format all the pages by default and accept an optional page number parameter to convert specific pages (@harikrishnan83 [#1408](https://github.com/carrierwaveuploader/carrierwave/pull/1408))
57
+ * Fix cache workfile collision between versions (@jvdp [#1399](https://github.com/carrierwaveuploader/carrierwave/pull/1399))
58
+ * Reset mounter cache on record reload (@semenyukdmitriy [#1383](https://github.com/carrierwaveuploader/carrierwave/pull/1383))
59
+ * Retrieve only active versions of files (@filipegiusti [#1351](https://github.com/carrierwaveuploader/carrierwave/pull/1351))
60
+ * Fix default gravity in MiniMagick `resize_and_pad` (@abevoelker [#1358](https://github.com/carrierwaveuploader/carrierwave/pull/1358))
61
+ * Skip loading RMagick if already loaded (@mshibuya [#1346](https://github.com/carrierwaveuploader/carrierwave/pull/1346))
62
+ * Make the `#remove_#{column}` accessor set the mounted column as changed (@nikz [#1326](https://github.com/carrierwaveuploader/carrierwave/pull/1326))
63
+ * Tempfile and @content_type assignment (@bensie [#1487](https://github.com/carrierwaveuploader/carrierwave/issues/1487))
64
+
65
+ ## 0.11.0 - 2016-03-29
66
+
67
+ ### Added
68
+
69
+ ### Changed
70
+ * `cache_id` is now less collision-prone thanks to a counter (@stillwaiting and @mtsmfm [#1866](https://github.com/carrierwaveuploader/carrierwave/pull/1866))
71
+
72
+ ### Removed
73
+
74
+ ### Fixed
75
+ * Fix require RMagick deprecation warning (@thomasfedb and @bensie [#1788](https://github.com/carrierwaveuploader/carrierwave/pull/1788))
76
+
77
+ ## 0.10.0 - 2014-02-26
78
+
79
+ Please check [0.10-stable] for previous changes.
80
+
81
+ [0.10-stable]: https://github.com/carrierwaveuploader/carrierwave/blob/0.10-stable/History.txt
@@ -0,0 +1,37 @@
1
+ # Contributing to CarrierWave
2
+
3
+ CarrierWave thrives on a large number of [contributors](https://github.com/carrierwaveuploader/carrierwave/contributors),
4
+ and pull requests are very welcome. Before submitting a pull request, please make sure that your changes are well tested.
5
+
6
+ First, make sure you have `imagemagick` and `ghostscript` installed. You may need `libmagic` as well.
7
+
8
+ Then, you'll need to install bundler and the gem dependencies:
9
+
10
+ `gem install bundler && bundle install`
11
+
12
+ You should now be able to run the local tests:
13
+
14
+ `bundle exec rake`
15
+
16
+ You can also run the remote specs by creating a ~/.fog file:
17
+
18
+ ```yaml
19
+ :carrierwave:
20
+ :aws_access_key_id: xxx
21
+ :aws_secret_access_key: yyy
22
+ :rackspace_username: xxx
23
+ :rackspace_api_key: yyy
24
+ :google_storage_access_key_id: xxx
25
+ :google_storage_secret_access_key: yyy
26
+ ```
27
+
28
+ You should now be able to run the remote tests:
29
+
30
+ REMOTE=true bundle exec rake
31
+
32
+ Please test with the latest Ruby 2.2.x version using RVM if possible.
33
+
34
+ ## Running active record tests
35
+
36
+ Make sure you have a local PostgreSQL database named `carrierwave_test` with the username
37
+ `postgres`
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activemodel-serializers-xml"
4
+
5
+ gemspec
@@ -0,0 +1,995 @@
1
+ # CarrierWave
2
+
3
+ This gem provides a simple and extremely flexible way to upload files from Ruby applications.
4
+ It works well with Rack based web applications, such as Ruby on Rails.
5
+
6
+ [![Build Status](https://travis-ci.org/carrierwaveuploader/carrierwave.svg?branch=master)](http://travis-ci.org/carrierwaveuploader/carrierwave)
7
+ [![Code Climate](http://img.shields.io/codeclimate/github/carrierwaveuploader/carrierwave.svg)](https://codeclimate.com/github/carrierwaveuploader/carrierwave)
8
+
9
+
10
+ > ## carrierwave version disclaimer
11
+ > ***This README is for a branch which is still in development.
12
+ > Please switch to latest `0.x` branch for stable version.***
13
+
14
+
15
+ ## Information
16
+
17
+ * RDoc documentation [available on RubyDoc.info](http://rubydoc.info/gems/carrierwave/frames)
18
+ * Source code [available on GitHub](http://github.com/carrierwaveuploader/carrierwave)
19
+ * More information, known limitations, and how-tos [available on the wiki](https://github.com/carrierwaveuploader/carrierwave/wiki)
20
+
21
+ ## Getting Help
22
+
23
+ * Please ask the community on [Stack Overflow](http://stackoverflow.com/) for help if you have any questions. Please do not post usage questions on the issue tracker.
24
+ * Please report bugs on the [issue tracker](http://github.com/carrierwaveuploader/carrierwave/issues) but read the "getting help" section in the wiki first.
25
+
26
+ ## Installation
27
+
28
+ Install the latest stable release:
29
+
30
+ ```
31
+ $ gem install carrierwave
32
+ ```
33
+
34
+ In Rails, add it to your Gemfile:
35
+
36
+ ```ruby
37
+ gem 'carrierwave'
38
+ ```
39
+
40
+ Finally, restart the server to apply the changes.
41
+
42
+ As of version 1.0.0 (forthcoming), CarrierWave requires Rails 4.0 or higher and Ruby 2.0
43
+ or higher. If you're on Rails 3, you should use v0.11.0.
44
+
45
+ ## Getting Started
46
+
47
+ Start off by generating an uploader:
48
+
49
+ rails generate uploader Avatar
50
+
51
+ this should give you a file in:
52
+
53
+ app/uploaders/avatar_uploader.rb
54
+
55
+ Check out this file for some hints on how you can customize your uploader. It
56
+ should look something like this:
57
+
58
+ ```ruby
59
+ class AvatarUploader < CarrierWave::Uploader::Base
60
+ storage :file
61
+ end
62
+ ```
63
+
64
+ You can use your uploader class to store and retrieve files like this:
65
+
66
+ ```ruby
67
+ uploader = AvatarUploader.new
68
+
69
+ uploader.store!(my_file)
70
+
71
+ uploader.retrieve_from_store!('my_file.png')
72
+ ```
73
+
74
+ CarrierWave gives you a `store` for permanent storage, and a `cache` for
75
+ temporary storage. You can use different stores, including filesystem
76
+ and cloud storage.
77
+
78
+ Most of the time you are going to want to use CarrierWave together with an ORM.
79
+ It is quite simple to mount uploaders on columns in your model, so you can
80
+ simply assign files and get going:
81
+
82
+ ### ActiveRecord
83
+
84
+ Make sure you are loading CarrierWave after loading your ORM, otherwise you'll
85
+ need to require the relevant extension manually, e.g.:
86
+
87
+ ```ruby
88
+ require 'carrierwave/orm/activerecord'
89
+ ```
90
+
91
+ Add a string column to the model you want to mount the uploader by creating
92
+ a migration:
93
+
94
+
95
+ rails g migration add_avatar_to_users avatar:string
96
+ rake db:migrate
97
+
98
+ Open your model file and mount the uploader:
99
+
100
+ ```ruby
101
+ class User < ActiveRecord::Base
102
+ mount_uploader :avatar, AvatarUploader
103
+ end
104
+ ```
105
+
106
+ Now you can cache files by assigning them to the attribute, they will
107
+ automatically be stored when the record is saved.
108
+
109
+ ```ruby
110
+ u = User.new
111
+ u.avatar = params[:file] # Assign a file like this, or
112
+
113
+ # like this
114
+ File.open('somewhere') do |f|
115
+ u.avatar = f
116
+ end
117
+
118
+ u.save!
119
+ u.avatar.url # => '/url/to/file.png'
120
+ u.avatar.current_path # => 'path/to/file.png'
121
+ u.avatar_identifier # => 'file.png'
122
+ ```
123
+
124
+ **Note**: `u.avatar` will never return nil, even if there is no photo associated to it.
125
+ To check if a photo was saved to the model, use `u.avatar.file.nil?` instead.
126
+
127
+ ### DataMapper, Mongoid, Sequel
128
+
129
+ Other ORM support has been extracted into separate gems:
130
+
131
+ * [carrierwave-datamapper](https://github.com/carrierwaveuploader/carrierwave-datamapper)
132
+ * [carrierwave-mongoid](https://github.com/carrierwaveuploader/carrierwave-mongoid)
133
+ * [carrierwave-sequel](https://github.com/carrierwaveuploader/carrierwave-sequel)
134
+
135
+ There are more extensions listed in [the wiki](https://github.com/carrierwaveuploader/carrierwave/wiki)
136
+
137
+ ## Multiple file uploads
138
+ **Note:** You must specify using the master branch to enable this feature:
139
+
140
+ `gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'`.
141
+
142
+ CarrierWave also has convenient support for multiple file upload fields.
143
+
144
+ ### ActiveRecord
145
+
146
+ Add a column which can store an array. This could be an array column or a JSON
147
+ column for example. Your choice depends on what your database supports. For
148
+ example, create a migration like this:
149
+
150
+
151
+ rails g migration add_avatars_to_users avatars:json
152
+ rake db:migrate
153
+
154
+ Open your model file and mount the uploader:
155
+
156
+ ```ruby
157
+ class User < ActiveRecord::Base
158
+ mount_uploaders :avatars, AvatarUploader
159
+ end
160
+ ```
161
+
162
+ Make sure your file input fields are set up as multiple file fields. For
163
+ example in Rails you'll want to do something like this:
164
+
165
+ ```erb
166
+ <%= form.file_field :avatars, multiple: true %>
167
+ ```
168
+
169
+ Also, make sure your upload controller permits the multiple file upload attribute, *pointing to an empty array in a hash*. For example:
170
+
171
+ ```ruby
172
+ params.require(:user).permit(:email, :first_name, :last_name, {avatars: []})
173
+ ```
174
+
175
+ Now you can select multiple files in the upload dialog (e.g. SHIFT+SELECT), and they will
176
+ automatically be stored when the record is saved.
177
+
178
+ ```ruby
179
+ u = User.new(params[:user])
180
+ u.save!
181
+ u.avatars[0].url # => '/url/to/file.png'
182
+ u.avatars[0].current_path # => 'path/to/file.png'
183
+ u.avatars[0].identifier # => 'file.png'
184
+ ```
185
+
186
+ ## Changing the storage directory
187
+
188
+ In order to change where uploaded files are put, just override the `store_dir`
189
+ method:
190
+
191
+ ```ruby
192
+ class MyUploader < CarrierWave::Uploader::Base
193
+ def store_dir
194
+ 'public/my/upload/directory'
195
+ end
196
+ end
197
+ ```
198
+
199
+ This works for the file storage as well as Amazon S3 and Rackspace Cloud Files.
200
+ Define `store_dir` as `nil` if you'd like to store files at the root level.
201
+
202
+ If you store files outside the project root folder, you may want to define `cache_dir` in the same way:
203
+
204
+ ```ruby
205
+ class MyUploader < CarrierWave::Uploader::Base
206
+ def cache_dir
207
+ '/tmp/projectname-cache'
208
+ end
209
+ end
210
+ ```
211
+
212
+ ## Securing uploads
213
+
214
+ Certain files might be dangerous if uploaded to the wrong location, such as PHP
215
+ files or other script files. CarrierWave allows you to specify a whitelist of
216
+ allowed extensions or content types.
217
+
218
+ If you're mounting the uploader, uploading a file with the wrong extension will
219
+ make the record invalid instead. Otherwise, an error is raised.
220
+
221
+ ```ruby
222
+ class MyUploader < CarrierWave::Uploader::Base
223
+ def extension_whitelist
224
+ %w(jpg jpeg gif png)
225
+ end
226
+ end
227
+ ```
228
+
229
+ The same thing could be done using content types.
230
+ Let's say we need an uploader that accepts only images. This can be done like this
231
+
232
+ ```ruby
233
+ class MyUploader < CarrierWave::Uploader::Base
234
+ def content_type_whitelist
235
+ /image\//
236
+ end
237
+ end
238
+ ```
239
+
240
+ You can use a blacklist to reject content types.
241
+ Let's say we need an uploader that reject JSON files. This can be done like this
242
+
243
+ ```ruby
244
+ class NoJsonUploader < CarrierWave::Uploader::Base
245
+ def content_type_blacklist
246
+ ['application/text', 'application/json']
247
+ end
248
+ end
249
+ ```
250
+
251
+ ### Filenames and unicode chars
252
+
253
+ Another security issue you should care for is the file names (see
254
+ [Ruby On Rails Security Guide](http://guides.rubyonrails.org/security.html#file-uploads)).
255
+ By default, CarrierWave provides only English letters, arabic numerals and some symbols as
256
+ white-listed characters in the file name. If you want to support local scripts (Cyrillic letters, letters with diacritics and so on), you
257
+ have to override `sanitize_regexp` method. It should return regular expression which would match
258
+ all *non*-allowed symbols.
259
+
260
+ ```ruby
261
+ CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
262
+ ```
263
+
264
+ Also make sure that allowing non-latin characters won't cause a compatibility issue with a third-party
265
+ plugins or client-side software.
266
+
267
+ ## Setting the content type
268
+
269
+ As of v0.11.0, the `mime-types` gem is a runtime dependency and the content type is set automatically.
270
+ You no longer need to do this manually.
271
+
272
+ ## Adding versions
273
+
274
+ Often you'll want to add different versions of the same file. The classic example is image thumbnails. There is built in support for this*:
275
+
276
+ *Note:* You must have Imagemagick and MiniMagick installed to do image resizing. MiniMagick is a Ruby interface for Imagemagick which is a C program. This is why MiniMagick fails on 'bundle install' without Imagemagick installed.
277
+
278
+ Some documentation refers to RMagick instead of MiniMagick but MiniMagick is recommended.
279
+
280
+ To install Imagemagick on OSX with homebrew type the following:
281
+
282
+ ```
283
+ $ brew install imagemagick
284
+ ```
285
+
286
+ ```ruby
287
+ class MyUploader < CarrierWave::Uploader::Base
288
+ include CarrierWave::MiniMagick
289
+
290
+ process resize_to_fit: [800, 800]
291
+
292
+ version :thumb do
293
+ process resize_to_fill: [200,200]
294
+ end
295
+
296
+ end
297
+ ```
298
+
299
+ When this uploader is used, an uploaded image would be scaled to be no larger
300
+ than 800 by 800 pixels. A version called thumb is then created, which is scaled
301
+ and cropped to exactly 200 by 200 pixels. The uploader could be used like this:
302
+
303
+ ```ruby
304
+ uploader = AvatarUploader.new
305
+ uploader.store!(my_file) # size: 1024x768
306
+
307
+ uploader.url # => '/url/to/my_file.png' # size: 800x600
308
+ uploader.thumb.url # => '/url/to/thumb_my_file.png' # size: 200x200
309
+ ```
310
+
311
+ One important thing to remember is that process is called *before* versions are
312
+ created. This can cut down on processing cost.
313
+
314
+ It is possible to nest versions within versions:
315
+
316
+ ```ruby
317
+ class MyUploader < CarrierWave::Uploader::Base
318
+
319
+ version :animal do
320
+ version :human
321
+ version :monkey
322
+ version :llama
323
+ end
324
+ end
325
+ ```
326
+
327
+ ### Conditional versions
328
+
329
+ Occasionally you want to restrict the creation of versions on certain
330
+ properties within the model or based on the picture itself.
331
+
332
+ ```ruby
333
+ class MyUploader < CarrierWave::Uploader::Base
334
+
335
+ version :human, if: :is_human?
336
+ version :monkey, if: :is_monkey?
337
+ version :banner, if: :is_landscape?
338
+
339
+ private
340
+
341
+ def is_human? picture
342
+ model.can_program?(:ruby)
343
+ end
344
+
345
+ def is_monkey? picture
346
+ model.favorite_food == 'banana'
347
+ end
348
+
349
+ def is_landscape? picture
350
+ image = MiniMagick::Image.open(picture.path)
351
+ image[:width] > image[:height]
352
+ end
353
+
354
+ end
355
+ ```
356
+
357
+ The `model` variable points to the instance object the uploader is attached to.
358
+
359
+ ### Create versions from existing versions
360
+
361
+ For performance reasons, it is often useful to create versions from existing ones
362
+ instead of using the original file. If your uploader generates several versions
363
+ where the next is smaller than the last, it will take less time to generate from
364
+ a smaller, already processed image.
365
+
366
+ ```ruby
367
+ class MyUploader < CarrierWave::Uploader::Base
368
+
369
+ version :thumb do
370
+ process resize_to_fill: [280, 280]
371
+ end
372
+
373
+ version :small_thumb, from_version: :thumb do
374
+ process resize_to_fill: [20, 20]
375
+ end
376
+
377
+ end
378
+ ```
379
+
380
+ The option `:from_version` uses the file cached in the `:thumb` version instead
381
+ of the original version, potentially resulting in faster processing.
382
+
383
+ ## Making uploads work across form redisplays
384
+
385
+ Often you'll notice that uploaded files disappear when a validation fails.
386
+ CarrierWave has a feature that makes it easy to remember the uploaded file even
387
+ in that case. Suppose your `user` model has an uploader mounted on `avatar`
388
+ file, just add a hidden field called `avatar_cache` (don't forget to add it to
389
+ the attr_accessible list as necessary). In Rails, this would look like this:
390
+
391
+ ```erb
392
+ <%= form_for @user, html: { multipart: true } do |f| %>
393
+ <p>
394
+ <label>My Avatar</label>
395
+ <%= f.file_field :avatar %>
396
+ <%= f.hidden_field :avatar_cache %>
397
+ </p>
398
+ <% end %>
399
+ ````
400
+
401
+ It might be a good idea to show the user that a file has been uploaded, in the
402
+ case of images, a small thumbnail would be a good indicator:
403
+
404
+ ```erb
405
+ <%= form_for @user, html: { multipart: true } do |f| %>
406
+ <p>
407
+ <label>My Avatar</label>
408
+ <%= image_tag(@user.avatar_url) if @user.avatar? %>
409
+ <%= f.file_field :avatar %>
410
+ <%= f.hidden_field :avatar_cache %>
411
+ </p>
412
+ <% end %>
413
+ ```
414
+
415
+ ## Removing uploaded files
416
+
417
+ If you want to remove a previously uploaded file on a mounted uploader, you can
418
+ easily add a checkbox to the form which will remove the file when checked.
419
+
420
+ ```erb
421
+ <%= form_for @user, html: { multipart: true } do |f| %>
422
+ <p>
423
+ <label>My Avatar</label>
424
+ <%= image_tag(@user.avatar_url) if @user.avatar? %>
425
+ <%= f.file_field :avatar %>
426
+ </p>
427
+
428
+ <p>
429
+ <label>
430
+ <%= f.check_box :remove_avatar %>
431
+ Remove avatar
432
+ </label>
433
+ </p>
434
+ <% end %>
435
+ ```
436
+
437
+ If you want to remove the file manually, you can call <code>remove_avatar!</code>, then save the object.
438
+
439
+ ```erb
440
+ @user.remove_avatar!
441
+ @user.save
442
+ #=> true
443
+ ```
444
+
445
+ ## Uploading files from a remote location
446
+
447
+ Your users may find it convenient to upload a file from a location on the Internet
448
+ via a URL. CarrierWave makes this simple, just add the appropriate attribute to your
449
+ form and you're good to go:
450
+
451
+ ```erb
452
+ <%= form_for @user, html: { multipart: true } do |f| %>
453
+ <p>
454
+ <label>My Avatar URL:</label>
455
+ <%= image_tag(@user.avatar_url) if @user.avatar? %>
456
+ <%= f.text_field :remote_avatar_url %>
457
+ </p>
458
+ <% end %>
459
+ ```
460
+
461
+ If you're using ActiveRecord, CarrierWave will indicate invalid URLs and download
462
+ failures automatically with attribute validation errors. If you aren't, or you
463
+ disable CarrierWave's `validate_download` option, you'll need to handle those
464
+ errors yourself.
465
+
466
+ ## Providing a default URL
467
+
468
+ In many cases, especially when working with images, it might be a good idea to
469
+ provide a default url, a fallback in case no file has been uploaded. You can do
470
+ this easily by overriding the `default_url` method in your uploader:
471
+
472
+ ```ruby
473
+ class MyUploader < CarrierWave::Uploader::Base
474
+ def default_url(*args)
475
+ "/images/fallback/" + [version_name, "default.png"].compact.join('_')
476
+ end
477
+ end
478
+ ```
479
+
480
+ Or if you are using the Rails asset pipeline:
481
+
482
+ ```ruby
483
+ class MyUploader < CarrierWave::Uploader::Base
484
+ def default_url(*args)
485
+ ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
486
+ end
487
+ end
488
+ ```
489
+
490
+ ## Recreating versions
491
+
492
+ You might come to a situation where you want to retroactively change a version
493
+ or add a new one. You can use the `recreate_versions!` method to recreate the
494
+ versions from the base file. This uses a naive approach which will re-upload and
495
+ process the specified version or all versions, if none is passed as an argument.
496
+
497
+ When you are generating random unique filenames you have to call `save!` on
498
+ the model after using `recreate_versions!`. This is necessary because
499
+ `recreate_versions!` doesn't save the new filename to the database. Calling
500
+ `save!` yourself will prevent that the database and file system are running
501
+ out of sync.
502
+
503
+ ```ruby
504
+ instance = MyUploader.new
505
+ instance.recreate_versions!(:thumb, :large)
506
+ ```
507
+
508
+ Or on a mounted uploader:
509
+
510
+ ```ruby
511
+ User.find_each do |user|
512
+ user.avatar.recreate_versions!
513
+ end
514
+ ```
515
+
516
+ Note: `recreate_versions!` will throw an exception on records without an image. To avoid this, scope the records to those with images or check if an image exists within the block. If you're using ActiveRecord, recreating versions for a user avatar might look like this:
517
+
518
+ ```ruby
519
+ User.find_each do |user|
520
+ user.avatar.recreate_versions! if user.avatar?
521
+ end
522
+ ```
523
+
524
+ ## Configuring CarrierWave
525
+
526
+ CarrierWave has a broad range of configuration options, which you can configure,
527
+ both globally and on a per-uploader basis:
528
+
529
+ ```ruby
530
+ CarrierWave.configure do |config|
531
+ config.permissions = 0666
532
+ config.directory_permissions = 0777
533
+ config.storage = :file
534
+ end
535
+ ```
536
+
537
+ Or alternatively:
538
+
539
+ ```ruby
540
+ class AvatarUploader < CarrierWave::Uploader::Base
541
+ permissions 0777
542
+ end
543
+ ```
544
+
545
+ If you're using Rails, create an initializer for this:
546
+
547
+ config/initializers/carrierwave.rb
548
+
549
+ If you want CarrierWave to fail noisily in development, you can change these configs in your environment file:
550
+
551
+ ```ruby
552
+ CarrierWave.configure do |config|
553
+ config.ignore_integrity_errors = false
554
+ config.ignore_processing_errors = false
555
+ config.ignore_download_errors = false
556
+ end
557
+ ```
558
+
559
+
560
+ ## Testing with CarrierWave
561
+
562
+ It's a good idea to test your uploaders in isolation. In order to speed up your
563
+ tests, it's recommended to switch off processing in your tests, and to use the
564
+ file storage. In Rails you could do that by adding an initializer with:
565
+
566
+ ```ruby
567
+ if Rails.env.test? or Rails.env.cucumber?
568
+ CarrierWave.configure do |config|
569
+ config.storage = :file
570
+ config.enable_processing = false
571
+ end
572
+ end
573
+ ```
574
+
575
+ Remember, if you have already set `storage :something` in your uploader, the `storage`
576
+ setting from this initializer will be ignored.
577
+
578
+ If you need to test your processing, you should test it in isolation, and enable
579
+ processing only for those tests that need it.
580
+
581
+ CarrierWave comes with some RSpec matchers which you may find useful:
582
+
583
+ ```ruby
584
+ require 'carrierwave/test/matchers'
585
+
586
+ describe MyUploader do
587
+ include CarrierWave::Test::Matchers
588
+
589
+ let(:user) { double('user') }
590
+ let(:uploader) { MyUploader.new(user, :avatar) }
591
+
592
+ before do
593
+ MyUploader.enable_processing = true
594
+ File.open(path_to_file) { |f| uploader.store!(f) }
595
+ end
596
+
597
+ after do
598
+ MyUploader.enable_processing = false
599
+ uploader.remove!
600
+ end
601
+
602
+ context 'the thumb version' do
603
+ it "scales down a landscape image to be exactly 64 by 64 pixels" do
604
+ expect(uploader.thumb).to have_dimensions(64, 64)
605
+ end
606
+ end
607
+
608
+ context 'the small version' do
609
+ it "scales down a landscape image to fit within 200 by 200 pixels" do
610
+ expect(uploader.small).to be_no_larger_than(200, 200)
611
+ end
612
+ end
613
+
614
+ it "makes the image readable only to the owner and not executable" do
615
+ expect(uploader).to have_permissions(0600)
616
+ end
617
+
618
+ it "has the correct format" do
619
+ expect(uploader).to be_format('png')
620
+ end
621
+ end
622
+ ```
623
+
624
+ Setting the enable_processing flag on an uploader will prevent any of the versions from processing as well.
625
+ Processing can be enabled for a single version by setting the processing flag on the version like so:
626
+
627
+ ```ruby
628
+ @uploader.thumb.enable_processing = true
629
+ ```
630
+
631
+ ## Fog
632
+
633
+ If you want to use fog you must add in your CarrierWave initializer the
634
+ following lines
635
+
636
+ ```ruby
637
+ config.fog_provider = 'fog' # 'fog/aws' etc. Defaults to 'fog'
638
+ config.fog_credentials = { ... } # Provider specific credentials
639
+ ```
640
+
641
+ ## Using Amazon S3
642
+
643
+ [Fog AWS](http://github.com/fog/fog-aws) is used to support Amazon S3. Ensure you have it in your Gemfile:
644
+
645
+ ```ruby
646
+ gem "fog-aws"
647
+ ```
648
+
649
+ You'll need to provide your fog_credentials and a fog_directory (also known as a bucket) in an initializer.
650
+ For the sake of performance it is assumed that the directory already exists, so please create it if it needs to be.
651
+ You can also pass in additional options, as documented fully in lib/carrierwave/storage/fog.rb. Here's a full example:
652
+
653
+ ```ruby
654
+ CarrierWave.configure do |config|
655
+ config.fog_provider = 'fog/aws' # required
656
+ config.fog_credentials = {
657
+ provider: 'AWS', # required
658
+ aws_access_key_id: 'xxx', # required
659
+ aws_secret_access_key: 'yyy', # required
660
+ region: 'eu-west-1', # optional, defaults to 'us-east-1'
661
+ host: 's3.example.com', # optional, defaults to nil
662
+ endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
663
+ }
664
+ config.fog_directory = 'name_of_directory' # required
665
+ config.fog_public = false # optional, defaults to true
666
+ config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" } # optional, defaults to {}
667
+ end
668
+ ```
669
+
670
+ In your uploader, set the storage to :fog
671
+
672
+ ```ruby
673
+ class AvatarUploader < CarrierWave::Uploader::Base
674
+ storage :fog
675
+ end
676
+ ```
677
+
678
+ That's it! You can still use the `CarrierWave::Uploader#url` method to return the url to the file on Amazon S3.
679
+
680
+ ## Using Rackspace Cloud Files
681
+
682
+ [Fog](http://github.com/fog/fog) is used to support Rackspace Cloud Files. Ensure you have it in your Gemfile:
683
+
684
+ ```ruby
685
+ gem "fog"
686
+ ```
687
+
688
+ You'll need to configure a directory (also known as a container), username and API key in the initializer.
689
+ For the sake of performance it is assumed that the directory already exists, so please create it if need be.
690
+
691
+ Using a US-based account:
692
+
693
+ ```ruby
694
+ CarrierWave.configure do |config|
695
+ config.fog_provider = "fog/rackspace/storage" # optional, defaults to "fog"
696
+ config.fog_credentials = {
697
+ provider: 'Rackspace',
698
+ rackspace_username: 'xxxxxx',
699
+ rackspace_api_key: 'yyyyyy',
700
+ rackspace_region: :ord # optional, defaults to :dfw
701
+ }
702
+ config.fog_directory = 'name_of_directory'
703
+ end
704
+ ```
705
+
706
+ Using a UK-based account:
707
+
708
+ ```ruby
709
+ CarrierWave.configure do |config|
710
+ config.fog_provider = "fog/rackspace/storage" # optional, defaults to "fog"
711
+ config.fog_credentials = {
712
+ provider: 'Rackspace',
713
+ rackspace_username: 'xxxxxx',
714
+ rackspace_api_key: 'yyyyyy',
715
+ rackspace_auth_url: Fog::Rackspace::UK_AUTH_ENDPOINT,
716
+ rackspace_region: :lon
717
+ }
718
+ config.fog_directory = 'name_of_directory'
719
+ end
720
+ ```
721
+
722
+ You can optionally include your CDN host name in the configuration.
723
+ This is *highly* recommended, as without it every request requires a lookup
724
+ of this information.
725
+
726
+ ```ruby
727
+ config.asset_host = "http://c000000.cdn.rackspacecloud.com"
728
+ ```
729
+
730
+ In your uploader, set the storage to :fog
731
+
732
+ ```ruby
733
+ class AvatarUploader < CarrierWave::Uploader::Base
734
+ storage :fog
735
+ end
736
+ ```
737
+
738
+ That's it! You can still use the `CarrierWave::Uploader#url` method to return
739
+ the url to the file on Rackspace Cloud Files.
740
+
741
+ ## Using Google Storage for Developers
742
+
743
+ [Fog](http://github.com/fog/fog-google) is used to support Google Storage for Developers. Ensure you have it in your Gemfile:
744
+
745
+ ```ruby
746
+ gem "fog-google"
747
+ gem "google-api-client", "< 0.9", ">= 0.6.2"
748
+ gem "mime-types"
749
+ ```
750
+
751
+ You'll need to configure a directory (also known as a bucket), access key id and secret access key in the initializer.
752
+ For the sake of performance it is assumed that the directory already exists, so please create it if need be.
753
+
754
+ Please read the [fog-google README](https://github.com/fog/fog-google/blob/master/README.md) on how to get credentials.
755
+
756
+
757
+ ```ruby
758
+ CarrierWave.configure do |config|
759
+ config.fog_provider = 'fog/google' # required
760
+ config.fog_credentials = {
761
+ provider: 'Google',
762
+ google_storage_access_key_id: 'xxxxxx',
763
+ google_storage_secret_access_key: 'yyyyyy'
764
+ }
765
+ config.fog_directory = 'name_of_directory'
766
+ end
767
+ ```
768
+
769
+ In your uploader, set the storage to :fog
770
+
771
+ ```ruby
772
+ class AvatarUploader < CarrierWave::Uploader::Base
773
+ storage :fog
774
+ end
775
+ ```
776
+
777
+ That's it! You can still use the `CarrierWave::Uploader#url` method to return
778
+ the url to the file on Google.
779
+
780
+ ## Optimized Loading of Fog
781
+
782
+ Since Carrierwave doesn't know which parts of Fog you intend to use, it will just load the entire library (unless you use e.g. [`fog-aws`, `fog-google`] instead of fog proper). If you prefer to load fewer classes into your application, you need to load those parts of Fog yourself *before* loading CarrierWave in your Gemfile. Ex:
783
+
784
+ ```ruby
785
+ gem "fog", "~> 1.27", require: "fog/rackspace/storage"
786
+ gem "carrierwave"
787
+ ```
788
+
789
+ A couple of notes about versions:
790
+ * This functionality was introduced in Fog v1.20.
791
+ * This functionality is slated for CarrierWave v1.0.0.
792
+
793
+ If you're not relying on Gemfile entries alone and are requiring "carrierwave" anywhere, ensure you require "fog/rackspace/storage" before it. Ex:
794
+
795
+ ```ruby
796
+ require "fog/rackspace/storage"
797
+ require "carrierwave"
798
+ ```
799
+
800
+ Beware that this specific require is only needed when working with a fog provider that was not extracted to its own gem yet.
801
+ A list of the extracted providers can be found in the page of the `fog` organizations [here](https://github.com/fog).
802
+
803
+ When in doubt, inspect `Fog.constants` to see what has been loaded.
804
+
805
+ ## Dynamic Asset Host
806
+
807
+ The `asset_host` config property can be assigned a proc (or anything that responds to `call`) for generating the host dynamically. The proc-compliant object gets an instance of the current `CarrierWave::Storage::Fog::File` or `CarrierWave::SanitizedFile` as its only argument.
808
+
809
+ ```ruby
810
+ CarrierWave.configure do |config|
811
+ config.asset_host = proc do |file|
812
+ identifier = # some logic
813
+ "http://#{identifier}.cdn.rackspacecloud.com"
814
+ end
815
+ end
816
+ ```
817
+
818
+ ## Using RMagick
819
+
820
+ If you're uploading images, you'll probably want to manipulate them in some way,
821
+ you might want to create thumbnail images for example. CarrierWave comes with a
822
+ small library to make manipulating images with RMagick easier, you'll need to
823
+ include it in your Uploader:
824
+
825
+ ```ruby
826
+ class AvatarUploader < CarrierWave::Uploader::Base
827
+ include CarrierWave::RMagick
828
+ end
829
+ ```
830
+
831
+ The RMagick module gives you a few methods, like
832
+ `CarrierWave::RMagick#resize_to_fill` which manipulate the image file in some
833
+ way. You can set a `process` callback, which will call that method any time a
834
+ file is uploaded.
835
+ There is a demonstration of convert here.
836
+ Convert will only work if the file has the same file extension, thus the use of the filename method.
837
+
838
+ ```ruby
839
+ class AvatarUploader < CarrierWave::Uploader::Base
840
+ include CarrierWave::RMagick
841
+
842
+ process resize_to_fill: [200, 200]
843
+ process convert: 'png'
844
+
845
+ def filename
846
+ super.chomp(File.extname(super)) + '.png' if original_filename.present?
847
+ end
848
+ end
849
+ ```
850
+
851
+ Check out the manipulate! method, which makes it easy for you to write your own
852
+ manipulation methods.
853
+
854
+ ## Using MiniMagick
855
+
856
+ MiniMagick is similar to RMagick but performs all the operations using the 'mogrify'
857
+ command which is part of the standard ImageMagick kit. This allows you to have the power
858
+ of ImageMagick without having to worry about installing all the RMagick libraries.
859
+
860
+ See the MiniMagick site for more details:
861
+
862
+ https://github.com/minimagick/minimagick
863
+
864
+ And the ImageMagick command line options for more for whats on offer:
865
+
866
+ http://www.imagemagick.org/script/command-line-options.php
867
+
868
+ Currently, the MiniMagick carrierwave processor provides exactly the same methods as
869
+ for the RMagick processor.
870
+
871
+ ```ruby
872
+ class AvatarUploader < CarrierWave::Uploader::Base
873
+ include CarrierWave::MiniMagick
874
+
875
+ process resize_to_fill: [200, 200]
876
+ end
877
+ ```
878
+
879
+ ## Migrating from Paperclip
880
+
881
+ If you are using Paperclip, you can use the provided compatibility module:
882
+
883
+ ```ruby
884
+ class AvatarUploader < CarrierWave::Uploader::Base
885
+ include CarrierWave::Compatibility::Paperclip
886
+ end
887
+ ```
888
+
889
+ See the documentation for `CarrierWave::Compatibility::Paperclip` for more
890
+ details.
891
+
892
+ Be sure to use mount_on to specify the correct column:
893
+
894
+ ```ruby
895
+ mount_uploader :avatar, AvatarUploader, mount_on: :avatar_file_name
896
+ ```
897
+
898
+ ## I18n
899
+
900
+ The Active Record validations use the Rails i18n framework. Add these keys to
901
+ your translations file:
902
+
903
+ ```yaml
904
+ errors:
905
+ messages:
906
+ carrierwave_processing_error: "Cannot resize image."
907
+ carrierwave_integrity_error: "Not an image."
908
+ carrierwave_download_error: "Couldn't download image."
909
+ extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
910
+ extension_blacklist_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
911
+ ```
912
+
913
+ ## Large files
914
+
915
+ By default, CarrierWave copies an uploaded file twice, first copying the file into the cache, then
916
+ copying the file into the store. For large files, this can be prohibitively time consuming.
917
+
918
+ You may change this behavior by overriding either or both of the `move_to_cache` and
919
+ `move_to_store` methods:
920
+
921
+ ```ruby
922
+ class MyUploader < CarrierWave::Uploader::Base
923
+ def move_to_cache
924
+ true
925
+ end
926
+
927
+ def move_to_store
928
+ true
929
+ end
930
+ end
931
+ ```
932
+
933
+ When the `move_to_cache` and/or `move_to_store` methods return true, files will be moved (instead of copied) to the cache and store respectively.
934
+
935
+ This has only been tested with the local filesystem store.
936
+
937
+ ## Skipping ActiveRecord callbacks
938
+
939
+ By default, mounting an uploader into an ActiveRecord model will add a few
940
+ callbacks. For example, this code:
941
+
942
+ ```ruby
943
+ class User
944
+ mount_uploader :avatar, AvatarUploader
945
+ end
946
+ ```
947
+
948
+ Will add these callbacks:
949
+
950
+ ```ruby
951
+ after_save :store_avatar!
952
+ before_save :write_avatar_identifier
953
+ after_commit :remove_avatar!, on: :destroy
954
+ after_commit :mark_remove_avatar_false, on: :update
955
+ after_save :store_previous_changes_for_avatar
956
+ after_commit :remove_previously_stored_avatar, on: :update
957
+ ```
958
+
959
+ If you want to skip any of these callbacks (eg. you want to keep the existing
960
+ avatar, even after uploading a new one), you can use ActiveRecord’s
961
+ `skip_callback` method.
962
+
963
+ ```ruby
964
+ class User
965
+ mount_uploader :avatar, AvatarUploader
966
+ skip_callback :commit, :after, :remove_previously_stored_avatar
967
+ end
968
+ ```
969
+
970
+ ## Contributing to CarrierWave
971
+
972
+ See [CONTRIBUTING.md](https://github.com/carrierwaveuploader/carrierwave/blob/master/CONTRIBUTING.md)
973
+
974
+ ## License
975
+
976
+ Copyright (c) 2008-2015 Jonas Nicklas
977
+
978
+ Permission is hereby granted, free of charge, to any person obtaining
979
+ a copy of this software and associated documentation files (the
980
+ "Software"), to deal in the Software without restriction, including
981
+ without limitation the rights to use, copy, modify, merge, publish,
982
+ distribute, sublicense, and/or sell copies of the Software, and to
983
+ permit persons to whom the Software is furnished to do so, subject to
984
+ the following conditions:
985
+
986
+ The above copyright notice and this permission notice shall be
987
+ included in all copies or substantial portions of the Software.
988
+
989
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
990
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
991
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
992
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
993
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
994
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
995
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.