frm 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/frm/s3.rb +17 -17
- data/lib/frm/version.rb +1 -1
- metadata +2 -2
data/lib/frm/s3.rb
CHANGED
@@ -5,32 +5,31 @@ module FRM
|
|
5
5
|
|
6
6
|
def initialize(opts={})
|
7
7
|
super()
|
8
|
-
@opts = opts
|
8
|
+
@opts = opts.dup
|
9
|
+
puts "@opts.inspect is #{@opts.inspect}"
|
9
10
|
@opts[:public_repo] ||= false
|
10
11
|
@opts[:acl] = @opts[:public_repo] ? :public_read : :private
|
11
|
-
@opts[:
|
12
|
-
@opts[:
|
13
|
-
raise "you either need to pass an aws_access_key option or set the AWS_ACCESS_KEY environment variable"
|
14
|
-
|
15
|
-
raise "you either need to pass an aws_secret_key option or set the AWS_SECRET_KEY environment variable" \
|
16
|
-
if @opts[:aws_secret_key].nil?
|
12
|
+
@opts[:access_key_id] ||= ENV['AWS_ACCESS_KEY_ID']
|
13
|
+
@opts[:secret_access_key] ||= ENV['AWS_SECRET_ACCESS_KEY']
|
14
|
+
raise "you either need to pass an aws_access_key option or set the AWS_ACCESS_KEY environment variable" if @opts[:access_key_id].nil?
|
15
|
+
raise "you either need to pass an aws_secret_key option or set the AWS_SECRET_KEY environment variable" if @opts[:secret_access_key].nil?
|
17
16
|
raise "you need to pass in a bucket param" unless @opts[:bucket]
|
18
17
|
raise "you need to pass in a prefix param" unless @opts[:prefix]
|
19
|
-
@opts[:prefix]
|
20
|
-
AWS.config(:access_key_id => @opts[:access_key_id],
|
18
|
+
@opts[:prefix] = @opts[:prefix] + '/' unless @opts[:prefix][-1] == '/'
|
19
|
+
AWS.config(:access_key_id => @opts[:access_key_id],
|
21
20
|
:secret_access_key => @opts[:secret_access_key])
|
22
21
|
@s3 = AWS::S3.new
|
23
22
|
end
|
24
23
|
|
25
24
|
def exists?(relative_path)
|
26
|
-
handle_errors do
|
25
|
+
handle_errors do
|
27
26
|
return @s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].exists?
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def etag(relative_path)
|
32
31
|
quoted_etag = ""
|
33
|
-
handle_errors do
|
32
|
+
handle_errors do
|
34
33
|
quoted_etag = @s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].etag
|
35
34
|
end
|
36
35
|
# stupid method call is actually putting quotes in the string,
|
@@ -39,20 +38,20 @@ module FRM
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def put(relative_path,value)
|
42
|
-
handle_errors do
|
43
|
-
@s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].write(value,acl: @opts[:acl]) #
|
41
|
+
handle_errors do
|
42
|
+
@s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].write(value,acl: @opts[:acl]) #
|
44
43
|
end
|
45
44
|
return true
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
def get(relative_path)
|
49
|
-
handle_errors do
|
48
|
+
handle_errors do
|
50
49
|
return @s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].read
|
51
50
|
end
|
52
51
|
end
|
53
|
-
|
52
|
+
|
54
53
|
def delete(relative_path)
|
55
|
-
handle_errors do
|
54
|
+
handle_errors do
|
56
55
|
@s3.buckets[@opts[:bucket]].objects[full_path(relative_path)].delete
|
57
56
|
end
|
58
57
|
return true
|
@@ -73,3 +72,4 @@ module FRM
|
|
73
72
|
|
74
73
|
end
|
75
74
|
end
|
75
|
+
|
data/lib/frm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|