legion-settings 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/sourcehawk-scan.yml +20 -0
- data/.gitignore +4 -4
- data/.rubocop.yml +5 -10
- 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 -42
- data/SECURITY.md +9 -0
- data/attribution.txt +1 -0
- data/legion-settings.gemspec +22 -27
- data/lib/legion/settings.rb +13 -3
- data/lib/legion/settings/loader.rb +28 -36
- data/lib/legion/settings/os.rb +34 -0
- data/lib/legion/settings/version.rb +1 -1
- data/sonar-project.properties +12 -0
- data/sourcehawk.yml +4 -0
- metadata +38 -130
- data/.circleci/config.yml +0 -61
- data/.idea/.rakeTasks +0 -7
- data/.idea/legion-settings.iml +0 -39
- data/.idea/misc.xml +0 -7
- data/.idea/modules.xml +0 -8
- data/.idea/vagrant.xml +0 -7
- data/.idea/workspace.xml +0 -14
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/bitbucket-pipelines.yml +0 -39
- 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,61 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
orbs:
|
3
|
-
ruby: circleci/ruby@0.2.1
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
"rubocop":
|
7
|
-
docker:
|
8
|
-
- image: circleci/ruby:2.5-node
|
9
|
-
steps:
|
10
|
-
- checkout
|
11
|
-
- ruby/load-cache
|
12
|
-
- ruby/install-deps
|
13
|
-
- run:
|
14
|
-
name: Run Rubocop
|
15
|
-
command: bundle exec rubocop
|
16
|
-
- ruby/save-cache
|
17
|
-
"ruby-two-five":
|
18
|
-
docker:
|
19
|
-
- image: circleci/ruby:2.5
|
20
|
-
- image: memcached:1.5-alpine
|
21
|
-
steps:
|
22
|
-
- checkout
|
23
|
-
- ruby/load-cache
|
24
|
-
- ruby/install-deps
|
25
|
-
- ruby/run-tests
|
26
|
-
- ruby/save-cache
|
27
|
-
"ruby-two-six":
|
28
|
-
docker:
|
29
|
-
- image: circleci/ruby:2.6
|
30
|
-
- image: memcached:1.5-alpine
|
31
|
-
steps:
|
32
|
-
- checkout
|
33
|
-
- ruby/load-cache
|
34
|
-
- ruby/install-deps
|
35
|
-
- ruby/run-tests
|
36
|
-
- ruby/save-cache
|
37
|
-
"ruby-two-seven":
|
38
|
-
docker:
|
39
|
-
- image: circleci/ruby:2.7
|
40
|
-
- image: memcached:1.5-alpine
|
41
|
-
steps:
|
42
|
-
- checkout
|
43
|
-
- ruby/load-cache
|
44
|
-
- ruby/install-deps
|
45
|
-
- ruby/run-tests
|
46
|
-
- ruby/save-cache
|
47
|
-
|
48
|
-
workflows:
|
49
|
-
version: 2
|
50
|
-
rubocop-rspec:
|
51
|
-
jobs:
|
52
|
-
- rubocop
|
53
|
-
- ruby-two-five:
|
54
|
-
requires:
|
55
|
-
- rubocop
|
56
|
-
- ruby-two-six:
|
57
|
-
requires:
|
58
|
-
- ruby-two-five
|
59
|
-
- ruby-two-seven:
|
60
|
-
requires:
|
61
|
-
- ruby-two-five
|
data/.idea/.rakeTasks
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
-
You are allowed to:
|
4
|
-
1. Remove rake task
|
5
|
-
2. Add existing rake tasks
|
6
|
-
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
-
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build legion-settings-0.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install legion-settings-0.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install legion-settings-0.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.2.0 and build and push legion-settings-0.2.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.idea/legion-settings.iml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$">
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
9
|
-
</content>
|
10
|
-
<orderEntry type="inheritedJdk" />
|
11
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
13
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.5.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="legion-json (v0.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="legion-logging (v0.3.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="logger (v1.4.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="oj (v3.10.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v2.7.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec_junit_formatter (v0.4.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.80.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
36
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.6.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
38
|
-
</component>
|
39
|
-
</module>
|
data/.idea/misc.xml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="JavaScriptSettings">
|
4
|
-
<option name="languageLevel" value="ES6" />
|
5
|
-
</component>
|
6
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
|
7
|
-
</project>
|
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/legion-settings.iml" filepath="$PROJECT_DIR$/.idea/legion-settings.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/vagrant.xml
DELETED
data/.idea/workspace.xml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="CoverageOptionsProvider">
|
4
|
-
<option name="myAddOrReplace" value="0" />
|
5
|
-
</component>
|
6
|
-
<component name="Git.Settings">
|
7
|
-
<option name="PUSH_AUTO_UPDATE" value="true" />
|
8
|
-
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
9
|
-
</component>
|
10
|
-
<component name="ProjectId" id="1Yl3Ocrmi4zW8q4pNn0hTFZMozm" />
|
11
|
-
<component name="PropertiesComponent">
|
12
|
-
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
|
13
|
-
</component>
|
14
|
-
</project>
|
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/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'legion/settings'
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require 'irb'
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/bitbucket-pipelines.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
image: ruby:2.4.0
|
2
|
-
|
3
|
-
pipelines:
|
4
|
-
branches:
|
5
|
-
master:
|
6
|
-
- step:
|
7
|
-
caches:
|
8
|
-
- bundler
|
9
|
-
script:
|
10
|
-
- gem install bundle rubocop
|
11
|
-
- bundle install
|
12
|
-
- rubocop
|
13
|
-
- rake
|
14
|
-
- step:
|
15
|
-
name: Deploy to test gem server
|
16
|
-
deployment: test
|
17
|
-
script:
|
18
|
-
- gem install bundle geminabox
|
19
|
-
- bundle install
|
20
|
-
- gem build legion-settings.gemspec
|
21
|
-
- gem inabox legion-settings*.gem -g https://gems.whonodes.org/ -o
|
22
|
-
- step:
|
23
|
-
name: Deploy to RubyGems
|
24
|
-
deployment: production
|
25
|
-
trigger: manual
|
26
|
-
script:
|
27
|
-
- gem build legion-settings.gemspec
|
28
|
-
default:
|
29
|
-
- step:
|
30
|
-
caches:
|
31
|
-
- bundler
|
32
|
-
script:
|
33
|
-
- gem install bundle rubocop
|
34
|
-
- bundle install
|
35
|
-
- rubocop
|
36
|
-
- rake
|
37
|
-
definitions:
|
38
|
-
caches:
|
39
|
-
bundler: vendor/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
|