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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11e410f5838a7cabe8b6667af204ec5cc8046d8a
4
- data.tar.gz: 72dc8d9467ad12d6d9bc8fdc7f9e629ad22e2bd8
3
+ metadata.gz: 53953131c4d882031e21536bbe0b018fb44e3557
4
+ data.tar.gz: 09804e172de8b1be505280a76ab45dfba90689e0
5
5
  SHA512:
6
- metadata.gz: 41ce122ce3f3ca8e8741918c284d9348d97994b87927b6b3800dbef255aeaf7a1c605da07e574558c2c8c4047477b976a966b5946d2c6eee97c04fa60baa28bb
7
- data.tar.gz: 77ea586239f6b7c3168a50982200af7ef013133dbc38020eb8f945339d7b46c16a0d298bff70a6082fda073dba5117f032006c4442b78bd22ed3a6a6cd573b18
6
+ metadata.gz: 9eaf094a230df629d45232425858979f2cd6176a06b51f2985d3e624b41e68e8e2b300c132f55071faa84188ae5e2b7e38bef852f55a047e0c7b565b54e4df39
7
+ data.tar.gz: c8cee3d611540af727beb9abf18aabacc2c075151f96d9f4708fb49521f594de5c3885d035acdf4d3150e0286abf5c765a2e5e5125483f5bd11f46876a778f99
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ # 0.1.1
2
+ - Add `config.additional_paths`
3
+
1
4
  # 0.1.0
2
5
  - Initial release
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
@@ -10,6 +10,9 @@ module S3AssetsUploader
10
10
 
11
11
  def upload
12
12
  upload_path(@config.assets_path)
13
+ @config.additional_paths.each do |path|
14
+ upload_path(Pathname.new(path))
15
+ end
13
16
  end
14
17
 
15
18
  private
@@ -1,3 +1,3 @@
1
1
  module S3AssetsUploader
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
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-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk