refinerycms-dragonfly 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d11bd9be648efd9d063d5a489296ad0568ef12303a859b149530777924ab637
4
+ data.tar.gz: 4040f71450f7c2df28c48e63c25002fcd24e854b4223ca0e3165d8fc9e5ef625
5
+ SHA512:
6
+ metadata.gz: 254b0753d946efe7acea73a163ec5fda529258c06bc84b4b32d6828ef0b38dc414dc400fdba2a28579b9793bb8c5dfe679bfcefaf097db484cb93ec477a65f9a
7
+ data.tar.gz: a2edb4ea5c3db95db85c706519671e8aa3e8cf58c5a15b26f73dca67c196b293849a3cd38d7789c19ab8832ac03b235eeed6f6a4e0e5e3696c9668e3a5bb956e
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ namespace :refinery do
2
+ namespace :testing do
3
+ task :setup_extension do
4
+ require 'refinerycms-dragonfly'
5
+ Refinery::DragonflyGenerator.start %w[--quiet]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module Refinery
2
+ class DragonflyGenerator < Rails::Generators::Base
3
+
4
+ # Dragonfly has no migrations. Make skip_migrations the default
5
+ class_option :skip_migrations, :type => :boolean, :default => true, :aliases => nil, :group => :runtime,
6
+ :desc => 'Skip over installing or running migrations.'
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def rake_db
11
+ rake 'refinery_dragonfly:install:migrations' unless self.options[:skip_migrations]
12
+ end
13
+
14
+ def generate_dragonfly_initializer
15
+ template 'config/initializers/refinery/dragonfly.rb.erb',
16
+ File.join(destination_root, 'config', 'initializers', 'refinery', 'dragonfly.rb')
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+ Refinery::Dragonfly.configure do |config|
3
+
4
+ # Should set this if concerned about DOS attacks. See
5
+ # http://markevans.github.com/dragonfly/file.Configuration.html#Configuration
6
+
7
+ # config.secret = <%= Refinery::Dragonfly.secret.inspect %>
8
+ # config.verify_urls = <%= Refinery::Dragonfly.verify_urls.inspect %>
9
+
10
+ # Refinery passes all options to Dragonfly. See refinerycms/dragonfly/lib/refinery/dragonfly/configuration.rb and
11
+ # http://markevans.github.com/dragonfly/file.Configuration.html#Configuration
12
+
13
+ # config.url_format = <%= Refinery::Dragonfly.url_format.inspect %>
14
+ # config.url_host = <%= Refinery::Dragonfly.url_host.inspect %>
15
+ # config.url_path_prefix = <%= Refinery::Dragonfly.url_path_prefix.inspect %>
16
+
17
+ # config.allow_legacy_urls = <%= Refinery::Dragonfly.allow_legacy_urls.inspect %>
18
+ # config.analysers = <%= Refinery::Dragonfly.analysers.inspect %>
19
+ # config.before_serve = <%= Refinery::Dragonfly.before_serve.inspect %>
20
+ # config.datastore_root_path = <%= Refinery::Dragonfly.datastore_root_path.inspect %>
21
+ # config.define_url = <%= Refinery::Dragonfly.define_url.inspect %>
22
+ # config.dragonfly_url = <%= Refinery::Dragonfly.dragonfly_url.inspect %>
23
+ # config.fetch_file_whitelist = <%= Refinery::Dragonfly.fetch_file_whitelist.inspect %>
24
+ # config.fetch_url_whitelist = <%= Refinery::Dragonfly.fetch_url_whitelist.inspect %>
25
+ # config.generators = <%= Refinery::Dragonfly.generators.inspect %>
26
+ # config.mime_types = <%= Refinery::Dragonfly.mime_types.inspect %>
27
+ # config.name = <%= Refinery::Dragonfly.name.inspect %>
28
+ # config.path_prefix = <%= Refinery::Dragonfly.path_prefix.inspect %>
29
+ # config.plugin = <%= Refinery::Dragonfly.plugin.inspect %>
30
+ # config.processors = <%= Refinery::Dragonfly.processors.inspect %>
31
+ # config.response_header = <%= Refinery::Dragonfly.response_header.inspect %>
32
+
33
+
34
+ # Set the S3 options using means other than securely by environment variables.
35
+ # If you have to.
36
+ # config.s3_bucket_name = ENV['S3_BUCKET']
37
+ # config.s3_region = ENV['S3_REGION']
38
+ # config.s3_access_key_id = ENV['S3_KEY']
39
+ # config.s3_secret_access_key = ENV['S3_SECRET']
40
+
41
+ # When true will use Amazon's Simple Storage Service instead of the default file system for storing resources and images
42
+ config.s3_datastore = config.s3_access_key_id.present? || config.s3_secret_access_key.present?
43
+
44
+ # config.s3_fog_storage_options = <%= Refinery::Dragonfly.s3_fog_storage_options.inspect %>
45
+ # config.s3_root_path = <%= Refinery::Dragonfly.s3_root_path.inspect %>
46
+ # config.s3_storage_path = <%= Refinery::Dragonfly.s3_storage_path.inspect %>
47
+ # config.s3_storage_headers = <%= Refinery::Dragonfly.s3_storage_headers.inspect %>
48
+ # config.s3_url_host = <%= Refinery::Dragonfly.s3_url_host.inspect %>
49
+ # config.s3_url_scheme = <%= Refinery::Dragonfly.s3_url_scheme.inspect %>
50
+ # config.s3_use_iam_profile = <%= Refinery::Dragonfly.s3_use_iam_profile.inspect %>
51
+
52
+ # Configure a custom Dragonfly datastore instead of the default (filesystem).
53
+ # Dragonfly offers gems for datastores on S3, Couch, Mongo
54
+ # See http://markevans.github.io/dragonfly/data-stores#building-a-custom-data-store
55
+ #
56
+ # config.custom_datastore_class = <%= Refinery::Dragonfly.custom_datastore_class.inspect %>
57
+ # config.custom_datastore_opts = <%= Refinery::Dragonfly.custom_datastore_opts.inspect %>
58
+
59
+ end
@@ -0,0 +1,23 @@
1
+ require 'active_support/configurable'
2
+ require 'dragonfly'
3
+
4
+ module Refinery
5
+ autoload :DragonflyGenerator, 'generators/refinery/dragonfly/dragonfly_generator'
6
+
7
+ module Dragonfly
8
+ require 'refinery/dragonfly/configuration'
9
+ require 'refinery/dragonfly/dragonfly'
10
+ require 'refinery/dragonfly/engine'
11
+
12
+ class << self
13
+ def root
14
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
15
+ end
16
+
17
+ def factory_paths
18
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,87 @@
1
+ module Refinery
2
+ module Dragonfly
3
+
4
+ include ActiveSupport::Configurable
5
+
6
+ # All dragonfly options allowed
7
+ config_accessor :allow_legacy_urls, :analysers,
8
+ :before_serve,
9
+ :cache_log_level, :cache_store_root,
10
+ :custom_datastore_class, :custom_datastore_opts,
11
+ :datastore_root_path, :define_url, :dragonfly_url,
12
+ :fetch_file_whitelist, :fetch_url_whitelist,
13
+ :generators,
14
+ :mime_types,
15
+ :name,
16
+ :path_prefix, :plugin, :processors,
17
+ :response_header,
18
+ :secret,
19
+ :url_format, :url_host, :url_path_prefix,
20
+ :verify_urls,
21
+
22
+ # s3 options
23
+
24
+ :s3_access_key_id,
25
+ :s3_datastore, :s3_bucket_name,
26
+
27
+ :s3_fog_storage_options,
28
+ :s3_region, :s3_root_path,
29
+ :s3_secret_access_key, :s3_storage_path, :s3_storage_headers,
30
+ :s3_url_host, :s3_url_scheme, :s3_use_iam_profile
31
+
32
+
33
+ self.allow_legacy_urls = false
34
+ self.analysers = []
35
+ self.before_serve = nil
36
+
37
+ self.cache_log_level = 'verbose'
38
+ self.cache_store_root = 'tmp/dragonfly'
39
+ self.custom_datastore_class = nil
40
+ self.custom_datastore_opts = {}
41
+
42
+ self.datastore_root_path = 'public/system/refinery/dragonfly'
43
+ self.define_url = nil
44
+ self.dragonfly_url = nil
45
+ self.fetch_file_whitelist = nil
46
+ self.fetch_url_whitelist = nil
47
+ self.generators = []
48
+ self.mime_types = []
49
+ self.name = 'dragonfly'
50
+ self.path_prefix = nil
51
+ self.plugin = ''
52
+ self.processors = []
53
+ self.response_header = nil
54
+ self.secret = Array.new(24) { rand(256) }.pack('C*').unpack('H*').first
55
+ self.url_path_prefix = ''
56
+ self.url_host = ''
57
+ self.verify_urls = true
58
+
59
+ # s3 Data Store Config
60
+
61
+ self.s3_datastore = false
62
+ self.s3_bucket_name = ENV['S3_BUCKET']
63
+ self.s3_access_key_id = ENV['S3_KEY']
64
+ self.s3_secret_access_key = ENV['S3_SECRET']
65
+ self.s3_region = ENV['S3_REGION'] # default 'us-east-1' see Dragonfly S3DataStore :s3_REGIONS for options
66
+ self.s3_url_scheme = nil # defaults to "http"
67
+ self.s3_url_host = nil # defaults to "<bucket-name>.s3.amazonaws.com" or "s3.amazonaws.com/<bucket-name>" if not a valid subdomain
68
+ self.s3_use_iam_profile = nil # boolean - if true no need for access_key_id or secret_access_key
69
+ self.s3_root_path = nil # store all content under a subdirectory - uids will be relative to this - defaults to nil
70
+ self.s3_fog_storage_options = nil # hash for passing any extra options to Fog
71
+
72
+ # Per-storage options
73
+ self.s3_storage_path = nil
74
+ self.s3_storage_headers = nil
75
+
76
+
77
+ def self.custom_datastore?
78
+ config.custom_datastore_class.present? && config.custom_datastore_opts.present?
79
+ end
80
+
81
+ def self.url_format(url_segment='dragonfly')
82
+ "/system/refinery/#{url_segment}/:job/:basename.:ext"
83
+ end
84
+ end
85
+
86
+ end
87
+
@@ -0,0 +1,95 @@
1
+ module Refinery
2
+ module Dragonfly
3
+
4
+ class << self
5
+
6
+ def configure!(extension)
7
+ ::ActiveRecord::Base.extend ::Dragonfly::Model
8
+ ::ActiveRecord::Base.extend ::Dragonfly::Model::Validations
9
+
10
+ ::Dragonfly.app(extension.dragonfly_name).configure do
11
+
12
+ datastore :file, {root_path: extension.dragonfly_datastore_root_path}
13
+ plugin extension.dragonfly_plugin if extension.dragonfly_plugin
14
+ secret extension.dragonfly_secret
15
+
16
+ if extension.dragonfly_custom_datastore?
17
+ datastore extension.dragonfly_custom_datastore_class.new(extension.dragonfly_custom_datastore_opts)
18
+ end
19
+
20
+ url_format extension.dragonfly_url_format
21
+ url_host extension.dragonfly_url_host
22
+ url_path_prefix extension.dragonfly_url_path_prefix
23
+
24
+ allow_legacy_urls extension.dragonfly_allow_legacy_urls
25
+ dragonfly_url extension.dragonfly_dragonfly_url
26
+ fetch_file_whitelist extension.dragonfly_fetch_file_whitelist
27
+ fetch_url_whitelist extension.dragonfly_fetch_url_whitelist
28
+
29
+ response_header extension.dragonfly_response_header
30
+
31
+ verify_urls extension.dragonfly_verify_urls
32
+
33
+ # These options require a name and block
34
+ define_url extension.dragonfly_define_url if extension.dragonfly_define_url.present?
35
+ before_serve extension.dragonfly_before_serve if extension.dragonfly_before_serve.present?
36
+
37
+
38
+ # There can be more than one instance of each of these options.
39
+ extension.dragonfly_mime_types.each do |mt|
40
+ mime_type mt[:ext], mt[:mimetype]
41
+ end
42
+
43
+ extension.dragonfly_analysers.each do |a|
44
+ analyser a[:name], a[:block]
45
+ end unless extension.dragonfly_analysers.blank?
46
+
47
+ extension.dragonfly_generators.each do |g|
48
+ generator g[:name], g[:block]
49
+ end unless extension.dragonfly_generators.blank?
50
+
51
+ extension.dragonfly_processors.each do |p|
52
+ processor p[:name], p[:block]
53
+ end unless extension.dragonfly_processors.blank?
54
+
55
+ if extension.s3_datastore
56
+ require 'dragonfly/s3_data_store'
57
+ datastore :s3,{
58
+ s3_access_key_id: extension.s3_access_key_id,
59
+ s3_datastore: extension.s3_datastore,
60
+ s3_bucket_name: extension.s3_bucket_name,
61
+ s3_fog_storage_options: extension.s3_fog_storage_options,
62
+ s3_region: extension.s3_region,
63
+ s3_root_path: extension.s3_root_path,
64
+ s3_secret_access_key: extension.s3_secret_access_key,
65
+ s3_storage_path: extension.s3_storage_path,
66
+ s3_storage_headers: extension.s3_storage_headers,
67
+ s3_url_host: extension.s3_url_host,
68
+ s3_url_scheme: extension.s3_url_scheme,
69
+ s3_use_iam_profile: extension.s3_use_iam_profile
70
+ }
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+ def attach!(app, extension)
77
+
78
+ # Injects Dragonfly::Middleware into the stack
79
+
80
+ if defined?(::Rack::Cache)
81
+ unless app.config.action_controller.perform_caching && app.config.action_dispatch.rack_cache
82
+ app.config.middleware.insert 0, ::Rack::Cache, {
83
+ verbose: extension.dragonfly_cache_log_level =='verbose',
84
+ metastore: URI.encode("file:#{extension.dragonfly_cache_store_root}/meta"), # URI encoded in case of spaces
85
+ entitystore: URI.encode("file:#{extension.dragonfly_cache_store_root}/body")
86
+ }
87
+ end
88
+ app.config.middleware.insert_after ::Rack::Cache, ::Dragonfly::Middleware, extension.dragonfly_name
89
+ else
90
+ app.config.middleware.use ::Dragonfly::Middleware, extension.dragonfly_name
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,26 @@
1
+ module Refinery
2
+ module Dragonfly
3
+ class Engine < ::Rails::Engine
4
+ include Refinery::Engine
5
+
6
+ isolate_namespace Refinery
7
+ engine_name :refinery_dragonfly
8
+
9
+ config.autoload_paths += %W( #{config.root}/lib )
10
+
11
+ before_inclusion do
12
+ Refinery::Plugin.register do |plugin|
13
+ plugin.pathname = root
14
+ plugin.name = "refinerycms_dragonfly"
15
+ plugin.hide_from_menu = true
16
+ plugin.menu_match = %r{refinery/dragonfly}
17
+ end
18
+ end
19
+
20
+ config.after_initialize do
21
+ Refinery.register_engine Refinery::Dragonfly
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,189 @@
1
+ module Refinery
2
+ module Dragonfly
3
+ module ExtensionConfiguration
4
+ include ActiveSupport::Configurable
5
+
6
+ config_accessor :dragonfly_allow_legacy_urls, :dragonfly_analysers,
7
+ :dragonfly_before_serve,
8
+ :dragonfly_cache_store_root, :dragonfly_cache_log_level,
9
+ :dragonfly_custom_datastore_class, :dragonfly_custom_datastore_opts,
10
+ :dragonfly_datastore_root_path, :dragonfly_define_url, :dragonfly_dragonfly_url,
11
+ :dragonfly_fetch_file_whitelist, :dragonfly_fetch_url_whitelist,
12
+ :dragonfly_generators,
13
+ :dragonfly_mime_types,
14
+ :dragonfly_name,
15
+ :dragonfly_path_prefix, :dragonfly_plugin, :dragonfly_processors,
16
+ :dragonfly_response_header,
17
+ :dragonfly_secret,
18
+ :dragonfly_url_format, :dragonfly_url_host, :dragonfly_url_path_prefix, :dragonfly_url_segment,
19
+ :dragonfly_verify_urls,
20
+
21
+ :s3_access_key_id,
22
+ :s3_datastore, :s3_bucket_name,
23
+ :s3_fog_storage_options,
24
+ :s3_region, :s3_root_path,
25
+ :s3_secret_access_key, :s3_storage_path, :s3_storage_headers,
26
+ :s3_url_host, :s3_url_scheme, :s3_use_iam_profiles
27
+
28
+
29
+ def short_name
30
+ config.dragonfly_name.to_s.remove('refinery_')
31
+ end
32
+
33
+ def dragonfly_allow_legacy_urls
34
+ config.dragonfly_allow_legacy_urls.presence || Refinery::Dragonfly.allow_legacy_urls
35
+ end
36
+
37
+ def dragonfly_analysers
38
+ config.dragonfly_analysers.presence || Refinery::Dragonfly.analysers
39
+ end
40
+
41
+ def dragonfly_before_serve
42
+ config.dragonfly_before_serve.presence || Refinery::Dragonfly.before_serve
43
+ end
44
+
45
+ def dragonfly_cache_store_root
46
+ config.dragonfly_cache_store.presence || Rails.root.join('tmp', 'dragonfly')
47
+ end
48
+
49
+ def dragonfly_cache_log_level
50
+ config.dragonfly_cache_log_level || Refinery::Dragonfly.cache_log_level
51
+ end
52
+
53
+ def dragonfly_custom_datastore?
54
+ config.dragonfly_custom_datastore_class.nil? ? Refinery::Dragonfly.custom_datastore? : config.custom_datastore_class.present?
55
+ end
56
+
57
+ def dragonfly_custom_datastore_class
58
+ config.dragonfly_custom_datastore_class.nil? ? Refinery::Dragonfly.custom_datastore_class : config.dragonfly_custom_datastore_class.constantize
59
+ end
60
+
61
+ def dragonfly_custom_datastore_opts
62
+ config.dragonfly_custom_datastore_opts.presence || Refinery::Dragonfly.custom_datastore_opts
63
+ end
64
+
65
+ def dragonfly_datastore_root_path
66
+ config.dragonfly_datastore_root_path.presence || Rails.root.join('public', 'system', 'refinery', short_name).to_s if Rails.root
67
+ end
68
+
69
+ def dragonfly_define_url
70
+ config.dragonfly_define_url || Refinery::Dragonfly.define_url
71
+ end
72
+
73
+ def dragonfly_dragonfly_url
74
+ config.dragonfly_dragonfly_url || Refinery::Dragonfly.dragonfly_url
75
+ end
76
+
77
+ def dragonfly_fetch_file_whitelist
78
+ config.dragonfly_fetch_file_whitelist || Refinery::Dragonfly.fetch_file_whitelist
79
+ end
80
+
81
+ def dragonfly_fetch_url_whitelist
82
+ config.dragonfly_fetch_url_whitelist || Refinery::Dragonfly.fetch_url_whitelist
83
+ end
84
+
85
+ def dragonfly_generators
86
+ config.dragonfly_generators || Refinery::Dragonfly.generators
87
+ end
88
+
89
+
90
+ # define one or more new mimetypes
91
+ # dragonfly_mimetypes = [
92
+ # {ext: 'egg', mimetype: 'fried/egg'},
93
+ # {ext: 'avo', mimetype: 'smashed/avo'}
94
+ # ]
95
+ #
96
+
97
+ def dragonfly_mime_types
98
+ config.dragonfly_mime_types || Refinery::Dragonfly.mime_types
99
+ end
100
+
101
+ def dragonfly_name
102
+ config.dragonfly_name || Refinery::Dragonfly.name
103
+ end
104
+
105
+ def dragonfly_path_prefix
106
+ config.dragonfly_path_prefix || Refinery::Dragonfly.path_prefix
107
+ end
108
+
109
+ def dragonfly_response_header
110
+ config.dragonfly_response_header || Refinery::Dragonfly.response_header
111
+ end
112
+
113
+ def dragonfly_secret
114
+ config.dragonfly_secret || Refinery::Dragonfly.secret
115
+ end
116
+
117
+ def dragonfly_url
118
+ config.dragonfly_url || Refinery::Dragonfly.url
119
+ end
120
+
121
+ def dragonfly_url_format
122
+ config.dragonfly_url_format || Refinery::Dragonfly.url_format(short_name)
123
+ end
124
+
125
+ def dragonfly_url_host
126
+ config.dragonfly_url_host || Refinery::Dragonfly.url_host
127
+ end
128
+
129
+ def dragonfly_url_path_prefix
130
+ config.dragonfly_url_path_prefix || Refinery::Dragonfly.url_path_prefix
131
+ end
132
+
133
+ def dragonfly_url_segment
134
+ config.dragonfly_url_segment || short_name
135
+ end
136
+
137
+ def dragonfly_verify_urls
138
+ config.dragonfly_verify_urls.nil? ? Refinery::Dragonfly.verify_urls : config.dragonfly_verify_urls
139
+ end
140
+
141
+ # -------------------
142
+ # Options for s3_datastore
143
+
144
+ def s3_datastore?
145
+ config.s3_datastore.presence || Refinery::Dragonfly.s3_datastore
146
+ end
147
+
148
+ def s3_access_key_id
149
+ config.s3_access_key_id.presence || Refinery::Dragonfly.s3_access_key_id
150
+ end
151
+
152
+ def s3_bucket_name
153
+ config.s3_bucket_name.presence || Refinery::Dragonfly.s3_bucket_name
154
+ end
155
+
156
+ def s3_fog_storage_options
157
+ config.s3_fog_storage_options.presence || Refinery::Dragonfly.s3_fog_storage_options
158
+ end
159
+
160
+ def s3_host
161
+ config.s3_host.presence || Refinery::Dragonfly.s3_host
162
+ end
163
+
164
+ def s3_region
165
+ config.s3_region.presence || Refinery::Dragonfly.s3_region
166
+ end
167
+
168
+ def s3_root_path
169
+ config.s3_root_path.presence || Refinery::Dragonfly.s3_root_path
170
+ end
171
+
172
+ def s3_scheme
173
+ config.s3_scheme.presence || Refinery::Dragonfly.s3_scheme
174
+ end
175
+
176
+ def s3_secret_access_key
177
+ config.s3_secret_access_key.presence || Refinery::Dragonfly.s3_secret_access_key
178
+ end
179
+
180
+ def s3_storage_headers
181
+ config.s3_storage_headers.presence || Refinery::Dragonfly.s3_storage_headers
182
+ end
183
+
184
+ def s3_use_iam_profile
185
+ config.s3_use_iam_profile.presence || Refinery::Dragonfly.s3_use_iam_profile
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/dragonfly'
@@ -0,0 +1,27 @@
1
+ # Encoding: UTF-8
2
+
3
+
4
+ Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.name = %q{refinerycms-dragonfly}
7
+ s.version = '1.0.0'
8
+ s.summary = %q{Dragonfly interface for Refinery CMS}
9
+ s.description = %q{Allows Refinery to use dragonfly for file storage and processing}
10
+ s.email = %q{anita@joli.com.au}
11
+ s.homepage = %q{http://refinerycms.com}
12
+ s.authors = ['Anita Graham', 'Philip Arndt']
13
+ s.license = %q{MIT}
14
+ s.require_paths = %w(lib)
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- spec/*`.split("\n")
18
+
19
+ s.add_dependency 'dragonfly', '~> 1.1'
20
+ s.add_dependency 'dragonfly-s3_data_store'
21
+ s.add_dependency 'refinerycms-core', ['~> 4.0', '>= 4.0.2']
22
+
23
+ s.cert_chain = [File.expand_path("../../certs/parndt.pem", __FILE__)]
24
+ if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__)
25
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'generator_spec/test_case'
3
+ require 'generators/refinery/dragonfly/dragonfly_generator'
4
+
5
+ module Refinery
6
+ describe DragonflyGenerator do
7
+ include GeneratorSpec::TestCase
8
+ destination File.expand_path("../../../../tmp", __FILE__)
9
+
10
+ before do
11
+ prepare_destination
12
+ run_generator %w[--skip-migrations]
13
+ end
14
+
15
+ specify do
16
+ expect(destination_root).to have_structure {
17
+ directory "config" do
18
+ directory "initializers" do
19
+ directory "refinery" do
20
+ file "dragonfly.rb" do
21
+ contains "Refinery::Dragonfly.configure"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ describe Dragonfly do
5
+ describe 'default configuration' do
6
+
7
+ it 'defines a default secret' do
8
+ expect(Refinery::Dragonfly.secret).to_not be nil
9
+ end
10
+
11
+ it "doesn't use S3" do
12
+ expect(Refinery::Dragonfly.s3_datastore).to be false
13
+ end
14
+
15
+ it "doesn't use a custom datastore" do
16
+ expect(Refinery::Dragonfly.custom_datastore_class).to eq(nil)
17
+ end
18
+ end
19
+
20
+ describe 'using custom configuration' do
21
+ describe 'datastore' do
22
+ before {
23
+ class DummyBackend;
24
+ end}
25
+ after {Refinery::Dragonfly.custom_datastore_class = nil}
26
+ let(:datastore) {DummyBackend.new}
27
+
28
+ it 'uses the custom setting' do
29
+ Refinery::Dragonfly.custom_datastore_class = DummyBackend
30
+ expect(Refinery::Dragonfly.custom_datastore_class).to eq(datastore.class)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1 @@
1
+ CustomDatastoreOne = Class.new
@@ -0,0 +1 @@
1
+ CustomDatastoreTwo = Class.new
@@ -0,0 +1,10 @@
1
+ shared_examples_for 'adds the dragonfly app to the middleware stack' do
2
+
3
+ let(:middleware_array){ Rails.application.config.middleware.to_a}
4
+
5
+ describe 'middleware stack:' do
6
+ it 'includes Dragonfly::Middleware' do
7
+ expect(middleware_array).to include(Dragonfly::Middleware)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,73 @@
1
+ require_relative '../custom_datastore_one'
2
+ require_relative '../custom_datastore_two'
3
+ shared_examples_for 'Creates a dragonfly App:' do
4
+
5
+ describe 'app creation' do
6
+ ::Refinery::Dragonfly.configure!(described_class)
7
+ it 'exists' do
8
+ expect(::Dragonfly.app(described_class.dragonfly_name).name).to eq(described_class.dragonfly_name.to_sym)
9
+ end
10
+ end
11
+
12
+ describe 'app configuration' do
13
+ # These are just some of the configuration parameters which can be passed to Dragonfly
14
+ it 'sets the datastore_root_path' do
15
+ expect(Dragonfly.app(described_class.dragonfly_name).datastore.root_path).to eq(described_class.dragonfly_datastore_root_path)
16
+ end
17
+
18
+ it 'sets the url host' do
19
+ expect(Dragonfly.app(described_class.dragonfly_name).server.url_host).to eq(described_class.dragonfly_url_host)
20
+ end
21
+
22
+ it 'sets the url format' do
23
+ expect(Dragonfly.app(described_class.dragonfly_name).server.url_format).to eq(described_class.dragonfly_url_format)
24
+ end
25
+ end
26
+
27
+ describe 'configuring Amazon S3' do
28
+ context "using custom settings" do
29
+ it "uses the custom values" do
30
+ Refinery::Dragonfly.s3_bucket_name = "kfc"
31
+ described_class.s3_bucket_name = "buckethead"
32
+
33
+ expect(described_class.s3_bucket_name).to eq("buckethead")
34
+ end
35
+ end
36
+
37
+ describe "without custom settings" do
38
+ it "uses the defaults" do
39
+ described_class.s3_bucket_name = nil
40
+ Refinery::Dragonfly.s3_bucket_name = "kfc"
41
+
42
+ expect(described_class.s3_bucket_name).to eq("kfc")
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "defining a custom datastore" do
48
+
49
+ before(:each) do
50
+ allow(Refinery::Dragonfly).to receive_messages(custom_datastore_class: CustomDatastoreOne)
51
+ end
52
+
53
+ after(:each) do
54
+ described_class.dragonfly_custom_datastore_class = nil
55
+ end
56
+
57
+ context "with the default configuration" do
58
+ it "uses the default values" do
59
+ expect(described_class.dragonfly_custom_datastore_class).to eq(CustomDatastoreOne)
60
+ end
61
+ end
62
+
63
+ context "with a custom configuration" do
64
+ it "uses custom values" do
65
+ described_class.dragonfly_custom_datastore_class = 'CustomDatastoreTwo'
66
+ expect(described_class.dragonfly_custom_datastore_class).to eq(CustomDatastoreTwo)
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+
73
+
data/tasks/rspec.rake ADDED
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run specs"
4
+ RSpec::Core::RakeTask.new
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-dragonfly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Anita Graham
8
+ - Philip Arndt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDhjCCAm6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMQ0wCwYDVQQDDARnZW1z
15
+ MREwDwYKCZImiZPyLGQBGRYBcDEVMBMGCgmSJomT8ixkARkWBWFybmR0MRIwEAYK
16
+ CZImiZPyLGQBGRYCaW8wHhcNMTcwNzI1MTMxMjIwWhcNMTgwNzI1MTMxMjIwWjBN
17
+ MQ0wCwYDVQQDDARnZW1zMREwDwYKCZImiZPyLGQBGRYBcDEVMBMGCgmSJomT8ixk
18
+ ARkWBWFybmR0MRIwEAYKCZImiZPyLGQBGRYCaW8wggEiMA0GCSqGSIb3DQEBAQUA
19
+ A4IBDwAwggEKAoIBAQDrjwB8be48TFEvGweP7BwWFnmsL2IMU9Ts2UKKWK9GYr7Z
20
+ 5uNZFmO1yVBCrmUQHHDlpku6SN6HDO8ChDL7LNugz/4eapRTifHZl8jhPRsOLBcF
21
+ 1hANy/V2v5NNkL5Zvb+vsUa7lyjbIOoD5yYzSDl4/T0nOe6xYzxJgBuxZK/nWSOe
22
+ Db8Uffc7B4yhA2kuayUiQUXPYAoPdfUSxoTKDohw17Sm6LKTpg8GkT0ttof1a/xu
23
+ vdsTvZHIcTsYv16e+8SrwLRZ/iBVVsyZFkMYPMxemw7WHxmWElWIgW9S7pUK5Q7J
24
+ oMS5uJVbtV2EmV+cOnhOWDz1A16P7QRFmGje5L+vAgMBAAGjcTBvMAkGA1UdEwQC
25
+ MAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ7G/yxuQIzgszkOkaZBgoKBJ1rozAa
26
+ BgNVHREEEzARgQ9nZW1zQHAuYXJuZHQuaW8wGgYDVR0SBBMwEYEPZ2Vtc0BwLmFy
27
+ bmR0LmlvMA0GCSqGSIb3DQEBBQUAA4IBAQB12WMsC+yuuIeM0Ib6HUYZ2IbhRnuW
28
+ 4uydNRvKDPdwzjChnOI0POGpcL8O1s1gh+19o/ITq6zRfTLhkwR2ir7XfwHJNppJ
29
+ yg48wbdL5gpZwggKWggKX5G9pqv9LjRsSAew6r0WB+5KW+ArCl/iNo9+AdeR3nUx
30
+ I+L/QiUxYU6XAXSrczL/i7kF5Xc3ZXQYuFsyGW9plA3i9faWUMvGKQc6pvUHIUZC
31
+ jOQmH9VbgbfUrXYM1YOKdlwW5sPR1f4PKLDlvEE+bppIUgKOgLOIv3i7KwrGvFOq
32
+ 5r7Wz/HY31SM47mkK21saPJG4NvUFEycf0wlpzP657Pl9aVo47aKKbxX
33
+ -----END CERTIFICATE-----
34
+ date: 2018-05-23 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: dragonfly
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.1'
50
+ - !ruby/object:Gem::Dependency
51
+ name: dragonfly-s3_data_store
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: refinerycms-core
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '4.0'
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 4.0.2
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '4.0'
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 4.0.2
84
+ description: Allows Refinery to use dragonfly for file storage and processing
85
+ email: anita@joli.com.au
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Rakefile
91
+ - lib/generators/refinery/dragonfly/dragonfly_generator.rb
92
+ - lib/generators/refinery/dragonfly/templates/config/initializers/refinery/dragonfly.rb.erb
93
+ - lib/refinery/dragonfly.rb
94
+ - lib/refinery/dragonfly/configuration.rb
95
+ - lib/refinery/dragonfly/dragonfly.rb
96
+ - lib/refinery/dragonfly/engine.rb
97
+ - lib/refinery/dragonfly/extension_configuration.rb
98
+ - lib/refinerycms-dragonfly.rb
99
+ - refinerycms-dragonfly.gemspec
100
+ - spec/lib/generators/refinery/dragonfly/dragonfly_generator_spec.rb
101
+ - spec/lib/refinery/dragonfly/dragonfly_spec.rb
102
+ - spec/support/custom_datastore_one.rb
103
+ - spec/support/custom_datastore_two.rb
104
+ - spec/support/shared_examples/adds_dragonfly_app_to_middlewares.rb
105
+ - spec/support/shared_examples/creates_a_dragonfly_app.rb
106
+ - tasks/rspec.rake
107
+ homepage: http://refinerycms.com
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Dragonfly interface for Refinery CMS
131
+ test_files:
132
+ - spec/lib/generators/refinery/dragonfly/dragonfly_generator_spec.rb
133
+ - spec/lib/refinery/dragonfly/dragonfly_spec.rb
134
+ - spec/support/custom_datastore_one.rb
135
+ - spec/support/custom_datastore_two.rb
136
+ - spec/support/shared_examples/adds_dragonfly_app_to_middlewares.rb
137
+ - spec/support/shared_examples/creates_a_dragonfly_app.rb
metadata.gz.sig ADDED
Binary file