rain_forest 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +1 -0
- data/VERSION +1 -1
- data/lib/rain_forest/s3.rb +14 -0
- data/rain_forest.gemspec +2 -2
- data/spec/rain_forest/s3_spec.rb +20 -0
- 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: 4631f88b0bdbd28c7680f7e14b179b447c549b09
|
4
|
+
data.tar.gz: 8a43f04a31b35ba78030dd6a55c7e048610acf6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 028631222ec8c676fc074fb150e08708c5d8197274d452ce6e1043f5ea0a28a35993248959a7fddc9e5f1d50166edd090c10f98be3af1507654b0014317ac1b3
|
7
|
+
data.tar.gz: 609cc0df38d85a57bfdef18b52701794b2bea1daf92672dc89d045f0a4ffb0098998dfc225c38fa718d262d6476f54f4a564a2f05ee542f1afa6c10c4c0a91f8
|
data/README.markdown
CHANGED
@@ -56,6 +56,7 @@ config/initializers/rain_forest.rb
|
|
56
56
|
## Available Methods
|
57
57
|
RainForest::S3.write(storage_key, data, permission='public-read')
|
58
58
|
RainForest::S3.read(storage_key)
|
59
|
+
RainForest::S3.copy(source_key, dest_key)
|
59
60
|
RainForest::S3.move(source_key, dest_key)
|
60
61
|
RainForest::S3.content_length(storage_key)
|
61
62
|
RainForest::S3.delete_objects(prefix)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/rain_forest/s3.rb
CHANGED
@@ -30,6 +30,10 @@ module RainForest
|
|
30
30
|
self.new.read(storage_key)
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.copy(source_key, dest_key)
|
34
|
+
self.new.copy(source_key, dest_key)
|
35
|
+
end
|
36
|
+
|
33
37
|
def self.move(source_key, dest_key)
|
34
38
|
self.new.move(source_key, dest_key)
|
35
39
|
end
|
@@ -68,6 +72,16 @@ module RainForest
|
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
75
|
+
def copy(source_key, dest_key)
|
76
|
+
begin
|
77
|
+
@client.copy_object(bucket: @bucket, copy_source: "#{@bucket}/#{source_key}", key: dest_key)
|
78
|
+
rescue Exception => e
|
79
|
+
return false, e.message
|
80
|
+
end
|
81
|
+
|
82
|
+
return true, nil
|
83
|
+
end
|
84
|
+
|
71
85
|
def move(source_key, dest_key)
|
72
86
|
begin
|
73
87
|
@client.copy_object(bucket: @bucket, copy_source: "#{@bucket}/#{source_key}", key: dest_key)
|
data/rain_forest.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rain_forest"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Lukas Beaton"]
|
12
|
-
s.date = "2016-07-
|
12
|
+
s.date = "2016-07-12"
|
13
13
|
s.description = "A simplified adaptor for Amazon Web Services. Only S3 is supported at the moment."
|
14
14
|
s.email = "lukas.beaton@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/rain_forest/s3_spec.rb
CHANGED
@@ -126,4 +126,24 @@ describe RainForest::S3 do
|
|
126
126
|
expect(message).to eq("KABOOM!")
|
127
127
|
end
|
128
128
|
end
|
129
|
+
|
130
|
+
describe "#copy" do
|
131
|
+
it "works" do
|
132
|
+
expect(client).to receive(:copy_object).with(bucket: ENV["RAIN_FOREST_AWS_BUCKET"], copy_source: "#{ENV["RAIN_FOREST_AWS_BUCKET"]}/SOURCE-KEY", key: "DEST-KEY")
|
133
|
+
|
134
|
+
success, message = RainForest::S3.copy("SOURCE-KEY", "DEST-KEY")
|
135
|
+
|
136
|
+
expect(success).to eq(true)
|
137
|
+
expect(message).to eq(nil)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "handles errors" do
|
141
|
+
expect(client).to receive(:copy_object).and_raise(Exception.new("KABOOM!"))
|
142
|
+
|
143
|
+
success, message = RainForest::S3.copy("SOURCE-KEY", "DEST-KEY")
|
144
|
+
|
145
|
+
expect(success).to eq(false)
|
146
|
+
expect(message).to eq("KABOOM!")
|
147
|
+
end
|
148
|
+
end
|
129
149
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rain_forest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Beaton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|