Module: Refinery::Dragonfly
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/refinery/dragonfly.rb,
lib/refinery/dragonfly/engine.rb,
lib/refinery/dragonfly/dragonfly.rb,
lib/refinery/dragonfly/configuration.rb,
lib/refinery/dragonfly/extension_configuration.rb
Defined Under Namespace
Modules: ExtensionConfiguration Classes: Engine
Class Method Summary collapse
- .attach!(app, extension) ⇒ Object
- .configure!(extension) ⇒ Object
- .custom_datastore? ⇒ Boolean
- .factory_paths ⇒ Object
- .root ⇒ Object
- .url_format(url_segment = 'dragonfly') ⇒ Object
Class Method Details
.attach!(app, extension) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/refinery/dragonfly/dragonfly.rb', line 76 def attach!(app, extension) # Injects Dragonfly::Middleware into the stack if defined?(::Rack::Cache) unless app.config.action_controller.perform_caching && app.config.action_dispatch.rack_cache app.config.middleware.insert 0, ::Rack::Cache, { verbose: extension.dragonfly_cache_log_level =='verbose', metastore: "file:#{extension.dragonfly_cache_store_root}/meta", entitystore: "file:#{extension.dragonfly_cache_store_root}/body" } end app.config.middleware.insert_after ::Rack::Cache, ::Dragonfly::Middleware, extension.dragonfly_name else app.config.middleware.use ::Dragonfly::Middleware, extension.dragonfly_name end end |
.configure!(extension) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/refinery/dragonfly/dragonfly.rb', line 6 def configure!(extension) ::ActiveRecord::Base.extend ::Dragonfly::Model ::ActiveRecord::Base.extend ::Dragonfly::Model::Validations ::Dragonfly.app(extension.dragonfly_name).configure do datastore :file, {root_path: extension.dragonfly_datastore_root_path} plugin extension.dragonfly_plugin if extension.dragonfly_plugin secret extension.dragonfly_secret if extension.dragonfly_custom_datastore? datastore extension.dragonfly_custom_datastore_class.new(extension.dragonfly_custom_datastore_opts) end url_format extension.dragonfly_url_format url_host extension.dragonfly_url_host url_path_prefix extension.dragonfly_url_path_prefix allow_legacy_urls extension.dragonfly_allow_legacy_urls dragonfly_url extension.dragonfly_dragonfly_url fetch_file_whitelist extension.dragonfly_fetch_file_whitelist fetch_url_whitelist extension.dragonfly_fetch_url_whitelist response_header extension.dragonfly_response_header verify_urls extension.dragonfly_verify_urls # These options require a name and block define_url extension.dragonfly_define_url if extension.dragonfly_define_url.present? before_serve(&extension.dragonfly_before_serve) if extension.dragonfly_before_serve.present? # There can be more than one instance of each of these options. extension.dragonfly_mime_types.each do |mt| mime_type mt[:ext], mt[:mimetype] end extension.dragonfly_analysers.each do |a| analyser a[:name], a[:block] end unless extension.dragonfly_analysers.blank? extension.dragonfly_generators.each do |g| generator g[:name], g[:block] end unless extension.dragonfly_generators.blank? extension.dragonfly_processors.each do |p| processor p[:name], p[:block] end unless extension.dragonfly_processors.blank? if extension.s3_datastore? require 'dragonfly/s3_data_store' datastore :s3,{ access_key_id: extension.s3_access_key_id, datastore: extension.s3_datastore, bucket_name: extension.s3_bucket_name, fog_storage_options: extension., region: extension.s3_region, root_path: extension.s3_root_path, secret_access_key: extension.s3_secret_access_key, storage_path: extension.s3_storage_path, storage_headers: extension.s3_storage_headers, url_host: extension.s3_url_host, url_scheme: extension.s3_url_scheme, use_iam_profile: extension.s3_use_iam_profile } end end end |
.custom_datastore? ⇒ Boolean
77 78 79 |
# File 'lib/refinery/dragonfly/configuration.rb', line 77 def self.custom_datastore? config.custom_datastore_class.present? && config.custom_datastore_opts.present? end |
.factory_paths ⇒ Object
17 18 19 |
# File 'lib/refinery/dragonfly.rb', line 17 def factory_paths @factory_paths ||= [ root.join("spec/factories").to_s ] end |
.root ⇒ Object
13 14 15 |
# File 'lib/refinery/dragonfly.rb', line 13 def root @root ||= Pathname.new(File.('../../../', __FILE__)) end |
.url_format(url_segment = 'dragonfly') ⇒ Object
81 82 83 |
# File 'lib/refinery/dragonfly/configuration.rb', line 81 def self.url_format(url_segment='dragonfly') "/system/refinery/#{url_segment}/:job/:basename.:ext" end |