rain_forest 0.4.1 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4631f88b0bdbd28c7680f7e14b179b447c549b09
4
- data.tar.gz: 8a43f04a31b35ba78030dd6a55c7e048610acf6d
3
+ metadata.gz: 2c8078fadbdc4c6063f514affac5d65eb9e3df0c
4
+ data.tar.gz: 147555bc64682650c5e55c7d4081541541f946cf
5
5
  SHA512:
6
- metadata.gz: 028631222ec8c676fc074fb150e08708c5d8197274d452ce6e1043f5ea0a28a35993248959a7fddc9e5f1d50166edd090c10f98be3af1507654b0014317ac1b3
7
- data.tar.gz: 609cc0df38d85a57bfdef18b52701794b2bea1daf92672dc89d045f0a4ffb0098998dfc225c38fa718d262d6476f54f4a564a2f05ee542f1afa6c10c4c0a91f8
6
+ metadata.gz: 8e4aa64c948feb61a4b43680006e4989f77b5ee50c01b1a10ae8df9682aaae84dd8932520f1f726ff05d2e7ef061ce6c59da4fb1824f89e710ba9978f03d9755
7
+ data.tar.gz: a34cd95f583f0f2710fae598246157f33258003e73a4a9eb14f04a7273a2c89f1bef329c7e7efea05653bd8daaf030ddf953201b42c6250c10efb38360577380
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.4
@@ -14,6 +14,10 @@ module RainForest
14
14
  self.new.update_origin(distribution_id, new_origin_key)
15
15
  end
16
16
 
17
+ def self.create_invalidation(distribution_id, invalidate_paths_array)
18
+ self.new.create_invalidation(distribution_id, invalidate_paths_array)
19
+ end
20
+
17
21
  def update_origin(distribution_id, new_origin_key)
18
22
  begin
19
23
  dist = @client.get_distribution(id: distribution_id)
@@ -38,5 +42,26 @@ module RainForest
38
42
 
39
43
  return true, nil
40
44
  end
45
+
46
+ def create_invalidation(distribution_id, invalidate_paths_array, caller_reference=SecureRandom.hex(16))
47
+ begin
48
+ parameters = {
49
+ distribution_id: distribution_id,
50
+ invalidation_batch: {
51
+ paths: {
52
+ quantity: invalidate_paths_array.count,
53
+ items: invalidate_paths_array
54
+ },
55
+ caller_reference: caller_reference
56
+ }
57
+ }
58
+
59
+ resp = @client.create_invalidation(parameters)
60
+
61
+ return true, resp
62
+ rescue Exception => e
63
+ return false, e.message
64
+ end
65
+ end
41
66
  end
42
67
  end
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.1"
8
+ s.version = "0.4.4"
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"
12
+ s.date = "2016-08-22"
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 = [
@@ -62,4 +62,41 @@ describe RainForest::CloudFront do
62
62
  expect(success).to eq(false)
63
63
  end
64
64
  end
65
+
66
+ describe "#create_invalidation" do
67
+ before do
68
+ expect(SecureRandom).to receive(:hex).with(16).and_return("A_RANDOM_CALLER_REFERENCE")
69
+ end
70
+
71
+ let(:aws_response_object){double("AWS Response Object")}
72
+
73
+ it "created an invalidation" do
74
+ expected_parameters = {
75
+ distribution_id: "DISTRIBUTION_ID",
76
+ invalidation_batch: {
77
+ paths: {
78
+ quantity: 3,
79
+ items: ["FIRST_PATH", "SECOND_PATH", "THIRD_PATH"]
80
+ },
81
+ caller_reference: "A_RANDOM_CALLER_REFERENCE"
82
+ }
83
+ }
84
+
85
+ expect(client).to receive(:create_invalidation).with(expected_parameters).and_return(aws_response_object)
86
+
87
+ success, message_or_object = RainForest::CloudFront.create_invalidation("DISTRIBUTION_ID", ["FIRST_PATH", "SECOND_PATH", "THIRD_PATH"])
88
+
89
+ expect(message_or_object).to eq(aws_response_object)
90
+ expect(success).to eq(true)
91
+ end
92
+
93
+ it "handles errors" do
94
+ expect(client).to receive(:create_invalidation).and_raise(Exception.new("KABOOM!"))
95
+
96
+ success, message = RainForest::CloudFront.create_invalidation("DISTRIBUTION_ID", ["FIRST_PATH", "SECOND_PATH", "THIRD_PATH"])
97
+
98
+ expect(message).to eq("KABOOM!")
99
+ expect(success).to eq(false)
100
+ end
101
+ end
65
102
  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.1
4
+ version: 0.4.4
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-12 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk