exercism_config 0.12.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd0b7e2733cf6504836725513ee9249452432e16744c87a498294c9bf607f565
4
- data.tar.gz: a86ee6db78ade29db5385811b66785b8ab78e9dbd572d2eb063dcfc954c34e1c
3
+ metadata.gz: 9c094d61eb0003e49c33c3f1398167c15888c46824271fec7ad761747d31487c
4
+ data.tar.gz: 310a0343c3962799b65b6b52446fb2056ee7b1af54c904c4a7ba7bbe4093dbb5
5
5
  SHA512:
6
- metadata.gz: 21890667a1426ec324fc6b32b8cfb07c7f38825313141ab92dfc4ed4800c90021f6dfcb95c2b212e99eea55dafa5e59be08845e5a5a11662f42689d781fc6add
7
- data.tar.gz: fc540dfe23e6e75c6861f07c5bf0871954241836a5d81e88cc1dc8aa23540309fb074622ef9730fa21a4f764766255ca986ec6a8845de40bf8fa8ddfff5ae8bd
6
+ metadata.gz: 0f62ce107a3a34874b6d661e2930e68be15c502ac6264146485f593d4c274f6f33600e6da165efe1c1a67be742d7d17da05e85c66430b36696ea2a0b00a18199
7
+ data.tar.gz: 55abe5deff25311edab033ac5eb96ced241df33471839bc4f95b204b93dfaf84c7ada5965a4cbe70ab6e56b2c59a4fc0e503226f430e9346260c3477f7015b37
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exercism_config (0.11.0)
4
+ exercism_config (0.16.0)
5
5
  aws-sdk-dynamodb (~> 1.0)
6
6
  mandate
7
7
  zeitwerk
@@ -10,7 +10,7 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  aws-eventstream (1.1.0)
13
- aws-partitions (1.345.0)
13
+ aws-partitions (1.346.0)
14
14
  aws-sdk-core (3.104.3)
15
15
  aws-eventstream (~> 1, >= 1.0.2)
16
16
  aws-partitions (~> 1, >= 1.239.0)
@@ -3,8 +3,9 @@ require 'mandate'
3
3
  require "ostruct"
4
4
  require 'json'
5
5
 
6
+ require_relative 'exercism_config/determine_environment'
6
7
  require_relative 'exercism_config/generate_aws_settings'
7
- require_relative 'exercism_config/setup_dynamodb_client.rb'
8
+ require_relative 'exercism_config/setup_dynamodb_client'
8
9
  require_relative 'exercism_config/retrieve'
9
10
  require_relative 'exercism_config/generate_aws_settings'
10
11
  require_relative "exercism_config/version"
@@ -15,6 +16,10 @@ module Exercism
15
16
  class ConfigError < RuntimeError
16
17
  end
17
18
 
19
+ def self.environment
20
+ @environment ||= ExercismConfig::DetermineEnvironment.()
21
+ end
22
+
18
23
  def self.config
19
24
  @config ||= ExercismConfig::Retrieve.()
20
25
  end
@@ -0,0 +1,16 @@
1
+ module ExercismConfig
2
+ class DetermineEnvironment
3
+ include Mandate
4
+
5
+ def call
6
+ env = ENV["EXERCISM_ENV"] || ENV["RAILS_ENV"] || ENV["APP_ENV"]
7
+ raise Exercism::ConfigError, "No environment set - set one of EXERCISM_ENV, RAILS_ENV or APP_ENV" unless env
8
+
9
+ unless %w[development test production].include?(env)
10
+ raise Exercism::ConfigError, "environments must be one of development test production. Got #{env}"
11
+ end
12
+
13
+ env.to_sym
14
+ end
15
+ end
16
+ end
@@ -2,10 +2,6 @@ module ExercismConfig
2
2
  class GenerateAwsSettings
3
3
  include Mandate
4
4
 
5
- def initialize(environment)
6
- @environment = environment
7
- end
8
-
9
5
  def call
10
6
  {
11
7
  region: 'eu-west-2',
@@ -17,7 +13,7 @@ module ExercismConfig
17
13
 
18
14
  memoize
19
15
  def aws_access_key_id
20
- case environment
16
+ case Exercism.environment
21
17
  when :development, :test
22
18
  "FAKE"
23
19
  else
@@ -27,7 +23,7 @@ module ExercismConfig
27
23
 
28
24
  memoize
29
25
  def aws_secret_access_key
30
- case environment
26
+ case Exercism.environment
31
27
  when :development, :test
32
28
  "FAKE"
33
29
  else
@@ -37,24 +33,10 @@ module ExercismConfig
37
33
 
38
34
  memoize
39
35
  def profile
40
- case environment
36
+ case Exercism.environment
41
37
  when :production
42
38
  "exercism_staging"
43
39
  end
44
40
  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
41
  end
60
42
  end
@@ -2,12 +2,8 @@ module ExercismConfig
2
2
  class Retrieve
3
3
  include Mandate
4
4
 
5
- def initialize(environment = nil)
6
- @environment = environment
7
- end
8
-
9
5
  def call
10
- client = SetupDynamodbClient.(environment)
6
+ client = SetupDynamoDBClient.()
11
7
 
12
8
  resp = client.scan({table_name: "config"})
13
9
  items = resp.to_h[:items]
@@ -15,7 +11,14 @@ module ExercismConfig
15
11
  h[item['id']] = item['value']
16
12
  end
17
13
 
18
- aws_settings = GenerateAwsSettings.(environment)
14
+ # Tweak things for dynamodb when we're running in test mode
15
+ if Exercism.environment == :test
16
+ %w{dynamodb_tooling_jobs_table}.each do |key|
17
+ data[key] = "#{data[key]}-test"
18
+ end
19
+ end
20
+
21
+ aws_settings = GenerateAwsSettings.()
19
22
  Exercism::Config.new(data, aws_settings)
20
23
  rescue Exercism::ConfigError
21
24
  raise
@@ -36,20 +39,6 @@ module ExercismConfig
36
39
 
37
40
  Aws::DynamoDB::Client.new(config)
38
41
  end
39
-
40
- memoize
41
- def environment
42
- return @environment.to_sym if @environment
43
-
44
- env = ENV["EXERCISM_ENV"] || ENV["RAILS_ENV"] || ENV["APP_ENV"]
45
- raise Exercism::ConfigError, "No environment set - set one of EXERCISM_ENV, RAILS_ENV or APP_ENV" unless env
46
-
47
- unless %w[development test production].include?(env)
48
- raise Exercism::ConfigError, "environments must be one of development test production. Got #{env}"
49
- end
50
-
51
- env.to_sym
52
- end
53
42
  end
54
43
  end
55
44
 
@@ -1,13 +1,9 @@
1
1
  module ExercismConfig
2
- class SetupDynamodbClient
2
+ class SetupDynamoDBClient
3
3
  include Mandate
4
4
 
5
- def initialize(environment)
6
- @environment = environment
7
- end
8
-
9
5
  def call
10
- aws_settings = GenerateAwsSettings.(environment).merge(
6
+ aws_settings = GenerateAwsSettings.().merge(
11
7
  endpoint: config_endpoint,
12
8
 
13
9
  # We don't want a profile for this AWS service
@@ -23,10 +19,10 @@ module ExercismConfig
23
19
 
24
20
  memoize
25
21
  def config_endpoint
26
- case environment
22
+ case Exercism.environment
27
23
  when :development, :test
28
- host = ENV["EXERCISM_DOCKER"] ? "dynamodb" : "localhost"
29
- "http://#{host}:3039"
24
+ host = ENV["EXERCISM_DOCKER"] ? "dynamodb:8000" : "localhost:3039"
25
+ "http://#{host}"
30
26
  else
31
27
  nil
32
28
  end
@@ -1,3 +1,3 @@
1
1
  module ExercismConfig
2
- VERSION = "0.12.0"
2
+ VERSION = "0.17.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exercism_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -127,6 +127,7 @@ files:
127
127
  - exercism_config.gemspec
128
128
  - lib/exercism/config.rb
129
129
  - lib/exercism_config.rb
130
+ - lib/exercism_config/determine_environment.rb
130
131
  - lib/exercism_config/generate_aws_settings.rb
131
132
  - lib/exercism_config/retrieve.rb
132
133
  - lib/exercism_config/setup_dynamodb_client.rb