exercism_config 0.10.0 → 0.11.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29923659114d2bf254bad2e019a321f070cb3ff299ed4ea8ce715e92b8fd316e
|
4
|
+
data.tar.gz: ab184837acd4f8df85259f8b92004a6b120232874d1b83cccdb7a4afcddaf8f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893a4ffaa832a31aed0896a6191ce52e466a5cf1341a2f96674a55373cf0b011a815e51f3e832b38e4166616a95102cc4347ed63b549f3407f67efc7fb533947
|
7
|
+
data.tar.gz: 424ce4177752ef4da4d8745ff1d3766396ff9ccd7a872cf1697383b3d73eec13933bc149dcf36665496f6eb8d8b11c1eacd44f989d8882eb9e0ebcb888f77a52
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ExercismConfig
|
2
|
+
class GenerateAwsSettings
|
3
|
+
include Mandate
|
4
|
+
|
5
|
+
def initialize(environment)
|
6
|
+
@environment = environment
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
{
|
11
|
+
region: 'eu-west-2',
|
12
|
+
profile: profile,
|
13
|
+
access_key_id: aws_access_key_id,
|
14
|
+
secret_access_key: aws_secret_access_key
|
15
|
+
}.select {|k,v|v}
|
16
|
+
end
|
17
|
+
|
18
|
+
memoize
|
19
|
+
def aws_access_key_id
|
20
|
+
case environment
|
21
|
+
when :development, :test
|
22
|
+
"FAKE"
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
memoize
|
29
|
+
def aws_secret_access_key
|
30
|
+
case environment
|
31
|
+
when :development, :test
|
32
|
+
"FAKE"
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
memoize
|
39
|
+
def profile
|
40
|
+
case environment
|
41
|
+
when :production
|
42
|
+
"exercism_staging"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
memoize
|
47
|
+
def environment
|
48
|
+
return @environment.to_sym if @environment
|
49
|
+
|
50
|
+
env = ENV["EXERCISM_ENV"] || ENV["RAILS_ENV"] || ENV["APP_ENV"]
|
51
|
+
raise Exercism::ConfigError, "No environment set - set one of EXERCISM_ENV, RAILS_ENV or APP_ENV" unless env
|
52
|
+
|
53
|
+
unless %w[development test production].include?(env)
|
54
|
+
raise Exercism::ConfigError, "environments must be one of development test production. Got #{env}"
|
55
|
+
end
|
56
|
+
|
57
|
+
env.to_sym
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ExercismConfig
|
2
|
+
class SetupDynamodbClient
|
3
|
+
include Mandate
|
4
|
+
|
5
|
+
def initialize(environment)
|
6
|
+
@environment = environment
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
aws_settings = GenerateAwsSettings.(environment).merge(
|
11
|
+
endpoint: config_endpoint,
|
12
|
+
|
13
|
+
# We don't want a profile for this AWS service
|
14
|
+
# as we run it locally. But we do normally, so
|
15
|
+
# we locally override this here.
|
16
|
+
profile: nil
|
17
|
+
).select {|k,v|v}
|
18
|
+
Aws::DynamoDB::Client.new(aws_settings)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
attr_reader :environment
|
23
|
+
|
24
|
+
memoize
|
25
|
+
def config_endpoint
|
26
|
+
case environment
|
27
|
+
when :development, :test
|
28
|
+
"http://localhost:3039"
|
29
|
+
else
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exercism_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
@@ -127,7 +127,9 @@ files:
|
|
127
127
|
- exercism_config.gemspec
|
128
128
|
- lib/exercism/config.rb
|
129
129
|
- lib/exercism_config.rb
|
130
|
+
- lib/exercism_config/generate_aws_settings.rb
|
130
131
|
- lib/exercism_config/retrieve.rb
|
132
|
+
- lib/exercism_config/setup_dynamodb_client.rb
|
131
133
|
- lib/exercism_config/version.rb
|
132
134
|
homepage: https://exercism.io
|
133
135
|
licenses: []
|