star 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/star/file.rb +34 -4
- data/lib/star/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: 89914a09838e130825c2db61502c74f713b473e7
|
4
|
+
data.tar.gz: f2a04a96579ae2512a5162ddf771047be89da6f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f633d688af692ccfa96bdbe6fe462d4271c47ad115528731caa3c4423fd54112506aa7b04bdb4ce1bc80990020465cb36553bc8d2c69e7e614247d9e857cad12
|
7
|
+
data.tar.gz: e5baa3c1eaa12a1810d3be5af46b95e2a4cf27ccdd3ff40cabb3cba2fed012acea8c5176ccc48beb58227f2c6fb582cfebee566b94b693e7b594138d6dcfc00f
|
data/.travis.yml
CHANGED
@@ -4,4 +4,4 @@ rvm:
|
|
4
4
|
before_install: gem install bundler -v 1.10.6
|
5
5
|
env:
|
6
6
|
matrix:
|
7
|
-
|
7
|
+
secure: HraDnUT1Py2HLDuyYvZaVvgRTFLyfHI9iZA+Zo4auN2IYFdBNAK7x8dNh/LzEjKycUcJ+CGz/8QMegoxcD3bZE5AJtIb0O7u9rw81BQBmNVS4F3Q9PitNQ1Qw/nRBStJTOFcFET9L7wmotS7OZMhWE0fj9OLj6/T4TnL08+1VerWNdFm3uHgJCWNh3iRyNRdb2Je399L5lv9Xopqz1Wk2Xy6oRQAX06W7gEQuEVsGUvslIt+pdYWRv3mrzh+pQDiwdGI7GYWEyVqH6xsdPMnrga/+e6ignoYnGcW9GerojhYo+Gb0O+n6zOwL16/ePils/VjwBt7vZ76H52zNmW2Z5IDfrKB7YTubC3Dsw408r1zLF/b/4ShT0weqkxOtfWYpw02BA87S1aV/yWy+9S6f6kx6fE8nzQWP1h7sUO3xvEdco3OxsFr1qcUoxDU/0zDJk1nLKzFSJ221sRmJYusvt4MMHTt8gCp47R+pKii9J1GsbfFFFJF/nDMfG5fdY9A8LPiY8Zz0lKisEJWz6sWssi53tYavps9n2yZ5QNx0msKakzD/k6TiM/wnZ8Hz6GrJqXhSXG3X+uneeEuINHGnL7lus46+5RY/ae4eu3f/Ci2cDjOTkmlzM2JgJQ5zK/zwKd6ZuKUrcCOp65KZ1vSIek6VmxQYvLEsQAUYBwKDP0=
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 1.2.0 - 2015.01.25
|
10
|
+
|
11
|
+
* [FEATURE] Add `Star::File#copy_from` to duplicate files
|
12
|
+
|
9
13
|
## 1.1.0 - 2015.10.26
|
10
14
|
|
11
15
|
* [FEATURE] Add `Star::File#delete` to delete files
|
data/README.md
CHANGED
data/lib/star/file.rb
CHANGED
@@ -38,6 +38,14 @@ module Star
|
|
38
38
|
Star.remote? ? delete_remote : delete_local
|
39
39
|
end
|
40
40
|
|
41
|
+
def copy_from(source)
|
42
|
+
Star.remote? ? copy_from_remote(source) : copy_from_local(source)
|
43
|
+
end
|
44
|
+
|
45
|
+
def remote_path
|
46
|
+
URI.escape path
|
47
|
+
end
|
48
|
+
|
41
49
|
private
|
42
50
|
|
43
51
|
def store_remote(tmp_file)
|
@@ -75,10 +83,36 @@ module Star
|
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
86
|
+
def copy_from_remote(source)
|
87
|
+
timestamp = Time.now.utc.strftime "%a, %d %b %Y %H:%M:%S UTC"
|
88
|
+
extra = "x-amz-copy-source:/#{bucket}#{source.remote_path}"
|
89
|
+
signature = sign "PUT\n\n#{@content_type}\n#{timestamp}\n#{extra}"
|
90
|
+
request = copy_file signature, timestamp, source
|
91
|
+
response = Net::HTTP.start(host, 443, use_ssl: true) do |http|
|
92
|
+
http.request request
|
93
|
+
end
|
94
|
+
response.error! unless response.is_a? Net::HTTPSuccess
|
95
|
+
sleep 3 # See https://forums.aws.amazon.com/message.jspa?messageID=370480
|
96
|
+
end
|
97
|
+
|
98
|
+
def copy_file(signature, timestamp, source)
|
99
|
+
Net::HTTP::Put.new("/#{bucket}#{remote_path}").tap do |request|
|
100
|
+
request.add_field 'Date', timestamp
|
101
|
+
request.add_field 'Content-Type', @content_type
|
102
|
+
request.add_field 'x-amz-copy-source', "/#{bucket}#{source.remote_path}"
|
103
|
+
request.add_field 'Authorization', "AWS #{key}:#{signature}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
78
107
|
def delete_local
|
79
108
|
FileUtils.rm_f path
|
80
109
|
end
|
81
110
|
|
111
|
+
def copy_from_local(source)
|
112
|
+
FileUtils.mkdir_p ::File.dirname(path)
|
113
|
+
FileUtils.cp source.path, path
|
114
|
+
end
|
115
|
+
|
82
116
|
def url_params
|
83
117
|
expires_at = Time.now.to_i + Star.configuration.duration
|
84
118
|
digest = OpenSSL::Digest.new 'sha1'
|
@@ -117,10 +151,6 @@ module Star
|
|
117
151
|
"s3.amazonaws.com"
|
118
152
|
end
|
119
153
|
|
120
|
-
def remote_path
|
121
|
-
URI.escape path
|
122
|
-
end
|
123
|
-
|
124
154
|
def key
|
125
155
|
Star.configuration.access_key_id
|
126
156
|
end
|
data/lib/star/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: star
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- claudiob
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|