soar_environment 0.1.11 → 0.2.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
  SHA1:
3
- metadata.gz: cefa3bc5eaa71c5da03f09bd9d4dc5bfe1c51ec2
4
- data.tar.gz: 2383ea89e73de67d0a573aeaea107fce11808321
3
+ metadata.gz: 2e1f515041de21ba072c785abd2980fddec6d379
4
+ data.tar.gz: 928898d6d632dbb2440cf78db7f714143a4eb86f
5
5
  SHA512:
6
- metadata.gz: 40a3795e20c120d02df36b6d6ebd3440e950287009b260aabb99d6fe55b3956ca7f7fe56f874428b1b946680e68742dc91602b61c821a80ebd1db0796273b793
7
- data.tar.gz: 052c104809d196139d8fae3f1438d7134ad0e0b9f436b72b47382527d8f8aa1d7a55f3e0a27e42aa78ca355b42d7a2b3f1eb537dd78d605add93992c71ea030f
6
+ metadata.gz: '019aa4c6bdae200c2f18f710d2ba3251a7076b224b677ac0ead12d5f0b3910a19de54319f029c34d329e5e7b7f4d8173a4f7ae6276b664c4a49fd398dc9e58b7'
7
+ data.tar.gz: f17f0ce4ac3ed112d8b79b613d34ce549c3090168eaf63e11fea662420652965cdba2c2dd49e8963773797891549a5577e02de03f104a762670a2b70c206ea31
data/README.md CHANGED
@@ -9,6 +9,8 @@ Exceptions raised:
9
9
  - SoarEnvironment::LoadError when an environment file cannot be loaded when loading environment
10
10
 
11
11
  Once an environment is loaded (taking process and environment file into account), supplementing from configuration can be performed. Supplementing only provides values if the keys are not already present in the environment, thus if present in an environment file, that entry would be preferred above presence in configuration.
12
+
13
+ This library also provides an environment validator that expects an IDENTIFIER and RACK_ENV to be set to one of SoarEnvironment::EnvironmentValidator::VALID_EXECUTION_ENVIRONMENTS
12
14
 
13
15
  ## Installation
14
16
 
@@ -42,6 +44,14 @@ Once loaded, the environment can be supplemented with a configuration:
42
44
  environment = @iut.supplement_with_configuration(config)
43
45
  ```
44
46
 
47
+ An environment can be validated:
48
+
49
+ ```
50
+ validator = SoarEnvironment::EnvironmentValidator.new
51
+ errors = validator.validate(environment)
52
+ # => [ invalid service identifier', 'Missing execution environment indicator', 'Invalid execution environment indicator' ]
53
+ ```
54
+
45
55
  ## Contributing
46
56
 
47
57
  Please send feedback and comments to the author at:
@@ -1,4 +1,5 @@
1
1
  require "soar_environment/version"
2
+ require "soar_environment/environment_validator"
2
3
  require "psych"
3
4
  require "yaml"
4
5
 
@@ -0,0 +1,13 @@
1
+ module SoarEnvironment
2
+ class EnvironmentValidator
3
+ VALID_EXECUTION_ENVIRONMENTS = ['production','development'] unless defined? VALID_EXECUTION_ENVIRONMENTS; VALID_EXECUTION_ENVIRONMENTS.freeze
4
+
5
+ def validate(environment)
6
+ errors = []
7
+ errors << 'invalid service identifier' if (environment['IDENTIFIER'].nil?) or (environment['IDENTIFIER'].strip == "")
8
+ errors << 'Missing execution environment indicator' if (environment['RACK_ENV'] == 'none') or (environment['RACK_ENV'].nil?) or (environment['RACK_ENV'].strip == "")
9
+ errors << 'Invalid execution environment indicator' if not VALID_EXECUTION_ENVIRONMENTS.include?(environment['RACK_ENV'])
10
+ errors
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module SoarEnvironment
2
- VERSION = "0.1.11"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -33,4 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
35
  spec.add_development_dependency "byebug"
36
+ spec.add_development_dependency 'simplecov'
37
+ spec.add_development_dependency 'simplecov-rcov'
38
+
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst Van Graan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-rcov
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'
83
111
  description: This library determines the set of environment variables for a service
84
112
  component in the SOAR architecture
85
113
  email:
@@ -100,6 +128,7 @@ files:
100
128
  - bin/console
101
129
  - bin/setup
102
130
  - lib/soar_environment.rb
131
+ - lib/soar_environment/environment_validator.rb
103
132
  - lib/soar_environment/version.rb
104
133
  - soar_environment.gemspec
105
134
  homepage: https://github.com/hetznerZA/soar_environment