star 1.0.0 → 1.1.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 +6 -5
- data/lib/star/file.rb +25 -0
- data/lib/star/version.rb +1 -1
- data/star.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b29105c837f42831693f510c4afbc907bfd8edc
|
4
|
+
data.tar.gz: 49b8120b3cf3d9ec80157ac318bacbfdda9de00a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ee6b51e48ebe1ccf021ecb52b56d8d46c7fe005fe9175dfa6d619877cb22826be78fe41d03146a7f53a7fe8c5f51e2d75c46391e3ee6d9c40a05115f06ced3
|
7
|
+
data.tar.gz: 6ddbadb07b009d6c539d98a2be2226b2b462bf04a079fbc987358796327bd374123fb1c80e4f7d048bd39ce94011719760be40ceea7376f467a4a0c355484539
|
data/.travis.yml
CHANGED
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.1.0 - 2015.10.26
|
10
|
+
|
11
|
+
* [FEATURE] Add `Star::File#delete` to delete files
|
12
|
+
|
9
13
|
## 1.0.0 - 2015.10.26
|
10
14
|
|
11
15
|
* [FEATURE] Add `Star::File` to write/read files on S3
|
data/README.md
CHANGED
@@ -85,6 +85,8 @@ By default, this URL will only be publicly available for 30 seconds.
|
|
85
85
|
This is useful to let your users download the file, while preventing them
|
86
86
|
from sharing the URL and having other (unauthenticated) users download it.
|
87
87
|
|
88
|
+
To delete the file from S3, simply call `file.delete`.
|
89
|
+
|
88
90
|
Options
|
89
91
|
-------
|
90
92
|
|
@@ -174,7 +176,6 @@ In production, your files will still be stored on S3.
|
|
174
176
|
|
175
177
|
Your Rails controller/action that redirects to a file might look like this:
|
176
178
|
|
177
|
-
|
178
179
|
```ruby
|
179
180
|
if Star.remote?
|
180
181
|
redirect_to file.url
|
@@ -214,8 +215,8 @@ document the changes in CHANGELOG.md and README.md, bump the version, then run
|
|
214
215
|
|
215
216
|
rake release
|
216
217
|
|
217
|
-
Remember that the star gem follows [Semantic Versioning](http://semver.org)
|
218
|
-
Any new release that fixes bugs and does not add features should bump the *patch* version (1.0.x).
|
219
|
-
Any new release that is fully backward-compatible should bump the *minor* version (1.x.0).
|
220
|
-
Any new version that breaks compatibility should bump the *major* version (2.0.0).
|
218
|
+
Remember that the star gem follows [Semantic Versioning](http://semver.org):
|
221
219
|
|
220
|
+
* Any new release that fixes bugs and does not add features should bump the *patch* version (1.0.x).
|
221
|
+
* Any new release that is fully backward-compatible should bump the *minor* version (1.x.0).
|
222
|
+
* Any new version that breaks compatibility should bump the *major* version (2.0.0).
|
data/lib/star/file.rb
CHANGED
@@ -34,6 +34,10 @@ module Star
|
|
34
34
|
Star.remote? ? store_remote(tmp_file) : store_local(tmp_file)
|
35
35
|
end
|
36
36
|
|
37
|
+
def delete
|
38
|
+
Star.remote? ? delete_remote : delete_local
|
39
|
+
end
|
40
|
+
|
37
41
|
private
|
38
42
|
|
39
43
|
def store_remote(tmp_file)
|
@@ -54,6 +58,27 @@ module Star
|
|
54
58
|
FileUtils.mv tmp_file.path, path
|
55
59
|
end
|
56
60
|
|
61
|
+
def delete_remote
|
62
|
+
timestamp = Time.now.utc.strftime "%a, %d %b %Y %H:%M:%S UTC"
|
63
|
+
signature = sign "DELETE\n\n\n#{timestamp}"
|
64
|
+
request = delete_file signature, timestamp
|
65
|
+
response = Net::HTTP.start(host, 443, use_ssl: true) do |http|
|
66
|
+
http.request request
|
67
|
+
end
|
68
|
+
response.error! unless response.is_a? Net::HTTPNoContent
|
69
|
+
end
|
70
|
+
|
71
|
+
def delete_file(signature, timestamp)
|
72
|
+
Net::HTTP::Delete.new("/#{bucket}#{remote_path}").tap do |request|
|
73
|
+
request.add_field 'Authorization', "AWS #{key}:#{signature}"
|
74
|
+
request.add_field 'Date', timestamp
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete_local
|
79
|
+
FileUtils.rm_f path
|
80
|
+
end
|
81
|
+
|
57
82
|
def url_params
|
58
83
|
expires_at = Time.now.to_i + Star.configuration.duration
|
59
84
|
digest = OpenSSL::Digest.new 'sha1'
|
data/lib/star/version.rb
CHANGED
data/star.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
24
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
26
|
-
spec.add_development_dependency 'coveralls', '~> 0.8.
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
26
|
+
spec.add_development_dependency 'coveralls', '~> 0.8.10'
|
27
27
|
spec.add_development_dependency 'pry-nav', '~> 0.2.4'
|
28
28
|
end
|
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.1.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:
|
12
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,28 +45,28 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '3.
|
48
|
+
version: '3.4'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
55
|
+
version: '3.4'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: coveralls
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.8.
|
62
|
+
version: 0.8.10
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.8.
|
69
|
+
version: 0.8.10
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: pry-nav
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.5.1
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Write files to S3, read them with expiring URLs
|