exercism_config 0.1.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +0 -5
- data/Gemfile.lock +10 -7
- data/README.md +16 -26
- data/exercism_config.gemspec +9 -0
- data/lib/exercism/config.rb +12 -0
- data/lib/exercism_config.rb +3 -2
- data/lib/exercism_config/retrieve.rb +36 -4
- data/lib/exercism_config/version.rb +1 -1
- metadata +102 -4
- data/lib/exercism_config/config.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620afb9bb7623f6ed560ad3e6431b4466ad985379c4e0af174b8a635fc4b19df
|
4
|
+
data.tar.gz: ad2d2b64388d893da5099aa3d3827a706c5ec98de2e1ca5e0f2802d0e79d41a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 105e94188dbcd307eba148de2107912e1bb35431181f0ee1399b49553a1420d2db946ee467a0a12d81ad784138f68c785905b3ae349b63a9592f65e8cd5b5641
|
7
|
+
data.tar.gz: 9c2bb195adf603c26c9d0236f21b35c1bdef5b57ebbca7ccc3f91c8c0b4ec21d9cc28a379314ed04813c1f40a9b6f4cfc257b292a46330e924cdef58e477f962
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exercism_config (0.
|
4
|
+
exercism_config (0.6.0)
|
5
|
+
aws-sdk-dynamodb (~> 1.0)
|
6
|
+
mandate
|
7
|
+
zeitwerk
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: https://rubygems.org/
|
8
11
|
specs:
|
9
12
|
aws-eventstream (1.1.0)
|
10
|
-
aws-partitions (1.
|
11
|
-
aws-sdk-core (3.104.
|
13
|
+
aws-partitions (1.345.0)
|
14
|
+
aws-sdk-core (3.104.3)
|
12
15
|
aws-eventstream (~> 1, >= 1.0.2)
|
13
16
|
aws-partitions (~> 1, >= 1.239.0)
|
14
17
|
aws-sigv4 (~> 1.1)
|
@@ -21,19 +24,19 @@ GEM
|
|
21
24
|
jmespath (1.4.0)
|
22
25
|
mandate (0.3.0)
|
23
26
|
minitest (5.14.1)
|
27
|
+
mocha (1.11.2)
|
24
28
|
rake (12.3.3)
|
25
|
-
zeitwerk (2.
|
29
|
+
zeitwerk (2.4.0)
|
26
30
|
|
27
31
|
PLATFORMS
|
28
32
|
ruby
|
29
33
|
|
30
34
|
DEPENDENCIES
|
31
|
-
|
35
|
+
bundler (~> 2.1)
|
32
36
|
exercism_config!
|
33
|
-
mandate
|
34
37
|
minitest (~> 5.0)
|
38
|
+
mocha
|
35
39
|
rake (~> 12.0)
|
36
|
-
zeitwerk
|
37
40
|
|
38
41
|
BUNDLED WITH
|
39
42
|
2.1.4
|
data/README.md
CHANGED
@@ -1,36 +1,26 @@
|
|
1
|
-
#
|
1
|
+
# Exercism Config
|
2
2
|
|
3
|
-
|
3
|
+
When terraform creates Exercism's infrastructure, it writes endpoints and DNS entries to DynamoDB.
|
4
|
+
This gem allows you to trivially retrieve that data.
|
4
5
|
|
5
|
-
|
6
|
+
When running on AWS, simply ensure the machine has read-access to the relevant table (currently hardcoded to `config`).
|
7
|
+
On a local machine specify the AWS_PROFILE environment variable with the relevant profile stored in your `.aws/credentials`.
|
6
8
|
|
7
|
-
##
|
9
|
+
## Usage
|
8
10
|
|
9
|
-
|
11
|
+
Simply include this gem in your Gemfile, require it, and then refer to the object:
|
10
12
|
|
11
13
|
```ruby
|
14
|
+
# Gemfile
|
12
15
|
gem 'exercism_config'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install exercism_config
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
# Your code
|
18
|
+
require 'exercism_config'
|
19
|
+
ExercismConfig.config.webservers_alb_dns_name
|
20
|
+
```
|
34
21
|
|
35
|
-
|
22
|
+
To print out all the config from the command-line, you can run:
|
36
23
|
|
24
|
+
```bash
|
25
|
+
AWS_PROFILE=exercism_terraform ./bin/run
|
26
|
+
```
|
data/exercism_config.gemspec
CHANGED
@@ -21,4 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "aws-sdk-dynamodb", "~> 1.0"
|
26
|
+
spec.add_dependency "mandate"
|
27
|
+
spec.add_dependency "zeitwerk"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
30
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
32
|
+
spec.add_development_dependency "mocha"
|
24
33
|
end
|
data/lib/exercism_config.rb
CHANGED
@@ -2,13 +2,14 @@ require "exercism_config/version"
|
|
2
2
|
require 'aws-sdk-dynamodb'
|
3
3
|
require 'mandate'
|
4
4
|
require "ostruct"
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
require "zeitwerk"
|
7
8
|
loader = Zeitwerk::Loader.for_gem
|
8
9
|
loader.setup
|
9
10
|
|
10
|
-
module
|
11
|
+
module Exercism
|
11
12
|
def self.config
|
12
|
-
@config ||= Retrieve.()
|
13
|
+
@config ||= ExercismConfig::Retrieve.()
|
13
14
|
end
|
14
15
|
end
|
@@ -2,22 +2,54 @@ module ExercismConfig
|
|
2
2
|
class Retrieve
|
3
3
|
include Mandate
|
4
4
|
|
5
|
+
def initialize(environment = nil)
|
6
|
+
@environment = environment
|
7
|
+
end
|
8
|
+
|
5
9
|
def call
|
6
|
-
|
10
|
+
aws_settings = GenerateAwsSettings.(environment)
|
11
|
+
client = Aws::DynamoDB::Client.new(aws_settings)
|
12
|
+
|
13
|
+
resp = client.scan({table_name: "config"})
|
7
14
|
items = resp.to_h[:items]
|
8
15
|
data = items.each_with_object({}) do |item, h|
|
9
16
|
h[item['id']] = item['value']
|
10
17
|
end
|
11
18
|
|
12
|
-
Config.new(data)
|
19
|
+
Exercism::Config.new(data, aws_settings)
|
20
|
+
rescue Exercism::ConfigError
|
21
|
+
raise
|
22
|
+
rescue => e
|
23
|
+
raise Exercism::ConfigError, "Exercism Config could not be loaded: #{e.message}"
|
13
24
|
end
|
14
25
|
|
26
|
+
private
|
15
27
|
memoize
|
16
28
|
def aws_client
|
17
|
-
config = {
|
18
|
-
|
29
|
+
config = {
|
30
|
+
region: 'eu-west-2',
|
31
|
+
profile: profile,
|
32
|
+
endpoint: endpoint,
|
33
|
+
access_key_id: aws_access_key_id,
|
34
|
+
secret_access_key: aws_secret_access_key
|
35
|
+
}.select {|k,v|v}
|
36
|
+
|
19
37
|
Aws::DynamoDB::Client.new(config)
|
20
38
|
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
|
21
53
|
end
|
22
54
|
end
|
23
55
|
|
metadata
CHANGED
@@ -1,15 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exercism_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-dynamodb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mandate
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: zeitwerk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mocha
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
13
111
|
description:
|
14
112
|
email:
|
15
113
|
- jez.walker@gmail.com
|
@@ -27,8 +125,8 @@ files:
|
|
27
125
|
- bin/run
|
28
126
|
- bin/setup
|
29
127
|
- exercism_config.gemspec
|
128
|
+
- lib/exercism/config.rb
|
30
129
|
- lib/exercism_config.rb
|
31
|
-
- lib/exercism_config/config.rb
|
32
130
|
- lib/exercism_config/retrieve.rb
|
33
131
|
- lib/exercism_config/version.rb
|
34
132
|
homepage: https://exercism.io
|