spurious-ruby-awssdk-helper 0.2.4 → 1.0.0
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.md +8 -2
- data/lib/spurious/ruby/awssdk/helper.rb +0 -1
- data/lib/spurious/ruby/awssdk/helper/version.rb +1 -1
- data/lib/spurious/ruby/awssdk/strategy.rb +30 -30
- data/spec/helper.rb +2 -3
- data/spec/strategy_spec.rb +115 -42
- data/spurious-ruby-awssdk-helper.gemspec +3 -2
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d7747ebd65c39785b7dfabbbd1356afe588900
|
4
|
+
data.tar.gz: 34bd39dbdc36f85d4dbef058e8fd4294a02ca3de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3451f77cc7b875fdaffc61a93045e4101ea3840df06c9a65efbd669c4ff11e3a9358c0b5b6ed430a968d0a13866bbd2db88598328b8789d0eeb95a46fabdf125
|
7
|
+
data.tar.gz: 46841663c1e0d5ffbb49cdf290264c121c74f05128b0f723810bd3b7a5f0dc0f434f8d858b782f94ad86c6bb0b35324dba3c3c1489eb163156f6c68ae01dc76d
|
data/README.md
CHANGED
@@ -20,6 +20,12 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install spurious-ruby-awssdk-helper
|
22
22
|
|
23
|
+
## AWS SDK Versions
|
24
|
+
|
25
|
+
- The gem supports using both `~v1` and `~v2` of the `aws-sdk` gem.
|
26
|
+
- The gem uses `~v1` before it's `v1.0.0` release.
|
27
|
+
- The gem uses `~v2` past it's `v1.0.0+` release.
|
28
|
+
|
23
29
|
## Usage
|
24
30
|
|
25
31
|
You can configure the `aws-sdk` two different ways:
|
@@ -45,8 +51,8 @@ If you're running you application in a container on the same host
|
|
45
51
|
as spurious then you can pass in the following linked containers:
|
46
52
|
|
47
53
|
```bash
|
48
|
-
docker run ... --link
|
49
|
-
-sqs:sqs.spurious.localhost --link spurious-
|
54
|
+
docker run ... --link spurious-s3:s3.spurious.localhost --link spurious
|
55
|
+
-sqs:sqs.spurious.localhost --link spurious-dynamo:dynamodb.spurious.localhost
|
50
56
|
```
|
51
57
|
|
52
58
|
then inside your application:
|
@@ -5,52 +5,52 @@ module Spurious
|
|
5
5
|
module Ruby
|
6
6
|
module Awssdk
|
7
7
|
class Strategy
|
8
|
-
attr_accessor :mapping
|
9
|
-
|
10
8
|
def initialize(set_all = false)
|
11
9
|
@mapping = {}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
return unless set_all
|
11
|
+
|
12
|
+
dynamo
|
13
|
+
sqs
|
14
|
+
s3
|
15
|
+
end
|
16
|
+
|
17
|
+
def apply(config)
|
18
|
+
mapping.each do |type, mappings|
|
19
|
+
ports = config[type]
|
20
|
+
Aws.config.update("#{mappings['identifier']}_port".to_sym => ports.first["HostPort"]) if mappings["port"]
|
21
|
+
Aws.config.update("#{mappings['identifier']}_endpoint".to_sym => ports.first["Host"]) if mappings["ip"]
|
16
22
|
end
|
23
|
+
|
24
|
+
Aws.config.update(:use_ssl => false, :s3_force_path_style => true)
|
17
25
|
end
|
18
26
|
|
19
27
|
def dynamo(port = true, ip = true)
|
20
|
-
mapping[
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
mapping["spurious-dynamo"] = {
|
29
|
+
"port" => port,
|
30
|
+
"ip" => ip,
|
31
|
+
"identifier" => "dynamo_db"
|
24
32
|
}
|
25
33
|
end
|
26
34
|
|
27
|
-
def
|
28
|
-
mapping[
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
def s3(port = true, ip = true)
|
36
|
+
mapping["spurious-s3"] = {
|
37
|
+
"port" => port,
|
38
|
+
"ip" => ip,
|
39
|
+
"identifier" => "s3"
|
32
40
|
}
|
33
41
|
end
|
34
42
|
|
35
|
-
def
|
36
|
-
mapping[
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
def sqs(port = true, ip = true)
|
44
|
+
mapping["spurious-sqs"] = {
|
45
|
+
"port" => port,
|
46
|
+
"ip" => ip,
|
47
|
+
"identifier" => "sqs"
|
40
48
|
}
|
41
49
|
end
|
42
50
|
|
43
|
-
|
44
|
-
mapping.each do |type, mappings|
|
45
|
-
ports = config[type]
|
46
|
-
AWS.config("#{mappings['identifier']}_port".to_sym => ports.first['HostPort']) if mappings['port']
|
47
|
-
AWS.config("#{mappings['identifier']}_endpoint".to_sym => ports.first['Host']) if mappings['ip']
|
48
|
-
end
|
49
|
-
|
50
|
-
AWS.config(:use_ssl => false, :s3_force_path_style => true)
|
51
|
-
|
52
|
-
end
|
51
|
+
private
|
53
52
|
|
53
|
+
attr_reader :mapping
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/spec/helper.rb
CHANGED
data/spec/strategy_spec.rb
CHANGED
@@ -1,61 +1,134 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
|
+
require "spurious/ruby/awssdk/strategy"
|
2
3
|
|
3
4
|
describe Spurious::Ruby::Awssdk::Strategy do
|
5
|
+
subject { described_class.new set_all }
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
7
|
+
before do
|
8
|
+
allow(Aws).to receive(:config).with(no_args) { mock_config }
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:config) do
|
12
|
+
{
|
13
|
+
"spurious-sqs" => [
|
14
|
+
{
|
15
|
+
"GuestPort" => 123,
|
16
|
+
"HostPort" => 456,
|
17
|
+
"Host" => "foo"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"spurious-s3" => [
|
21
|
+
{
|
22
|
+
"GuestPort" => 789,
|
23
|
+
"HostPort" => 101,
|
24
|
+
"Host" => "foo"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"spurious-dynamo" => [
|
28
|
+
{
|
29
|
+
"GuestPort" => 121,
|
30
|
+
"HostPort" => 314,
|
31
|
+
"Host" => "foo"
|
32
|
+
}
|
33
|
+
]
|
30
34
|
}
|
35
|
+
end
|
36
|
+
let(:mock_config) do
|
37
|
+
instance_double(
|
38
|
+
"Hash",
|
39
|
+
:update => nil
|
40
|
+
)
|
41
|
+
end
|
42
|
+
let(:set_all) { true }
|
31
43
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
44
|
+
describe "#apply" do
|
45
|
+
context "applys ports to all services" do
|
46
|
+
specify do
|
47
|
+
expect(mock_config).to receive(:update).exactly(7).times
|
48
|
+
subject.apply config
|
49
|
+
end
|
50
|
+
end
|
36
51
|
|
37
|
-
|
38
|
-
|
52
|
+
context "applys ports to 0 services" do
|
53
|
+
let(:set_all) { false }
|
54
|
+
specify do
|
55
|
+
expect(mock_config).to receive(:update).exactly(1).times
|
56
|
+
subject.apply config
|
57
|
+
end
|
58
|
+
end
|
39
59
|
|
60
|
+
specify do
|
61
|
+
expect(mock_config).to receive(:update).with({
|
62
|
+
:use_ssl => false,
|
63
|
+
:s3_force_path_style => true
|
64
|
+
}).once
|
65
|
+
subject.apply config
|
40
66
|
end
|
67
|
+
end
|
41
68
|
|
42
|
-
|
43
|
-
|
69
|
+
describe "#dynamo" do
|
70
|
+
let(:set_all) { false }
|
71
|
+
before { subject.dynamo(true, true) }
|
44
72
|
|
45
|
-
|
46
|
-
|
73
|
+
context "sets ports just for this service" do
|
74
|
+
specify do
|
75
|
+
expect(mock_config).to receive(:update).exactly(3).times
|
76
|
+
subject.apply config
|
77
|
+
end
|
78
|
+
end
|
47
79
|
|
80
|
+
specify do
|
81
|
+
expect(mock_config).to receive(:update).with(:dynamo_db_port => 314).once
|
82
|
+
subject.apply config
|
48
83
|
end
|
49
84
|
|
50
|
-
|
51
|
-
|
85
|
+
specify do
|
86
|
+
expect(mock_config).to receive(:update).with(:dynamo_db_endpoint => "foo").once
|
87
|
+
subject.apply config
|
88
|
+
end
|
89
|
+
end
|
52
90
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
subject.apply(config)
|
91
|
+
describe "#s3" do
|
92
|
+
let(:set_all) { false }
|
93
|
+
before { subject.s3(true, true) }
|
57
94
|
|
95
|
+
context "sets ports just for this service" do
|
96
|
+
specify do
|
97
|
+
expect(mock_config).to receive(:update).exactly(3).times
|
98
|
+
subject.apply config
|
99
|
+
end
|
58
100
|
end
|
59
101
|
|
102
|
+
specify do
|
103
|
+
expect(mock_config).to receive(:update).with(:s3_port => 101).once
|
104
|
+
subject.apply config
|
105
|
+
end
|
106
|
+
|
107
|
+
specify do
|
108
|
+
expect(mock_config).to receive(:update).with(:s3_endpoint => "foo").once
|
109
|
+
subject.apply config
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#sqs" do
|
114
|
+
let(:set_all) { false }
|
115
|
+
before { subject.sqs(true, true) }
|
116
|
+
|
117
|
+
context "sets ports just for this service" do
|
118
|
+
specify do
|
119
|
+
expect(mock_config).to receive(:update).exactly(3).times
|
120
|
+
subject.apply config
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
specify do
|
125
|
+
expect(mock_config).to receive(:update).with(:sqs_port => 456).once
|
126
|
+
subject.apply config
|
127
|
+
end
|
128
|
+
|
129
|
+
specify do
|
130
|
+
expect(mock_config).to receive(:update).with(:sqs_endpoint => "foo").once
|
131
|
+
subject.apply config
|
132
|
+
end
|
60
133
|
end
|
61
134
|
end
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["stevenmajack@gmail.com"]
|
11
11
|
spec.summary = %q{Helper gem for configuring the AWS ruby SDK with spurious details}
|
12
12
|
spec.description = %q{Helper gem for configuring the AWS ruby SDK with spurious details}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/spurious-io/ruby-awssdk-helper"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -19,8 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "pry"
|
22
23
|
spec.add_development_dependency "rake"
|
23
24
|
spec.add_development_dependency "rake-rspec", ">= 0.0.2"
|
24
25
|
|
25
|
-
spec.add_runtime_dependency "aws-sdk", "~>
|
26
|
+
spec.add_runtime_dependency "aws-sdk", "~> 2"
|
26
27
|
end
|
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spurious-ruby-awssdk-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake-rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: 0.0.2
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: 0.0.2
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: aws-sdk
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - ~>
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '2'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - ~>
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '2'
|
69
83
|
description: Helper gem for configuring the AWS ruby SDK with spurious details
|
70
84
|
email:
|
71
85
|
- stevenmajack@gmail.com
|
@@ -73,8 +87,8 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
78
92
|
- Gemfile
|
79
93
|
- LICENSE.txt
|
80
94
|
- README.md
|
@@ -85,7 +99,7 @@ files:
|
|
85
99
|
- spec/helper.rb
|
86
100
|
- spec/strategy_spec.rb
|
87
101
|
- spurious-ruby-awssdk-helper.gemspec
|
88
|
-
homepage:
|
102
|
+
homepage: https://github.com/spurious-io/ruby-awssdk-helper
|
89
103
|
licenses:
|
90
104
|
- MIT
|
91
105
|
metadata: {}
|
@@ -95,17 +109,17 @@ require_paths:
|
|
95
109
|
- lib
|
96
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
111
|
requirements:
|
98
|
-
- -
|
112
|
+
- - ">="
|
99
113
|
- !ruby/object:Gem::Version
|
100
114
|
version: '0'
|
101
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
116
|
requirements:
|
103
|
-
- -
|
117
|
+
- - ">="
|
104
118
|
- !ruby/object:Gem::Version
|
105
119
|
version: '0'
|
106
120
|
requirements: []
|
107
121
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.6
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: Helper gem for configuring the AWS ruby SDK with spurious details
|