refinerycms-resources 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88faa05ca6216ceb4a7d5cb83f1cb5dcb10cde5a
4
- data.tar.gz: 2f769810e6a006f1bd0349760b86a9bc4d592b03
3
+ metadata.gz: '08cc58f2f832273fd4283a124243cc8482e55979'
4
+ data.tar.gz: f76b1752e7a670ae4b40fdf072fe585305435143
5
5
  SHA512:
6
- metadata.gz: b5ef915f67a536caf8e29a303bad81bf1a4465370717796c80b22c3750a46ebf180f15910fc3de1550016c5423b559bb91a57d1a532b3a3ebb393294400910dd
7
- data.tar.gz: b10b8295ffbdeaf490deadb508598014802ccd343887c1cfd30a6972070dc7d6ba9714e2fed239c1e177b29934d33b766e7ddd6a673a4da80a23befec7f375e7
6
+ metadata.gz: d18db2f4b34ce8c222e88fd42f388ffc225cee10a4fb9fe70f22f6af75e9b76fbabb809590fca2183017f395cc5c1a31d6ea9f7bb58773158a280722cb3d38e6
7
+ data.tar.gz: 1e167bd3f2ae804447b4f917d7889e9906d5ef4db09eddc8b95faf62632ebcae2aef49520366234962f3566d265e5a444424007023810f2346c623e8539f8ab8
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- �F�
2
- �>�J�EY�6"Z�w�'��a꜕O �G7�<BYg爷ᕁ��M�k#��Ҕ�ro���"˳ ��>2��rF@(�r� *��B�S�M�҅
1
+ d���������� ���2#�ќ��UPjŊz�^!�Vf󕧣��+�%30AgTT���[r�!6'�=o�j�f#O��i�熘U{����B��l�h�X���s_\��z:8�j1�$���`a4�A[JO��.�i=��� Уh�Q���^���.g �/\ڳ�o�� ��~��a��ߑ<F�� �������P���fy@R�e/�h����x�<�C��9HhF����WX�{���$�o�Ò�
@@ -9,25 +9,35 @@ Refinery::Resources.configure do |config|
9
9
  # Configure how many resources per page should be displayed in the list of resources in the admin area
10
10
  # config.pages_per_admin_index = <%= Refinery::Resources.pages_per_admin_index.inspect %>
11
11
 
12
- # Configure S3 (you can also use ENV for this)
13
- # The s3_backend setting by default defers to the core setting for this but can be set just for resources.
14
- # config.s3_backend = Refinery::Core.s3_backend
15
- # config.s3_bucket_name = ENV['S3_BUCKET']
16
- # config.s3_access_key_id = ENV['S3_KEY']
17
- # config.s3_secret_access_key = ENV['S3_SECRET']
18
- # config.s3_region = ENV['S3_REGION']
12
+ # Configure Dragonfly.
13
+ # Refer to config/initializers/refinery/dragonfly.rb for the full list of dragonfly configurations which can be used.
14
+ # This includes all dragonfly config for Dragonfly v 1.1.1
19
15
 
20
- # Configure Dragonfly
21
- # config.dragonfly_verify_urls = <%= Refinery::Resources.dragonfly_verify_urls %>
22
- # config.dragonfly_secret = <%= Refinery::Resources.dragonfly_secret.inspect %>
23
- # config.dragonfly_url_format = <%= Refinery::Resources.dragonfly_url_format.inspect %>
24
- # config.dragonfly_url_host = <%= Refinery::Resources.dragonfly_url_host.inspect %>
25
- # config.datastore_root_path = <%= Refinery::Resources.datastore_root_path.inspect %>
26
- # config.content_disposition = <%= Refinery::Resources.content_disposition.inspect %>
16
+ # config.dragonfly_verify_urls = <%= Refinery::Resources.dragonfly_verify_urls.inspect %>
17
+ # config.dragonfly_secret = <%= Refinery::Resources.dragonfly_secret.inspect %>
18
+ # config.dragonfly_url_host = <%= Refinery::Resources.dragonfly_url_host.inspect %>
19
+ # config.dragonfly_datastore_root_path = <%= Refinery::Resources.dragonfly_datastore_root_path.inspect %>
20
+ # config.dragonfly_url_format = <%= Refinery::Resources.dragonfly_url_format.inspect %>
27
21
 
28
- # Configure Dragonfly custom storage backend
29
- # The custom_backend setting by default defers to the core setting for this but can be set just for resources.
30
- # config.custom_backend_class = <%= Refinery::Resources.custom_backend_class.inspect %>
31
- # config.custom_backend_opts = <%= Refinery::Resources.custom_backend_opts.inspect %>
22
+ # Configure S3 (you can also use ENV for this)
23
+ # The s3_datastore setting by default defers to the Refinery::Dragonfly setting for this but can be set just for images.
24
+ # config.s3_datastore = Refinery::Dragonfly.s3_datastore
25
+ # config.s3_bucket_name = ENV['S3_BUCKET']
26
+ # config.s3_access_key_id = ENV['S3_KEY']
27
+ # config.s3_secret_access_key = ENV['S3_SECRET']
28
+ # config.s3_region = ENV['S3_REGION']
29
+ #
30
+ # further S3 configuration options
31
+ # config.s3_fog_storage_options = <%= Refinery::Resources.s3_fog_storage_options.inspect %>
32
+ # config.s3_root_path = <%= Refinery::Resources.s3_root_path.inspect %>
33
+ # config.s3_storage_path = <%= Refinery::Resources.s3_storage_path.inspect %>
34
+ # config.s3_storage_headers = <%= Refinery::Resources.s3_storage_headers.inspect %>
35
+ # config.s3_url_host = <%= Refinery::Resources.s3_url_host.inspect %>
36
+ # config.s3_url_scheme = <%= Refinery::Resources.s3_url_scheme.inspect %>
37
+ # config.s3_use_iam_profile = <%= Refinery::Resources.s3_use_iam_profile.inspect %>
32
38
 
39
+ # Configure Dragonfly custom datastore
40
+ # The custom_datastore setting by default defers to the Refinery::Resources setting for this but can be set just for images.
41
+ # config.custom_datastore_class = <%= Refinery::Resources.dragonfly_custom_datastore_class.inspect %>
42
+ # config.custom_datastore_opts = <%= Refinery::Resources.dragonfly_custom_datastore_opts.inspect %>
33
43
  end
@@ -1,15 +1,15 @@
1
1
  require 'refinerycms-core'
2
- require 'dragonfly'
2
+ require 'refinerycms-dragonfly'
3
3
 
4
4
  module Refinery
5
5
  autoload :ResourcesGenerator, 'generators/refinery/resources/resources_generator'
6
6
 
7
7
  module Resources
8
8
  require 'refinery/resources/engine'
9
+ require 'refinery/dragonfly/extension_configuration'
9
10
  require 'refinery/resources/configuration'
10
11
 
11
- autoload :Dragonfly, 'refinery/resources/dragonfly'
12
- autoload :Validators, 'refinery/resources/validators'
12
+ autoload :Validators, 'refinery/resources/validators'
13
13
 
14
14
  class << self
15
15
  def root
@@ -25,4 +25,4 @@ end
25
25
 
26
26
  ActiveSupport.on_load(:active_record) do
27
27
  require 'globalize'
28
- end
28
+ end
@@ -1,63 +1,18 @@
1
1
  module Refinery
2
2
  module Resources
3
- include ActiveSupport::Configurable
4
3
 
5
- config_accessor :dragonfly_secret, :dragonfly_url_format, :dragonfly_url_host, :dragonfly_verify_urls,
6
- :max_file_size, :pages_per_dialog, :pages_per_admin_index,
7
- :s3_backend, :s3_bucket_name, :s3_region,
8
- :s3_access_key_id, :s3_secret_access_key,
9
- :datastore_root_path, :content_disposition,
10
- :custom_backend_class, :custom_backend_opts
4
+ extend Refinery::Dragonfly::ExtensionConfiguration
5
+ include ActiveSupport::Configurable
11
6
 
12
- self.dragonfly_secret = Core.dragonfly_secret
13
- self.dragonfly_url_format = '/system/resources/:job/:basename.:ext'
14
- self.dragonfly_url_host = ''
15
- self.dragonfly_verify_urls = true
7
+ config_accessor :max_file_size, :pages_per_dialog, :pages_per_admin_index, :content_disposition
16
8
 
17
9
  self.content_disposition = :attachment
18
10
  self.max_file_size = 52_428_800
19
11
  self.pages_per_dialog = 12
20
12
  self.pages_per_admin_index = 20
21
13
 
22
- # We have to configure these settings after Rails is available.
23
- # But a non-nil custom option can still be provided
24
- class << self
25
- def datastore_root_path
26
- config.datastore_root_path || (Rails.root.join('public', 'system', 'refinery', 'resources').to_s if Rails.root)
27
- end
28
-
29
- def s3_backend
30
- config.s3_backend.nil? ? Core.s3_backend : config.s3_backend
31
- end
32
-
33
- def s3_bucket_name
34
- config.s3_bucket_name.presence || Core.s3_bucket_name
35
- end
36
-
37
- def s3_access_key_id
38
- config.s3_access_key_id.presence || Core.s3_access_key_id
39
- end
40
-
41
- def s3_secret_access_key
42
- config.s3_secret_access_key.presence || Core.s3_secret_access_key
43
- end
14
+ self.dragonfly_name = :refinery_resources
44
15
 
45
- def s3_region
46
- config.s3_region.presence || Core.s3_region
47
- end
48
-
49
- def custom_backend?
50
- config.custom_backend_class.nil? ? Core.dragonfly_custom_backend? : config.custom_backend_class.present?
51
- end
52
-
53
- def custom_backend_class
54
- config.custom_backend_class.nil? ? Core.dragonfly_custom_backend_class : config.custom_backend_class.constantize
55
- end
56
-
57
- def custom_backend_opts
58
- config.custom_backend_opts.presence || Core.dragonfly_custom_backend_opts
59
- end
60
-
61
- end
62
16
  end
63
17
  end
18
+
@@ -9,8 +9,8 @@ module Refinery
9
9
  config.autoload_paths += %W( #{config.root}/lib )
10
10
 
11
11
  initializer 'attach-refinery-resources-with-dragonfly', :before => :finisher_hook do |app|
12
- ::Refinery::Resources::Dragonfly.configure!
13
- ::Refinery::Resources::Dragonfly.attach!(app)
12
+ ::Refinery::Dragonfly.configure!(Refinery::Resources)
13
+ ::Refinery::Dragonfly.attach!(app, Refinery::Resources)
14
14
  end
15
15
 
16
16
  before_inclusion do
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = %q{Resources extension for Refinery CMS}
11
11
  s.description = %q{Handles all file upload and processing functionality in Refinery CMS.}
12
12
  s.email = %q{refinerycms@p.arndt.io}
13
- s.homepage = %q{http://refinerycms.com}
13
+ s.homepage = %q{https://www.refinerycms.com}
14
14
  s.rubyforge_project = %q{refinerycms}
15
15
  s.authors = ['Philip Arndt', 'Uģis Ozols', 'Rob Yurkowski']
16
16
  s.license = %q{MIT}
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'globalize', ['>= 5.1.0.beta1', '< 5.2']
25
25
  s.add_dependency 'activemodel-serializers-xml', '~> 1.0', '>= 1.0.1'
26
26
  s.add_dependency 'refinerycms-core', version
27
+ s.add_dependency 'refinerycms-dragonfly', '~> 1.0'
27
28
 
28
29
  s.required_ruby_version = Refinery::Version.required_ruby_version
29
30
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :resource, :class => Refinery::Resource do
3
3
  file Refinery.roots('refinery/resources').join("spec/fixtures/refinery_is_awesome.txt")
4
4
  end
@@ -74,7 +74,7 @@ module Refinery
74
74
  end
75
75
 
76
76
  context "edit/update" do
77
- let!(:resource) { FactoryGirl.create(:resource) }
77
+ let!(:resource) { FactoryBot.create(:resource) }
78
78
 
79
79
  it "updates file" do
80
80
  visit refinery.admin_resources_path
@@ -119,7 +119,7 @@ module Refinery
119
119
  end
120
120
 
121
121
  context "destroy" do
122
- let!(:resource) { FactoryGirl.create(:resource) }
122
+ let!(:resource) { FactoryBot.create(:resource) }
123
123
 
124
124
  it "removes file" do
125
125
  visit refinery.admin_resources_path
@@ -133,7 +133,7 @@ module Refinery
133
133
  end
134
134
 
135
135
  context "download" do
136
- let!(:resource) { FactoryGirl.create(:resource) }
136
+ let!(:resource) { FactoryBot.create(:resource) }
137
137
 
138
138
  it "succeeds" do
139
139
  visit refinery.admin_resources_path
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ describe Resources do
5
+ it_has_behaviour 'Creates a dragonfly App:'
6
+ it_has_behaviour 'adds the dragonfly app to the middleware stack'
7
+ end
8
+ end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  module Refinery
4
4
  describe Resource, :type => :model do
5
- let(:resource) { FactoryGirl.create(:resource) }
6
- let(:titled_resource) { FactoryGirl.create(:resource, resource_title: 'Resource Title')}
5
+ let(:resource) { FactoryBot.create(:resource) }
6
+ let(:titled_resource) { FactoryBot.create(:resource, resource_title: 'Resource Title')}
7
7
 
8
8
  context "with valid attributes" do
9
9
  it "should create successfully" do
@@ -27,7 +27,7 @@ module Refinery
27
27
  context "when Dragonfly.verify_urls is true" do
28
28
  before do
29
29
  allow(Refinery::Resources).to receive(:dragonfly_verify_urls).and_return(true)
30
- ::Refinery::Resources::Dragonfly.configure!
30
+ ::Refinery::Dragonfly.configure!(Refinery::Resources)
31
31
  end
32
32
 
33
33
  it "returns a url with an SHA parameter" do
@@ -38,7 +38,7 @@ module Refinery
38
38
  context "when Dragonfly.verify_urls is false" do
39
39
  before do
40
40
  allow(Refinery::Resources).to receive(:dragonfly_verify_urls).and_return(false)
41
- ::Refinery::Resources::Dragonfly.configure!
41
+ ::Refinery::Dragonfly.configure!(Refinery::Resources)
42
42
  end
43
43
  it "returns a url without an SHA parameter" do
44
44
  expect(resource.url).not_to match(/\?sha=[\da-fA-F]{16}\z/)
@@ -0,0 +1,18 @@
1
+ module Capybara
2
+
3
+ add_selector(:linkhref) do
4
+ xpath {|href| ".//a[@href='#{href}']"}
5
+ end
6
+ end
7
+
8
+ def ensure_on(path)
9
+ visit(path) unless current_path == path
10
+ end
11
+
12
+ RSpec.configure do |c|
13
+ c.alias_it_should_behave_like_to :it_has_behaviour, 'has behaviour:'
14
+ end
15
+
16
+ def uri_filename(url)
17
+ File.basename(URI.parse(url).path)
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -32,7 +32,7 @@ cert_chain:
32
32
  jOQmH9VbgbfUrXYM1YOKdlwW5sPR1f4PKLDlvEE+bppIUgKOgLOIv3i7KwrGvFOq
33
33
  5r7Wz/HY31SM47mkK21saPJG4NvUFEycf0wlpzP657Pl9aVo47aKKbxX
34
34
  -----END CERTIFICATE-----
35
- date: 2017-10-25 00:00:00.000000000 Z
35
+ date: 2018-05-21 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: acts_as_indexed
@@ -114,14 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 4.0.1
117
+ version: 4.0.2
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 4.0.1
124
+ version: 4.0.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: refinerycms-dragonfly
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.0'
125
139
  description: Handles all file upload and processing functionality in Refinery CMS.
126
140
  email: refinerycms@p.arndt.io
127
141
  executables: []
@@ -180,7 +194,6 @@ files:
180
194
  - lib/generators/refinery/resources/templates/config/initializers/refinery/resources.rb.erb
181
195
  - lib/refinery/resources.rb
182
196
  - lib/refinery/resources/configuration.rb
183
- - lib/refinery/resources/dragonfly.rb
184
197
  - lib/refinery/resources/engine.rb
185
198
  - lib/refinery/resources/validators.rb
186
199
  - lib/refinery/resources/validators/file_size_validator.rb
@@ -192,9 +205,10 @@ files:
192
205
  - spec/fixtures/refinery_is_awesome.txt
193
206
  - spec/fixtures/refinery_is_awesome2.txt
194
207
  - spec/lib/generators/refinery/resources/resources_generator_spec.rb
195
- - spec/lib/resources_spec.rb
208
+ - spec/lib/refinery/resources/engine_spec.rb
196
209
  - spec/models/refinery/resource_spec.rb
197
- homepage: http://refinerycms.com
210
+ - spec/spec_helper.rb
211
+ homepage: https://www.refinerycms.com
198
212
  licenses:
199
213
  - MIT
200
214
  metadata: {}
@@ -224,5 +238,6 @@ test_files:
224
238
  - spec/fixtures/refinery_is_awesome.txt
225
239
  - spec/fixtures/refinery_is_awesome2.txt
226
240
  - spec/lib/generators/refinery/resources/resources_generator_spec.rb
227
- - spec/lib/resources_spec.rb
241
+ - spec/lib/refinery/resources/engine_spec.rb
228
242
  - spec/models/refinery/resource_spec.rb
243
+ - spec/spec_helper.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,64 +0,0 @@
1
- require 'dragonfly'
2
-
3
- module Refinery
4
- module Resources
5
- module Dragonfly
6
-
7
- class << self
8
- def configure!
9
- ActiveRecord::Base.extend ::Dragonfly::Model
10
- ActiveRecord::Base.extend ::Dragonfly::Model::Validations
11
-
12
- app_resources = ::Dragonfly.app(:refinery_resources)
13
-
14
- app_resources.configure do |c|
15
- datastore :file, {
16
- :root_path => Refinery::Resources.datastore_root_path
17
- }
18
- url_format Refinery::Resources.dragonfly_url_format
19
- url_host Refinery::Resources.dragonfly_url_host
20
- verify_urls Refinery::Resources.dragonfly_verify_urls
21
- secret Refinery::Resources.dragonfly_secret
22
- response_header 'Content-Disposition' do |job, request, headers|
23
- "attachment; #{headers['Content-Disposition']}"
24
- end if Refinery::Resources.content_disposition == :attachment
25
- dragonfly_url nil
26
- end
27
-
28
- if ::Refinery::Resources.s3_backend
29
- require 'dragonfly/s3_data_store'
30
- options = {
31
- bucket_name: Refinery::Resources.s3_bucket_name,
32
- access_key_id: Refinery::Resources.s3_access_key_id,
33
- secret_access_key: Refinery::Resources.s3_secret_access_key
34
- }
35
- options.update(region: Refinery::Resources.s3_region) if Refinery::Resources.s3_region
36
- app_resources.use_datastore :s3, options
37
- end
38
-
39
- if Resources.custom_backend?
40
- app_resources.datastore = Resources.custom_backend_class.new(Resources.custom_backend_opts)
41
- end
42
- end
43
-
44
- ##
45
- # Injects Dragonfly::Middleware for Refinery::Images into the stack
46
- def attach!(app)
47
- if defined?(::Rack::Cache)
48
- unless app.config.action_controller.perform_caching && app.config.action_dispatch.rack_cache
49
- app.config.middleware.insert 0, ::Rack::Cache, {
50
- verbose: true,
51
- metastore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
52
- entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
53
- }
54
- end
55
- app.config.middleware.insert_after ::Rack::Cache, ::Dragonfly::Middleware, :refinery_resources
56
- else
57
- app.config.middleware.use ::Dragonfly::Middleware, :refinery_resources
58
- end
59
- end
60
- end
61
-
62
- end
63
- end
64
- end
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Refinery::Resources do
4
- describe "with custom s3 settings" do
5
- it "prefers custom values over the default" do
6
- Refinery::Core.s3_bucket_name = "kfc"
7
- described_class.s3_bucket_name = "buckethead"
8
-
9
- expect(described_class.s3_bucket_name).to eq("buckethead")
10
- end
11
- end
12
-
13
- describe "without custom s3 settings" do
14
- it "falls back on defaults" do
15
- described_class.s3_bucket_name = nil
16
- Refinery::Core.s3_bucket_name = "kfc"
17
-
18
- expect(described_class.s3_bucket_name).to eq("kfc")
19
- end
20
- end
21
-
22
- describe "with a custom storage backend" do
23
- before(:all) do
24
- DummyBackend1 = Class.new
25
- DummyBackend2 = Class.new
26
- end
27
-
28
- before(:each) do
29
- allow(Refinery::Core).to receive_messages(:dragonfly_custom_backend_class => DummyBackend1)
30
- end
31
-
32
- after(:each) do
33
- described_class.custom_backend_class = nil
34
- end
35
-
36
- it "uses the default configuration if present" do
37
- expect(described_class.custom_backend_class).to eq(DummyBackend1)
38
- end
39
-
40
- it "prefers custom values over the defaults" do
41
- described_class.custom_backend_class = 'DummyBackend2'
42
- expect(described_class.custom_backend_class).to eq(DummyBackend2)
43
- end
44
- end
45
- end