carrierwave-webdav 0.4.2 → 0.4.3

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: f980e67aeef264ba639bd4b7f5444284e11cb16e
4
- data.tar.gz: db3baa02d5a18f70465aa9b54c74e53cf1dc8052
3
+ metadata.gz: 104e3949932f6d0d79ecc6e963ec20e22933ce97
4
+ data.tar.gz: 3ef2f1fb1586bf186c5a9c44e7e1721beae7bffa
5
5
  SHA512:
6
- metadata.gz: 211100cf7ac9244b7c400c12f10d97ad13d8144d8934bdedf225d5269613934c710c498f67a0fa369c947ebdd7ec7335c48535ac504260e22f68ed8e60b8aa9b
7
- data.tar.gz: d1a00fac73f81a9d7eb9450c3d96141e1ab495e50b343ae47db5f5ccaad1304b0f1c0b912a473ccd883373d9adc579c5f45fd73f0b1cf2597152c709b0c991fc
6
+ metadata.gz: 172a6e8b9adb899ecdb5fecaeb67e99518554ac49bab2e644b1f9266d8f1147f0a9c74e150f49511b4c096361756ed31d103de63ea42c5ce4aa56cabe378c491
7
+ data.tar.gz: 2099b07cfcbf6264bfb83e780ce874c6aace8ad37eff9692b8346eeefc0fe163678813b45e78b32df44da29ec0034f55a58b93d2ea50dd6a405e0177ffa590ff
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - 2.2.2
@@ -56,7 +56,7 @@ module CarrierWave
56
56
  end
57
57
 
58
58
  def read
59
- res = HTTParty.get(url, options)
59
+ res = HTTParty.get(read_url, options)
60
60
  if res.code != 200
61
61
  raise CarrierWave::IntegrityError.new("Can't download a file: #{res.inspect}")
62
62
  end
@@ -64,7 +64,7 @@ module CarrierWave
64
64
  end
65
65
 
66
66
  def headers
67
- res = HTTParty.head(url, options)
67
+ res = HTTParty.head(read_url, options)
68
68
  if res.code != 200
69
69
  raise CarrierWave::IntegrityError.new("Can't headers for a file: #{res.inspect}")
70
70
  end
@@ -100,7 +100,11 @@ module CarrierWave
100
100
  end
101
101
 
102
102
  def url
103
- "#{server}/#{path}"
103
+ if host = uploader.asset_host
104
+ host.respond_to?(:call) ? host.call(self) : [host, path].join('/')
105
+ else
106
+ read_url
107
+ end
104
108
  end
105
109
 
106
110
  alias :content_length :length
@@ -109,8 +113,12 @@ module CarrierWave
109
113
 
110
114
  private
111
115
 
116
+ def read_url
117
+ "#{server}/#{path}"
118
+ end
119
+
112
120
  def write_url
113
- @write_server ? "#{@write_server}/#{path}" : url
121
+ @write_server ? "#{@write_server}/#{path}" : read_url
114
122
  end
115
123
 
116
124
  def mkcol
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module WebDAV
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
@@ -91,4 +91,33 @@ describe CarrierWave::Storage::WebDAV do
91
91
  expect(@file.read).to eq(webdav_file.read)
92
92
  end
93
93
 
94
+ describe 'File#url' do
95
+ let(:root) { Pathname.new(@file.path).dirname }
96
+ let(:path) { @uploader.path.sub(root.to_path, '') }
97
+
98
+ before do
99
+ CarrierWave.configure do |config|
100
+ config.asset_host = host
101
+ config.root = root
102
+ end
103
+ end
104
+
105
+ context 'when asset_host is set' do
106
+ let(:host) { 'http://asset.host' }
107
+
108
+ it 'path contains asset_host' do
109
+ @uploader.cache!(@file)
110
+ expect(@uploader.url).to eq [host, path].join
111
+ end
112
+ end
113
+
114
+ context 'when asset_host is not set' do
115
+ let(:host) { nil }
116
+
117
+ it 'path does not contain asset_host' do
118
+ @uploader.cache!(@file)
119
+ expect(@uploader.url).to eq path
120
+ end
121
+ end
122
+ end
94
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-webdav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qinix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.2.2
83
+ rubygems_version: 2.5.1
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: WebDAV support for CarrierWave
@@ -89,3 +89,4 @@ test_files:
89
89
  - spec/lib/webdav_spec.rb
90
90
  - spec/spec_helper.rb
91
91
  - spec/supports/helpers.rb
92
+ has_rdoc: