directwave 0.0.7 → 0.0.8

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: 9895a5e52aa5d43976fa70963070d9668892a984
4
- data.tar.gz: 40d6073208f79498a33f9ef7329d4bff07bb7973
3
+ metadata.gz: a4221f30da940883f8288a642650c86d77a99ea4
4
+ data.tar.gz: 18e034a411ec465b1f1a6224c6bad81527de5501
5
5
  SHA512:
6
- metadata.gz: 632ccdafe01372d6bb26050a6d7d860e64177f67b45d4e8944973d014b6c6ce5b972390dee0b1b680b4f769a6fc2255141231c33439aff3d059c971d09548ca8
7
- data.tar.gz: e38220247f008dfe52c2328614cbfb7d614330e8f2afdc618554d9ff6b90ae88948b450a052d3461ee16463e7ccef211f8f14c00d17b87e2105f25d2e93fd6c2
6
+ metadata.gz: 2c1a66ff5b293765698b6ee1f96d4828fff8a98bd4c05abdc08b3efd02ef94743732f6ed0daa4783b1c6572f70c4dfd6e5bb34b8fd74d455d4dee2e043f18e17
7
+ data.tar.gz: cac8f81c2bd7ec567a81ee36675c4ea7a81f8b01650449469d9893e757e099d8601c946f17b4ca1c68213aa5087614095cff89e61f0aadb6d2eecfc5d4c654ec
@@ -4,7 +4,7 @@ require "active_support/core_ext"
4
4
  require "active_support/concern"
5
5
  require "uuid"
6
6
  require "aws-sdk"
7
- require "base64"
7
+ require "base64"
8
8
 
9
9
  module DirectWave
10
10
  class << self
@@ -12,7 +12,7 @@ module DirectWave
12
12
  DirectWave::Uploader::Base.configure(&block)
13
13
  end
14
14
  end
15
-
15
+
16
16
  autoload :Mounter, "directwave/mounter"
17
17
  autoload :VERSION, "directwave/version"
18
18
 
@@ -26,4 +26,4 @@ module DirectWave
26
26
  end
27
27
  end
28
28
 
29
- require "directwave/railtie" if defined?(Rails)
29
+ require "directwave/railtie" if defined?(Rails)
@@ -1,9 +1,9 @@
1
1
  module DirectWave
2
-
2
+
3
3
  module Uploader
4
4
  module Configuration
5
5
  extend ActiveSupport::Concern
6
-
6
+
7
7
  included do
8
8
  add_config :s3_access_policy
9
9
  add_config :s3_bucket
@@ -11,17 +11,19 @@ module DirectWave
11
11
  add_config :s3_secret_access_key
12
12
  add_config :s3_region
13
13
  add_config :s3_authentication_timeout
14
-
14
+
15
15
  add_config :max_file_size
16
16
  add_config :expiration_period
17
-
17
+
18
18
  add_config :store_dir
19
19
  add_config :upload_dir
20
20
  add_config :cache_dir
21
21
 
22
+ add_config :asset_host
23
+
22
24
  reset_config
23
25
  end
24
-
26
+
25
27
  module ClassMethods
26
28
  def add_config(name)
27
29
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -33,18 +35,18 @@ module DirectWave
33
35
  return nil if name.nil? && !instance_variable_defined?("@#{name}")
34
36
  @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name
35
37
  end
36
-
38
+
37
39
  def #{name}=(value)
38
40
  @#{name} = value
39
41
  end
40
- end
41
-
42
+ end
43
+
42
44
  def #{name}
43
45
  self.class.#{name}
44
46
  end
45
47
  RUBY
46
48
  end
47
-
49
+
48
50
  def configure
49
51
  yield self
50
52
  end
@@ -54,7 +56,7 @@ module DirectWave
54
56
  config.s3_access_policy = :public_read
55
57
  config.s3_region = "us-east-1"
56
58
  config.s3_authentication_timeout = 60.minutes
57
-
59
+
58
60
  config.max_file_size = 300.megabytes
59
61
  config.expiration_period = 6.hours
60
62
 
@@ -66,5 +68,5 @@ module DirectWave
66
68
  end # ClassMethods
67
69
  end #Configuration
68
70
  end # Uploader
69
-
71
+
70
72
  end # DirectWave
@@ -1,22 +1,22 @@
1
1
  module DirectWave
2
-
2
+
3
3
  module Uploader
4
4
  module Paths
5
5
  extend ActiveSupport::Concern
6
-
6
+
7
7
  def url(version=:original)
8
8
  versions[version.to_sym].url || default_url
9
9
  end
10
-
10
+
11
11
  def key(version=:original)
12
12
  versions[version.to_sym].key
13
13
  end
14
-
14
+
15
15
  def default_url; end
16
-
16
+
17
17
  def filename(part=nil)
18
18
  return original_filename unless has_store_key?
19
-
19
+
20
20
  key_path = store_key.split("/")
21
21
  filename_parts = []
22
22
  filename = filename_parts.unshift(key_path.pop)
@@ -24,23 +24,23 @@ module DirectWave
24
24
  filename_parts.unshift(unique_key) if unique_key
25
25
  filename_parts.join("/")
26
26
  end
27
-
27
+
28
28
  def original_filename
29
29
  model[mounted_as.to_s] if model.respond_to?(mounted_as)
30
30
  end
31
-
31
+
32
32
  def store_key=(string)
33
33
  @store_key = string
34
34
  end
35
-
35
+
36
36
  def store_key
37
37
  @store_key ||= "#{upload_dir}/#{guid}/${filename}"
38
38
  end
39
-
39
+
40
40
  def has_store_key?
41
41
  @store_key.present? && !(@store_key =~ /#{Regexp.escape("${filename}")}\z/)
42
- end
42
+ end
43
43
  end # Paths
44
44
  end # Uploader
45
-
45
+
46
46
  end
@@ -14,10 +14,16 @@ module DirectWave
14
14
 
15
15
  def url
16
16
  @url ||= begin
17
- if @uploader.s3_access_policy != :public_read
18
- file.url_for(:get, { expires: @uploader.s3_authentication_timeout }).to_s
17
+ uri = if @uploader.s3_access_policy != :public_read
18
+ file.url_for :get, { expires: @uploader.s3_authentication_timeout }
19
19
  else
20
- file.public_url.to_s
20
+ file.public_url
21
+ end
22
+
23
+ if @uploader.class.asset_host.present?
24
+ "#{@uploader.class.asset_host}#{uri.path}?#{uri.query}"
25
+ else
26
+ uri.to_s
21
27
  end
22
28
  end
23
29
  end
@@ -1,3 +1,3 @@
1
1
  module Directwave
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directwave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dima Kochnev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-28 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project: directwave
185
- rubygems_version: 2.0.3
185
+ rubygems_version: 2.0.14
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Ruby direct uploader to Amazon S3