s3_assets_uploader 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -0
- data/lib/s3_assets_uploader/config.rb +12 -1
- data/lib/s3_assets_uploader/uploader.rb +3 -0
- data/lib/s3_assets_uploader/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53953131c4d882031e21536bbe0b018fb44e3557
|
4
|
+
data.tar.gz: 09804e172de8b1be505280a76ab45dfba90689e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eaf094a230df629d45232425858979f2cd6176a06b51f2985d3e624b41e68e8e2b300c132f55071faa84188ae5e2b7e38bef852f55a047e0c7b565b54e4df39
|
7
|
+
data.tar.gz: c8cee3d611540af727beb9abf18aabacc2c075151f96d9f4708fb49521f594de5c3885d035acdf4d3150e0286abf5c765a2e5e5125483f5bd11f46876a778f99
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# S3AssetsUploader
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/s3_assets_uploader.svg)](http://badge.fury.io/rb/s3_assets_uploader)
|
3
|
+
[![Build Status](https://travis-ci.org/eagletmt/s3_assets_uploader.svg?branch=master)](https://travis-ci.org/eagletmt/s3_assets_uploader)
|
2
4
|
|
3
5
|
Upload Rails assets to S3.
|
4
6
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'aws-sdk'
|
2
2
|
|
3
3
|
module S3AssetsUploader
|
4
|
-
class Config < Struct.new(:s3_client, :bucket, :assets_path, :assets_prefix)
|
4
|
+
class Config < Struct.new(:s3_client, :bucket, :assets_path, :assets_prefix, :additional_paths)
|
5
5
|
class ValidationError < StandardError
|
6
6
|
end
|
7
7
|
|
@@ -9,6 +9,7 @@ module S3AssetsUploader
|
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
self.assets_path = DEFAULT_ASSETS_PATH
|
12
|
+
self.additional_paths = []
|
12
13
|
end
|
13
14
|
|
14
15
|
def assets_path
|
@@ -23,6 +24,9 @@ module S3AssetsUploader
|
|
23
24
|
if bucket.nil?
|
24
25
|
raise ValidationError.new('config.bucket must be set')
|
25
26
|
end
|
27
|
+
additional_paths.each do |path|
|
28
|
+
assert_under_public_path!(path)
|
29
|
+
end
|
26
30
|
self.s3_client ||= create_default_client
|
27
31
|
true
|
28
32
|
end
|
@@ -32,5 +36,12 @@ module S3AssetsUploader
|
|
32
36
|
def create_default_client
|
33
37
|
Aws::S3::Client.new
|
34
38
|
end
|
39
|
+
|
40
|
+
def assert_under_public_path!(path)
|
41
|
+
if Pathname.new(path).relative_path_from(public_path).to_s.start_with?('../')
|
42
|
+
raise ValidationError.new("#{path} must be under #{public_path}")
|
43
|
+
end
|
44
|
+
true
|
45
|
+
end
|
35
46
|
end
|
36
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_assets_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|