legion-settings 1.1.3 → 1.2.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/.github/workflows/sourcehawk-scan.yml +20 -0
- data/.gitignore +5 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +2 -7
- data/CODE_OF_CONDUCT.md +75 -0
- data/CONTRIBUTING.md +55 -0
- data/Gemfile +8 -0
- data/INDIVIDUAL_CONTRIBUTOR_LICENSE.md +30 -0
- data/LICENSE +201 -0
- data/NOTICE.txt +9 -0
- data/README.md +23 -36
- data/SECURITY.md +9 -0
- data/attribution.txt +1 -0
- data/legion-settings.gemspec +22 -22
- data/lib/legion/settings.rb +11 -2
- data/lib/legion/settings/loader.rb +3 -0
- data/lib/legion/settings/os.rb +34 -0
- data/lib/legion/settings/version.rb +1 -1
- data/sourcehawk.yml +4 -0
- metadata +36 -122
- data/.circleci/config.yml +0 -105
- data/Gemfile.lock +0 -78
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bitbucket-pipelines.yml +0 -17
- data/lib/legion/settings/constants.rb +0 -5
- data/lib/legion/settings/rules.rb +0 -92
- data/lib/legion/settings/validator.rb +0 -63
- data/lib/legion/settings/validators.rb +0 -9
data/.circleci/config.yml
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
orbs:
|
3
|
-
ruby: circleci/ruby@1.1.2
|
4
|
-
sonarcloud: sonarsource/sonarcloud@1.0.2
|
5
|
-
|
6
|
-
jobs:
|
7
|
-
"rubocop":
|
8
|
-
docker:
|
9
|
-
- image: cimg/ruby:2.7
|
10
|
-
steps:
|
11
|
-
- checkout
|
12
|
-
- restore_cache:
|
13
|
-
key: "bundler cache mri"
|
14
|
-
- run: bundle update
|
15
|
-
- run: bundle exec rubocop --format=json --out=rubocop-result.json
|
16
|
-
- store_test_results:
|
17
|
-
path: rubocop-result.json
|
18
|
-
- sonarcloud/scan
|
19
|
-
- run: bundle exec rubocop
|
20
|
-
- save_cache:
|
21
|
-
key: "bundler cache mri"
|
22
|
-
paths:
|
23
|
-
- "/usr/local/bundle"
|
24
|
-
"ruby-two-five":
|
25
|
-
docker:
|
26
|
-
- image: cimg/ruby:2.5
|
27
|
-
steps:
|
28
|
-
- checkout
|
29
|
-
- restore_cache:
|
30
|
-
key: "bundler cache mri"
|
31
|
-
- run: bundle update
|
32
|
-
- save_cache:
|
33
|
-
key: "bundler cache mri"
|
34
|
-
paths:
|
35
|
-
- "/usr/local/bundle"
|
36
|
-
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
37
|
-
- store_test_results:
|
38
|
-
path: rspec-results.xml
|
39
|
-
- sonarcloud/scan
|
40
|
-
"ruby-two-six":
|
41
|
-
docker:
|
42
|
-
- image: cimg/ruby:2.6
|
43
|
-
steps:
|
44
|
-
- checkout
|
45
|
-
- restore_cache:
|
46
|
-
key: "bundler cache mri"
|
47
|
-
- run: bundle update
|
48
|
-
- save_cache:
|
49
|
-
key: "bundler cache mri"
|
50
|
-
paths:
|
51
|
-
- "/usr/local/bundle"
|
52
|
-
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
53
|
-
- store_test_results:
|
54
|
-
path: rspec-results.xml
|
55
|
-
- sonarcloud/scan
|
56
|
-
"ruby-two-seven":
|
57
|
-
docker:
|
58
|
-
- image: circleci/ruby:2.7
|
59
|
-
steps:
|
60
|
-
- checkout
|
61
|
-
- restore_cache:
|
62
|
-
key: "bundler cache mri"
|
63
|
-
- run: bundle update
|
64
|
-
- save_cache:
|
65
|
-
key: "bundler cache mri"
|
66
|
-
paths:
|
67
|
-
- "/usr/local/bundle"
|
68
|
-
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
69
|
-
- store_test_results:
|
70
|
-
path: rspec-results.xml
|
71
|
-
- sonarcloud/scan
|
72
|
-
"ruby-three":
|
73
|
-
docker:
|
74
|
-
- image: circleci/ruby:3
|
75
|
-
steps:
|
76
|
-
- checkout
|
77
|
-
- restore_cache:
|
78
|
-
key: "bundler cache mri"
|
79
|
-
- run: bundle update
|
80
|
-
- save_cache:
|
81
|
-
key: "bundler cache mri"
|
82
|
-
paths:
|
83
|
-
- "/usr/local/bundle"
|
84
|
-
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
|
85
|
-
- store_test_results:
|
86
|
-
path: rspec-results.xml
|
87
|
-
- sonarcloud/scan
|
88
|
-
|
89
|
-
workflows:
|
90
|
-
version: 2
|
91
|
-
rubocop-rspec:
|
92
|
-
jobs:
|
93
|
-
- rubocop
|
94
|
-
- ruby-two-five:
|
95
|
-
requires:
|
96
|
-
- rubocop
|
97
|
-
- ruby-two-six:
|
98
|
-
requires:
|
99
|
-
- ruby-two-five
|
100
|
-
- ruby-two-seven:
|
101
|
-
requires:
|
102
|
-
- ruby-two-five
|
103
|
-
- ruby-three:
|
104
|
-
requires:
|
105
|
-
- ruby-two-five
|
data/Gemfile.lock
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
legion-settings (1.1.3)
|
5
|
-
legion-json
|
6
|
-
legion-logging
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
ast (2.4.1)
|
12
|
-
diff-lcs (1.4.4)
|
13
|
-
docile (1.3.4)
|
14
|
-
json (2.5.1)
|
15
|
-
json_pure (2.5.1)
|
16
|
-
legion-exceptions (1.1.5)
|
17
|
-
legion-json (1.1.4)
|
18
|
-
json_pure
|
19
|
-
legion-exceptions (>= 1.1.5)
|
20
|
-
multi_json
|
21
|
-
legion-logging (1.1.3)
|
22
|
-
rainbow (~> 3)
|
23
|
-
multi_json (1.15.0)
|
24
|
-
parallel (1.20.1)
|
25
|
-
parser (3.0.0.0)
|
26
|
-
ast (~> 2.4.1)
|
27
|
-
rainbow (3.0.0)
|
28
|
-
rake (13.0.3)
|
29
|
-
regexp_parser (2.0.3)
|
30
|
-
rexml (3.2.4)
|
31
|
-
rspec (3.10.0)
|
32
|
-
rspec-core (~> 3.10.0)
|
33
|
-
rspec-expectations (~> 3.10.0)
|
34
|
-
rspec-mocks (~> 3.10.0)
|
35
|
-
rspec-core (3.10.1)
|
36
|
-
rspec-support (~> 3.10.0)
|
37
|
-
rspec-expectations (3.10.1)
|
38
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.10.0)
|
40
|
-
rspec-mocks (3.10.1)
|
41
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.10.0)
|
43
|
-
rspec-support (3.10.1)
|
44
|
-
rspec_junit_formatter (0.4.1)
|
45
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
46
|
-
rubocop (1.8.0)
|
47
|
-
parallel (~> 1.10)
|
48
|
-
parser (>= 3.0.0.0)
|
49
|
-
rainbow (>= 2.2.2, < 4.0)
|
50
|
-
regexp_parser (>= 1.8, < 3.0)
|
51
|
-
rexml
|
52
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
53
|
-
ruby-progressbar (~> 1.7)
|
54
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
-
rubocop-ast (1.4.0)
|
56
|
-
parser (>= 2.7.1.5)
|
57
|
-
ruby-progressbar (1.11.0)
|
58
|
-
simplecov (0.17.1)
|
59
|
-
docile (~> 1.1)
|
60
|
-
json (>= 1.8, < 3)
|
61
|
-
simplecov-html (~> 0.10.0)
|
62
|
-
simplecov-html (0.10.2)
|
63
|
-
unicode-display_width (2.0.0)
|
64
|
-
|
65
|
-
PLATFORMS
|
66
|
-
ruby
|
67
|
-
|
68
|
-
DEPENDENCIES
|
69
|
-
bundler
|
70
|
-
legion-settings!
|
71
|
-
rake
|
72
|
-
rspec
|
73
|
-
rspec_junit_formatter
|
74
|
-
rubocop
|
75
|
-
simplecov (< 0.18.0)
|
76
|
-
|
77
|
-
BUNDLED WITH
|
78
|
-
2.2.4
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2018 Esity
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/bitbucket-pipelines.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
image: ruby:2.7
|
2
|
-
|
3
|
-
pipelines:
|
4
|
-
tags:
|
5
|
-
"v*":
|
6
|
-
- step:
|
7
|
-
name: Push to RubyGems
|
8
|
-
deployment: RubyGems
|
9
|
-
script:
|
10
|
-
- gem install gem-release
|
11
|
-
- (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
|
12
|
-
- gem release
|
13
|
-
artifacts:
|
14
|
-
- pkg/**
|
15
|
-
definitions:
|
16
|
-
caches:
|
17
|
-
bundler: /usr/local/bundle
|
@@ -1,92 +0,0 @@
|
|
1
|
-
module Legion
|
2
|
-
module Settings
|
3
|
-
module Rules
|
4
|
-
def must_be_a_hash(value)
|
5
|
-
value.is_a?(Hash)
|
6
|
-
end
|
7
|
-
alias is_a_hash? must_be_a_hash
|
8
|
-
|
9
|
-
def must_be_a_hash_if_set(value)
|
10
|
-
value.nil? ? true : must_be_a_hash(value)
|
11
|
-
end
|
12
|
-
|
13
|
-
def must_be_an_array(value)
|
14
|
-
value.is_a?(Array)
|
15
|
-
end
|
16
|
-
alias is_an_array? must_be_an_array
|
17
|
-
|
18
|
-
def must_be_an_array_if_set(value)
|
19
|
-
value.nil? ? true : must_be_an_array(value)
|
20
|
-
end
|
21
|
-
|
22
|
-
def must_be_a_string(value)
|
23
|
-
value.is_a?(String)
|
24
|
-
end
|
25
|
-
alias is_a_string? must_be_a_string
|
26
|
-
|
27
|
-
def must_be_a_string_if_set(value)
|
28
|
-
value.nil? ? true : must_be_a_string(value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def must_be_an_integer(value)
|
32
|
-
value.is_a?(Integer)
|
33
|
-
end
|
34
|
-
alias is_an_integer? must_be_an_integer
|
35
|
-
|
36
|
-
def must_be_an_integer_if_set(value)
|
37
|
-
value.nil? ? true : must_be_an_integer(value)
|
38
|
-
end
|
39
|
-
|
40
|
-
def must_be_a_numeric(value)
|
41
|
-
value.is_a?(Numeric)
|
42
|
-
end
|
43
|
-
|
44
|
-
def must_be_a_numeric_if_set(value)
|
45
|
-
value.nil? ? true : must_be_a_numeric(value)
|
46
|
-
end
|
47
|
-
|
48
|
-
def must_match_regex(regex, value)
|
49
|
-
(value =~ regex).zero?
|
50
|
-
end
|
51
|
-
|
52
|
-
def must_be_boolean(value)
|
53
|
-
!value.nil?
|
54
|
-
end
|
55
|
-
|
56
|
-
def must_be_boolean_if_set(value)
|
57
|
-
value.nil? ? true : must_be_boolean(value)
|
58
|
-
end
|
59
|
-
|
60
|
-
def items_must_be_strings(value, regex = nil)
|
61
|
-
value.all? do |item|
|
62
|
-
item.is_a?(String) && !item.empty? &&
|
63
|
-
(regex.nil? || item =~ regex)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def either_are_set?(*values)
|
68
|
-
values.any? do |value|
|
69
|
-
!value.nil?
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def must_be_time(*values)
|
74
|
-
values.all? do |value|
|
75
|
-
Time.parse(value)
|
76
|
-
rescue StandardError
|
77
|
-
false
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def must_be_either(allowed, *values)
|
82
|
-
values.flatten.all? do |value|
|
83
|
-
allowed.include?(value)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def must_be_either_if_set(allowed, *values)
|
88
|
-
values[0].nil? ? true : must_be_either(allowed, values)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'legion/settings/rules'
|
2
|
-
require 'legion/settings/validators'
|
3
|
-
require 'legion/settings/constants'
|
4
|
-
|
5
|
-
module Legion
|
6
|
-
module Settings
|
7
|
-
class Validator
|
8
|
-
include Rules
|
9
|
-
include Validators
|
10
|
-
|
11
|
-
attr_reader :failures
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@failures = []
|
15
|
-
end
|
16
|
-
|
17
|
-
def run(settings, service = nil)
|
18
|
-
validate_legion(settings[:legion])
|
19
|
-
validate_transport(settings[:transport])
|
20
|
-
validate_categories(settings)
|
21
|
-
case service
|
22
|
-
when 'client'
|
23
|
-
validate_client(settings[:client])
|
24
|
-
when 'api'
|
25
|
-
validate_api(settings[:api])
|
26
|
-
when 'rspec'
|
27
|
-
validate_client(settings[:client])
|
28
|
-
validate_api(settings[:api])
|
29
|
-
end
|
30
|
-
@failures
|
31
|
-
end
|
32
|
-
|
33
|
-
def reset!
|
34
|
-
failure_count = @failures.size
|
35
|
-
@failures = []
|
36
|
-
failure_count
|
37
|
-
end
|
38
|
-
alias reset reset!
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def validate_categories(settings)
|
43
|
-
CATEGORIES.each do |category|
|
44
|
-
if is_a_hash?(settings[category])
|
45
|
-
validate_method = "validate_#{category.to_s.chop}".to_sym
|
46
|
-
settings[category].each do |name, details|
|
47
|
-
send(validate_method, details.merge(name: name.to_s))
|
48
|
-
end
|
49
|
-
else
|
50
|
-
invalid(settings[category], "#{category} must be a hash")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def invalid(object, message)
|
56
|
-
@failures << {
|
57
|
-
object: object,
|
58
|
-
message: message
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|