rain_forest 0.4.5 → 0.4.6
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 +3 -0
- data/VERSION +1 -1
- data/lib/rain_forest/cloud_front.rb +23 -0
- data/rain_forest.gemspec +2 -2
- data/spec/rain_forest/cloud_front_spec.rb +48 -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: 75b2766008d33db45631f33bced1f0abc5f1eb85
|
4
|
+
data.tar.gz: 0a375939c728033f141a5a7100d020fbb6192c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c42707a3baf069efb9bf41e5b801818e8e627241e91edb8452136cf95025b43f2ac1b23a563c373a8ec090c0767b73fd30872f01e099226bd7ade6410bb887c1
|
7
|
+
data.tar.gz: fca852480299e2186ac6146d9e13c62ca35148b52396ac75a4fa3383d607612c551ce8ab08b9828a30db4bf36abb843b33149ad8156e1d9560349b707dd687d0
|
data/README.markdown
CHANGED
@@ -60,7 +60,10 @@ config/initializers/rain_forest.rb
|
|
60
60
|
RainForest::S3.move(source_key, dest_key)
|
61
61
|
RainForest::S3.content_length(storage_key)
|
62
62
|
RainForest::S3.delete_objects(prefix)
|
63
|
+
RainForest::CloudFront.get_distribution(distribution_id)
|
64
|
+
RainForest::CloudFront.get_distribution_status(distribution_id)
|
63
65
|
RainForest::CloudFront.update_origin(distribution_id, new_origin)
|
66
|
+
RainForest::CloudFront.create_invalidation(distribution_id, invalid_path_array)
|
64
67
|
|
65
68
|
|
66
69
|
## Contributing to Rain Forest
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.6
|
@@ -11,6 +11,20 @@ module RainForest
|
|
11
11
|
@client = ::Aws::CloudFront::Client.new(access_key_id: akid, secret_access_key: secret, region: 'cloudfront.amazonaws.com')
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.get_distribution(distribution_id)
|
15
|
+
self.new.get_distribution(distribution_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get_distribution_status(distribution_id)
|
19
|
+
success, status_or_message = self.new.get_distribution(distribution_id)
|
20
|
+
|
21
|
+
if success
|
22
|
+
return success, status_or_message.distribution.status
|
23
|
+
else
|
24
|
+
return success, status_or_message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
14
28
|
def self.update_origin(distribution_id, new_origin_key)
|
15
29
|
self.new.update_origin(distribution_id, new_origin_key)
|
16
30
|
end
|
@@ -19,6 +33,15 @@ module RainForest
|
|
19
33
|
self.new.create_invalidation(distribution_id, invalidate_paths_array)
|
20
34
|
end
|
21
35
|
|
36
|
+
def get_distribution(distribution_id)
|
37
|
+
begin
|
38
|
+
dist = @client.get_distribution(id: distribution_id)
|
39
|
+
return true, dist
|
40
|
+
rescue Exception => e
|
41
|
+
return false, e.message
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
22
45
|
def update_origin(distribution_id, new_origin_key)
|
23
46
|
begin
|
24
47
|
dist = @client.get_distribution(id: distribution_id)
|
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.6"
|
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-08-
|
12
|
+
s.date = "2016-08-23"
|
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 = [
|
@@ -63,6 +63,54 @@ describe RainForest::CloudFront do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
describe "#get_distribution" do
|
67
|
+
let(:distribution){
|
68
|
+
OpenStruct.new(
|
69
|
+
distribution: OpenStruct.new(id: "DISTRIBUTION_ID", status: "InProgress")
|
70
|
+
)
|
71
|
+
}
|
72
|
+
|
73
|
+
it "works" do
|
74
|
+
expect(client).to receive(:get_distribution).with(id: 'DISTRIBUTION_ID').and_return(distribution)
|
75
|
+
|
76
|
+
success, message_or_object = RainForest::CloudFront.get_distribution('DISTRIBUTION_ID')
|
77
|
+
|
78
|
+
expect(message_or_object).to eq(distribution)
|
79
|
+
expect(success).to eq(true)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "handles errors" do
|
83
|
+
expect(client).to receive(:get_distribution).with(id: 'DISTRIBUTION_ID').and_raise(Exception.new("KABOOM!"))
|
84
|
+
|
85
|
+
success, message_or_object = RainForest::CloudFront.get_distribution('DISTRIBUTION_ID')
|
86
|
+
|
87
|
+
expect(message_or_object).to eq("KABOOM!")
|
88
|
+
expect(success).to eq(false)
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#get_distribution_status" do
|
92
|
+
it "works" do
|
93
|
+
expect(client).to receive(:get_distribution).with(id: 'DISTRIBUTION_ID').and_return(distribution)
|
94
|
+
|
95
|
+
success, message_or_status = RainForest::CloudFront.get_distribution_status('DISTRIBUTION_ID')
|
96
|
+
|
97
|
+
expect(message_or_status).to eq("InProgress")
|
98
|
+
expect(success).to eq(true)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "handles errors" do
|
102
|
+
expect(client).to receive(:get_distribution).with(id: 'DISTRIBUTION_ID').and_raise(Exception.new("KABOOM!"))
|
103
|
+
|
104
|
+
success, message_or_status = RainForest::CloudFront.get_distribution_status('DISTRIBUTION_ID')
|
105
|
+
|
106
|
+
expect(message_or_status).to eq("KABOOM!")
|
107
|
+
expect(success).to eq(false)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
|
66
114
|
describe "#create_invalidation" do
|
67
115
|
before do
|
68
116
|
expect(SecureRandom).to receive(:hex).with(16).and_return("A_RANDOM_CALLER_REFERENCE")
|
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.6
|
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-08-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|