legion-settings 0.1.0 → 1.1.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
- SHA1:
3
- metadata.gz: '09fab9f1b8877a7e4edd48838b81985de665106e'
4
- data.tar.gz: 5f7fd30a767e066a87987ad0fdd04a3b605b1f87
2
+ SHA256:
3
+ metadata.gz: c41823e19d32b23ed8ae0b32bf15075246e3e9ee302619a975005226d59b3847
4
+ data.tar.gz: bfd78c7bd67539fef37a48adaf0648362555b4fc27ce267c46f61055b3e0a62f
5
5
  SHA512:
6
- metadata.gz: 1ccfdc0cee0c2983d381dca59260089b42141e600d97afaeaeaca94d093df0b35d88875526a5ed7528ec4416b29ae15ce753275e2574628f63b4c338ab285574
7
- data.tar.gz: 45ed2014eb19bae521caad7cfd4cbe5baab5620d6adfb3138cc70a582f96e246ff9d1b872f67cb729d8b28cbc9f7cd7cbcc049e8c94c774fb5ca0c57043e57d1
6
+ metadata.gz: a39b162d3e71bf83a707b4195f0b144b63196dfcc2b5bdee87159021fa6f5010376f9f3bac556492e0b57df7bb2643b902c810fb0cb4ec1eee0247ea7e7ef745
7
+ data.tar.gz: e825405a4f794de6a4e26395190b944770e9d51db827b890632f8fea0f4c6c26b4fb9252b8f33272d13769dc782efef0b324922b3b6ebaf7144fe820876c81e6
@@ -1,167 +1,83 @@
1
- version: 2 # use CircleCI 2.0
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.2.1
4
+ sonarcloud: sonarsource/sonarcloud@1.0.1
5
+
2
6
  jobs:
3
7
  "rubocop":
4
8
  docker:
5
- - image: circleci/ruby:2.4-node
9
+ - image: circleci/ruby:2.7-node
6
10
  steps:
7
11
  - checkout
8
- - run: gem install rubocop
12
+ - ruby/load-cache
13
+ - ruby/install-deps
9
14
  - run:
10
15
  name: Run Rubocop
11
- command: rubocop
12
- - store_test_results:
13
- path: test_results
14
- "ruby-2.0":
16
+ command: bundle exec rubocop
17
+ - ruby/save-cache
18
+ "ruby-two-five":
15
19
  docker:
16
- - image: circleci/ruby:2.0
20
+ - image: circleci/ruby:2.5
17
21
  steps:
18
22
  - checkout
19
- - run:
20
- name: Bundle Install
21
- command: bundle install
22
- - run:
23
- name: Run RSpec
24
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
25
- when: always
26
- - store_test_results:
27
- path: test-results
28
- "ruby-2.1":
23
+ - ruby/load-cache
24
+ - run:
25
+ name: update bundler
26
+ command: gem update bundler
27
+ - ruby/install-deps
28
+ - ruby/run-tests
29
+ - ruby/save-cache
30
+ "ruby-two-six":
29
31
  docker:
30
- - image: circleci/ruby:2.1
32
+ - image: circleci/ruby:2.6
31
33
  steps:
32
34
  - checkout
33
- - run:
34
- name: Bundle Install
35
- command: bundle install
36
- - run:
37
- name: Run RSpec
38
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
39
- when: always
40
- - store_test_results:
41
- path: test-results
42
- "ruby-2.2":
35
+ - ruby/load-cache
36
+ - run:
37
+ name: update bundler
38
+ command: gem update bundler
39
+ - ruby/install-deps
40
+ - ruby/run-tests
41
+ - ruby/save-cache
42
+ "ruby-two-seven":
43
43
  docker:
44
- - image: circleci/ruby:2.2
44
+ - image: circleci/ruby:2.7
45
+ - image: memcached:1.5-alpine
45
46
  steps:
46
47
  - checkout
47
- - run:
48
- name: Bundle Install
49
- command: bundle install
50
- - run:
51
- name: Run RSpec
52
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
53
- when: always
54
- - store_test_results:
55
- path: test-results
56
-
57
- "ruby-2.3":
48
+ - ruby/load-cache
49
+ - ruby/install-deps
50
+ - ruby/run-tests
51
+ - ruby/save-cache
52
+ "sonarcloud":
58
53
  docker:
59
- - image: circleci/ruby:2.3
54
+ - image: circleci/ruby:2.7
60
55
  steps:
61
56
  - checkout
57
+ - ruby/load-cache
58
+ - ruby/install-deps
59
+ - ruby/run-tests
62
60
  - run:
63
- name: Bundle Install
64
- command: bundle install
65
- - run:
66
- name: Run RSpec
67
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
68
- when: always
69
- - store_test_results:
70
- path: test-results
71
-
72
- "ruby-2.4":
73
- docker:
74
- - image: circleci/ruby:2.4-node
75
- steps:
76
- - checkout
77
- - run:
78
- name: Bundle Install
79
- command: bundle install
80
- - run:
81
- name: Run RSpec
82
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
83
- when: always
84
- - store_test_results:
85
- path: test-results
86
- "ruby-2.5":
87
- docker:
88
- - image: circleci/ruby:2.5-node
89
- steps:
90
- - checkout
91
- - run:
92
- name: Bundle Install
93
- command: bundle install
94
- - run:
95
- name: Run RSpec
96
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
97
- when: always
98
- - store_test_results:
99
- path: test-results
100
- "ruby-2.6":
101
- docker:
102
- - image: circleci/ruby:2.6-node
103
- steps:
104
- - checkout
105
- - run:
106
- name: Bundle Install
107
- command: bundle install
108
- - run:
109
- name: Run RSpec
110
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
111
- when: always
112
- - store_test_results:
113
- path: test-results
114
- "jruby-9.2":
115
- docker:
116
- - image: circleci/jruby:9.2
117
- steps:
118
- - checkout
119
- - run:
120
- name: Bundle Install
121
- command: bundle install
122
- - run:
123
- name: Run RSpec
124
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
125
- when: always
126
- - store_test_results:
127
- path: test-results
61
+ name: Run Rubocop
62
+ command: bundle exec rubocop --format=json --out=rubocop-result.json
63
+ - sonarcloud/scan
64
+ - ruby/save-cache
128
65
 
129
66
  workflows:
130
67
  version: 2
131
- cop_rake_deploy:
68
+ rubocop-rspec:
132
69
  jobs:
133
70
  - rubocop
134
- # - ruby-2.2:
135
- # requires:
136
- # - ruby-2.4
137
- # filters:
138
- # branches:
139
- # only: /\bdevelop\b|\bmaster\b/
140
- - ruby-2.3:
141
- requires:
142
- - ruby-2.4
143
- filters:
144
- branches:
145
- only: /\bdevelop\b|\bmaster\b/
146
- - ruby-2.4:
71
+ - ruby-two-five:
147
72
  requires:
148
73
  - rubocop
149
- - ruby-2.5:
74
+ - ruby-two-six:
75
+ requires:
76
+ - ruby-two-five
77
+ - ruby-two-seven:
150
78
  requires:
151
- - ruby-2.4
152
- filters:
153
- branches:
154
- only: /\bdevelop\b|\bmaster\b/
155
- - ruby-2.6:
79
+ - ruby-two-five
80
+ - sonarcloud:
156
81
  requires:
157
- - ruby-2.4
158
- filters:
159
- branches:
160
- only: /\bdevelop\b|\bmaster\b/
161
- # - jruby-9.2:
162
- # requires:
163
- # - ruby-2.2
164
- # - ruby-2.3
165
- # - ruby-2.4
166
- # - ruby-2.5
167
- # - ruby-2.6
82
+ - ruby-two-seven
83
+ - ruby-two-six
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -0,0 +1,7 @@
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>
@@ -0,0 +1,39 @@
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="jdk" jdkName="RVM: ruby-2.7.0" jdkType="RUBY_SDK" />
11
+ <orderEntry type="sourceFolder" forTests="false" />
12
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.1, RVM: ruby-2.7.0) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="chef (v16.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, RVM: ruby-2.7.0) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.7.0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="legion-json (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="legion-logging (v1.0.0, RVM: ruby-2.7.0) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.15.0, RVM: ruby-2.7.0) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.2, RVM: ruby-2.7.0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="parser (v2.7.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.7.0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.7.0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v1.7.1, RVM: ruby-2.7.0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.7.0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.7.0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.7.0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.3, RVM: ruby-2.7.0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="rspec_junit_formatter (v0.4.1, RVM: ruby-2.7.0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.88.0, RVM: ruby-2.7.0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v0.2.0, RVM: ruby-2.7.0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.7.0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.7.0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.7.0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.7.0, RVM: ruby-2.7.0) [gem]" level="application" />
38
+ </component>
39
+ </module>
@@ -0,0 +1,7 @@
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>
@@ -0,0 +1,8 @@
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>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VagrantProjectSettings">
4
+ <option name="instanceFolder" value="" />
5
+ <option name="provider" value="" />
6
+ </component>
7
+ </project>
@@ -0,0 +1,14 @@
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>
@@ -1,4 +1,4 @@
1
- Metrics/LineLength:
1
+ Layout/LineLength:
2
2
  Max: 120
3
3
  Metrics/MethodLength:
4
4
  Max: 30
@@ -10,15 +10,14 @@ Layout/SpaceAroundEqualsInParameterDefault:
10
10
  EnforcedStyle: space
11
11
  Style/SymbolArray:
12
12
  Enabled: true
13
- Layout/AlignHash:
13
+ Layout/HashAlignment:
14
14
  EnforcedHashRocketStyle: table
15
15
  EnforcedColonStyle: table
16
- Style/HashSyntax:
17
- EnforcedStyle: ruby19_no_mixed_keys
18
16
  Style/Documentation:
19
17
  Enabled: false
20
18
  AllCops:
21
- TargetRubyVersion: 2.4
19
+ TargetRubyVersion: 2.5
20
+ NewCops: enable
22
21
  Style/FrozenStringLiteralComment:
23
22
  Enabled: false
24
23
  Naming/FileName:
@@ -0,0 +1,9 @@
1
+ # Legion::Settings Changelog
2
+
3
+ ## v0.2.0
4
+ * Adding merge settings method
5
+ * Updating default settings
6
+
7
+ ## v0.1.1
8
+ * Updating default hash to include legion:{extensions:{}}
9
+ * Fixing rubocop errors
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in legion-settings.gemspec
4
3
  gemspec
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ legion-settings (1.1.0)
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.2)
14
+ legion-json (1.1.0)
15
+ multi_json
16
+ legion-logging (1.0.0)
17
+ rainbow (~> 3)
18
+ multi_json (1.15.0)
19
+ parallel (1.19.2)
20
+ parser (2.7.1.4)
21
+ ast (~> 2.4.1)
22
+ rainbow (3.0.0)
23
+ rake (13.0.1)
24
+ regexp_parser (1.7.1)
25
+ rexml (3.2.4)
26
+ rspec (3.9.0)
27
+ rspec-core (~> 3.9.0)
28
+ rspec-expectations (~> 3.9.0)
29
+ rspec-mocks (~> 3.9.0)
30
+ rspec-core (3.9.2)
31
+ rspec-support (~> 3.9.3)
32
+ rspec-expectations (3.9.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-mocks (3.9.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-support (3.9.3)
39
+ rspec_junit_formatter (0.4.1)
40
+ rspec-core (>= 2, < 4, != 2.12.0)
41
+ rubocop (0.88.0)
42
+ parallel (~> 1.10)
43
+ parser (>= 2.7.1.1)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.7)
46
+ rexml
47
+ rubocop-ast (>= 0.1.0, < 1.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 1.4.0, < 2.0)
50
+ rubocop-ast (0.2.0)
51
+ parser (>= 2.7.0.1)
52
+ ruby-progressbar (1.10.1)
53
+ simplecov (0.18.5)
54
+ docile (~> 1.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov-html (0.12.2)
57
+ unicode-display_width (1.7.0)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler
64
+ legion-settings!
65
+ rake
66
+ rspec
67
+ rspec_junit_formatter
68
+ rubocop
69
+ simplecov
70
+
71
+ BUNDLED WITH
72
+ 2.1.4
data/README.md CHANGED
@@ -2,7 +2,20 @@
2
2
 
3
3
  Legion::Settings is part of the Legion Framework
4
4
 
5
-
5
+ ###Badges
6
+ ####CICD
7
+ | | License | CircleCI | CodeCov | CodeBeat |
8
+ |---------|---------|----------|---------|----------|
9
+ | Master |[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)|[![CircleCI](https://circleci.com/bb/legion-io/legion-settings/tree/master.svg?style=svg)](https://circleci.com/bb/legion-io/legion-settings/tree/master)|[![codecov](https://codecov.io/bb/legion-io/legion-settings/branch/master/graph/badge.svg)](https://codecov.io/bb/legion-io/legion-settings)|[![codebeat badge](https://codebeat.co/badges/e86dbe3e-b463-4f3c-91a8-c85492fd3833)](https://codebeat.co/projects/bitbucket-org-legion-io-legion-settings-master)|
10
+ | Develop |[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)|[![CircleCI](https://circleci.com/bb/legion-io/legion-settings/tree/develop.svg?style=svg)](https://circleci.com/bb/legion-io/legion-settings/tree/develop)|[![codecov](https://codecov.io/bb/legion-io/legion-settings/branch/develop/graph/badge.svg)](https://codecov.io/bb/legion-io/legion-settings)|[![codebeat badge](https://codebeat.co/badges/e86dbe3e-b463-4f3c-91a8-c85492fd3833)](https://codebeat.co/projects/bitbucket-org-legion-io-legion-settings-develop)|
11
+
12
+ #####RubyGems
13
+ ![](https://ruby-gem-downloads-badge.herokuapp.com/legion-settings)
14
+ [![Gem Version](https://badge.fury.io/rb/legion-settings.svg)](https://badge.fury.io/rb/legion-settings)
15
+
16
+ #####Bitbucket
17
+ ![](https://img.shields.io/bitbucket/issues-raw/legion-io/legion-settings.svg)
18
+ ![](https://img.shields.io/bitbucket/pr-raw/legion-io/legion-settings.svg)
6
19
  ## Installation
7
20
 
8
21
  Add this line to your application's Gemfile:
@@ -16,19 +16,15 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = 'exe'
20
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
20
  spec.require_paths = ['lib']
22
21
 
23
- spec.add_development_dependency 'bundler', '~> 1'
24
- spec.add_development_dependency 'codecov', '~> 0'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
- spec.add_development_dependency 'rspec_junit_formatter', '~> 0'
28
- if RUBY_ENGINE == 'jruby'
29
- spec.add_dependency('legion-json-jruby', '~> 0.1')
30
- else
31
- spec.add_dependency('legion-json', '~> 0.1')
32
- end
33
- spec.add_dependency 'legion-logging', '~> 0.1'
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rspec_junit_formatter'
26
+ spec.add_development_dependency 'rubocop'
27
+ spec.add_development_dependency 'simplecov'
28
+ spec.add_dependency 'legion-json'
29
+ spec.add_dependency 'legion-logging'
34
30
  end
@@ -4,11 +4,10 @@ require 'legion/json/parse_error'
4
4
  require 'legion/settings/loader'
5
5
 
6
6
  module Legion
7
- # Base Legion::Settings module
8
7
  module Settings
9
- # Base settings, needs to be refactored
10
8
  class << self
11
9
  attr_accessor :loader
10
+
12
11
  def load(options = {})
13
12
  @loader = Legion::Settings::Loader.new
14
13
  @loader.load_env
@@ -25,16 +24,25 @@ module Legion
25
24
  end
26
25
 
27
26
  def [](key)
28
- Legion::Logging.warn('Legion::Settings was not loading, auto loading now!') if @loader.nil?
27
+ Legion::Logging.info('Legion::Settings was not loading, auto loading now!') if @loader.nil?
29
28
  @loader = load if @loader.nil?
30
29
  @loader[key]
30
+ rescue NoMethodError, TypeError
31
+ Legion::Logging.fatal 'rescue inside [](key)'
32
+ nil
31
33
  end
32
34
 
33
35
  def set_prop(key, value)
34
- Legion::Logging.warn('Legion::Settings was not loading, auto loading now!') if @loader.nil?
35
36
  @loader = load if @loader.nil?
36
37
  @loader[key] = value
37
38
  end
39
+
40
+ def merge_settings(key, hash)
41
+ @loader = load if @loader.nil?
42
+ thing = {}
43
+ thing[key.to_sym] = hash
44
+ @loader.load_module_default(thing)
45
+ end
38
46
  end
39
47
  end
40
48
  end
@@ -1,13 +1,10 @@
1
+ require 'socket'
2
+
1
3
  module Legion
2
4
  module Settings
3
- # This is the main settings class, needs refactor
4
5
  class Loader
5
- # This is the standard error
6
6
  class Error < RuntimeError; end
7
-
8
- attr_reader :warnings
9
- attr_reader :errors
10
- attr_reader :loaded_files
7
+ attr_reader :warnings, :errors, :loaded_files, :settings
11
8
 
12
9
  def initialize
13
10
  @warnings = []
@@ -20,39 +17,36 @@ module Legion
20
17
 
21
18
  def client_defaults
22
19
  {
23
- name: system_hostname,
24
- address: system_address
20
+ hostname: system_hostname,
21
+ address: system_address,
22
+ name: "#{::Socket.gethostname.gsub('.', '_')}.#{::Process.pid}",
23
+ ready: false
25
24
  }
26
25
  end
27
26
 
28
27
  def default_settings
29
- default = {
30
- client: {},
31
- legion: {
32
- spawn: {
33
- limit: 12
34
- }
28
+ {
29
+ client: client_defaults,
30
+ cluster: { public_keys: {} },
31
+ crypt: {
32
+ cluster_secret: nil,
33
+ cluster_secret_timeout: 5,
34
+ vault: { connected: false }
35
35
  },
36
- transport: {
37
- rabbitmq: {
38
- user: 'guest',
39
- password: 'guest',
40
- host: '127.0.0.1'
41
- }
36
+ cache: { enabled: true, connected: false, driver: 'dalli' },
37
+ extensions: {},
38
+ default_extension_settings: {
39
+ logger: { level: 'info', trace: false, extended: false }
42
40
  },
43
- data: {
44
- mysql: {
45
- user: 'legion',
46
- password: 'legion',
47
- max_connections: 20,
48
- database: 'legion',
49
- host: '127.0.0.1',
50
- debug: false
51
- }
52
- }
41
+ logging: {
42
+ level: 'info',
43
+ location: 'stdout',
44
+ trace: true,
45
+ backtrace_logging: true
46
+ },
47
+ transport: { connected: false },
48
+ data: { connected: false }
53
49
  }
54
- default[:client] = client_defaults if %w[client rspec].include?(legion_service_name)
55
- default
56
50
  end
57
51
 
58
52
  def self.create_category_methods
@@ -99,7 +93,13 @@ module Legion
99
93
  load_api_env
100
94
  end
101
95
 
102
- def load_file(file)
96
+ def load_module_default(config)
97
+ merged = deep_merge(@settings, config)
98
+ deep_diff(@settings, merged) unless @loaded_files.empty?
99
+ @settings = merged
100
+ end
101
+
102
+ def load_file(file) # rubocop:disable Metrics/AbcSize
103
103
  Legion::Logging.debug("Trying to load file #{file}")
104
104
  if File.file?(file) && File.readable?(file)
105
105
  begin
@@ -110,9 +110,9 @@ module Legion
110
110
  @settings = merged
111
111
  # @indifferent_access = false
112
112
  @loaded_files << file
113
- rescue Legion::JSON::ParseError => error
113
+ rescue Legion::JSON::ParseError => e
114
114
  Legion::Logging.error('config file must be valid json')
115
- Legion::Logging.debug("file:#{file}, error: #{error}")
115
+ Legion::Logging.debug("file:#{file}, error: #{e}")
116
116
  end
117
117
  else
118
118
  Legion::Logging.warn("Config file does not exist or is not readable file:#{file}")
@@ -120,7 +120,6 @@ module Legion
120
120
  end
121
121
 
122
122
  def load_directory(directory)
123
- warning('loading config files from directory', directory: directory)
124
123
  path = directory.gsub(/\\(?=\S)/, '/')
125
124
  if File.readable?(path) && File.executable?(path)
126
125
  Dir.glob(File.join(path, '**{,/*/**}/*.json')).uniq.each do |file|
@@ -1,120 +1,62 @@
1
1
  module Legion
2
2
  module Settings
3
3
  module Rules
4
- # Check that a value is a hash.
5
- #
6
- # @param value [Object] to check.
7
- # @return [TrueClass, FalseClass]
8
4
  def must_be_a_hash(value)
9
5
  value.is_a?(Hash)
10
6
  end
11
7
  alias is_a_hash? must_be_a_hash
12
8
 
13
- # Check that a value is a hash, if set (not nil).
14
- #
15
- # @param value [Object] to check.
16
- # @return [TrueClass, FalseClass]
17
9
  def must_be_a_hash_if_set(value)
18
10
  value.nil? ? true : must_be_a_hash(value)
19
11
  end
20
12
 
21
- # Check that a value is an array.
22
- #
23
- # @param value [Object] to check.
24
- # @return [TrueClass, FalseClass]
25
13
  def must_be_an_array(value)
26
14
  value.is_a?(Array)
27
15
  end
28
16
  alias is_an_array? must_be_an_array
29
17
 
30
- # Check that a value is an array, if set (not nil).
31
- #
32
- # @param value [Object] to check.
33
- # @return [TrueClass, FalseClass]
34
18
  def must_be_an_array_if_set(value)
35
19
  value.nil? ? true : must_be_an_array(value)
36
20
  end
37
21
 
38
- # Check that a value is a string.
39
- #
40
- # @param value [Object] to check.
41
- # @return [TrueClass, FalseClass]
42
22
  def must_be_a_string(value)
43
23
  value.is_a?(String)
44
24
  end
45
25
  alias is_a_string? must_be_a_string
46
26
 
47
- # Check that a value is a string, if set (not nil).
48
- #
49
- # @param value [Object] to check.
50
- # @return [TrueClass, FalseClass]
51
27
  def must_be_a_string_if_set(value)
52
28
  value.nil? ? true : must_be_a_string(value)
53
29
  end
54
30
 
55
- # Check that a value is an integer.
56
- #
57
- # @param value [Object] to check.
58
- # @return [TrueClass, FalseClass]
59
31
  def must_be_an_integer(value)
60
32
  value.is_a?(Integer)
61
33
  end
62
34
  alias is_an_integer? must_be_an_integer
63
35
 
64
- # Check that a value is an integer, if set (not nil).
65
- #
66
- # @param value [Object] to check.
67
- # @return [TrueClass, FalseClass]
68
36
  def must_be_an_integer_if_set(value)
69
37
  value.nil? ? true : must_be_an_integer(value)
70
38
  end
71
39
 
72
- # Check that a value is numeric.
73
- #
74
- # @param value [Object] to check.
75
- # @return [TrueClass, FalseClass]
76
40
  def must_be_a_numeric(value)
77
41
  value.is_a?(Numeric)
78
42
  end
79
43
 
80
- # Check that a value is numeric, if set (not nil).
81
- #
82
- # @param value [Object] to check.
83
- # @return [TrueClass, FalseClass]
84
44
  def must_be_a_numeric_if_set(value)
85
45
  value.nil? ? true : must_be_a_numeric(value)
86
46
  end
87
47
 
88
- # Check that a value matches a regular expression.
89
- #
90
- # @param regex [Regexp] pattern to compare with value.
91
- # @param value [Object] to check if matches pattern.
92
- # @return [TrueClass, FalseClass]
93
48
  def must_match_regex(regex, value)
94
49
  (value =~ regex).zero?
95
50
  end
96
51
 
97
- # Check if a value is boolean.
98
- #
99
- # @param value [Object] to check.
100
- # @return [TrueClass, FalseClass]
101
52
  def must_be_boolean(value)
102
53
  !value.nil?
103
54
  end
104
55
 
105
- # Check if a value is boolean, if set (no nil).
106
- #
107
- # @param value [Object] to check.
108
- # @return [TrueClass, FalseClass]
109
56
  def must_be_boolean_if_set(value)
110
57
  value.nil? ? true : must_be_boolean(value)
111
58
  end
112
59
 
113
- # Check that value items are all strings and not empty.
114
- #
115
- # @param value [Array] with items to check.
116
- # @param regex [Regexp] to validate string items with.
117
- # @return [TrueClass, FalseClass]
118
60
  def items_must_be_strings(value, regex = nil)
119
61
  value.all? do |item|
120
62
  item.is_a?(String) && !item.empty? &&
@@ -122,46 +64,26 @@ module Legion
122
64
  end
123
65
  end
124
66
 
125
- # Check if either of the values are set (not nil).
126
- #
127
- # @param values [Array<Object>] to check if not nil.
128
- # @return [TrueClass, FalseClass]
129
67
  def either_are_set?(*values)
130
68
  values.any? do |value|
131
69
  !value.nil?
132
70
  end
133
71
  end
134
72
 
135
- # Check if values are valid times (can be parsed).
136
- #
137
- # @param values [Array<Object>] to check if valid time.
138
- # @return [TrueClass, FalseClass]
139
73
  def must_be_time(*values)
140
74
  values.all? do |value|
141
- begin
142
- Time.parse(value)
143
- rescue StandardError
144
- false
145
- end
75
+ Time.parse(value)
76
+ rescue StandardError
77
+ false
146
78
  end
147
79
  end
148
80
 
149
- # Check if values are allowed.
150
- #
151
- # @param allowed [Array<Object>] allowed values.
152
- # @param values [Array<Object>] to check if allowed.
153
- # @return [TrueClass, FalseClass]
154
81
  def must_be_either(allowed, *values)
155
82
  values.flatten.all? do |value|
156
83
  allowed.include?(value)
157
84
  end
158
85
  end
159
86
 
160
- # Check if values are allowed, if set (not nil).
161
- #
162
- # @param allowed [Array<Object>] allowed values.
163
- # @param values [Array<Object>] to check if allowed.
164
- # @return [TrueClass, FalseClass]
165
87
  def must_be_either_if_set(allowed, *values)
166
88
  values[0].nil? ? true : must_be_either(allowed, values)
167
89
  end
@@ -8,19 +8,12 @@ module Legion
8
8
  include Rules
9
9
  include Validators
10
10
 
11
- # @!attribute [r] failures
12
- # @return [Array] validation failures.
13
11
  attr_reader :failures
14
12
 
15
13
  def initialize
16
14
  @failures = []
17
15
  end
18
16
 
19
- # Run the validator.
20
- #
21
- # @param settings [Hash] legion settings to validate.
22
- # @param service [String] legion service to validate for.
23
- # @return [Array] validation failures.
24
17
  def run(settings, service = nil)
25
18
  validate_legion(settings[:legion])
26
19
  validate_transport(settings[:transport])
@@ -46,10 +39,6 @@ module Legion
46
39
 
47
40
  private
48
41
 
49
- # Validate setting categories: checks, filters, mutators, and
50
- # handlers.
51
- #
52
- # @param settings [Hash] legion settings to validate.
53
42
  def validate_categories(settings)
54
43
  CATEGORIES.each do |category|
55
44
  if is_a_hash?(settings[category])
@@ -63,12 +52,6 @@ module Legion
63
52
  end
64
53
  end
65
54
 
66
- # Record an invalid object with a message.
67
- #
68
- # @param object [Object] invalid object.
69
- # @param message [String] message explaining why the object is
70
- # invalid.
71
- # @return [Array] current validation failures.
72
55
  def invalid(object, message)
73
56
  @failures << {
74
57
  object: object,
@@ -2,10 +2,6 @@ module Legion
2
2
  module Settings
3
3
  module Validators
4
4
  module Legion
5
- # Validate Legion spawn.
6
- # Validates: limit
7
- #
8
- # @param legion [Hash] legion definition.
9
5
  def validate_legion_spawn(legion)
10
6
  spawn = legion[:spawn]
11
7
  if is_a_hash?(spawn)
@@ -20,10 +16,6 @@ module Legion
20
16
  end
21
17
  end
22
18
 
23
- # Validate a Legion definition.
24
- # Validates: spawn
25
- #
26
- # @param legion [Hash] legion definition.
27
19
  def validate_legion(legion)
28
20
  if is_a_hash?(legion)
29
21
  validate_legion_spawn(legion)
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Settings
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ sonar.projectKey=legion-io_legion-settings
2
+ sonar.organization=legion-io
3
+ sonar.projectName=Legion::Settings
4
+ sonar.sources=.
5
+ sonar.exclusions=vendor/**
6
+ sonar.coverage.exclusions=spec/**
7
+ sonar.ruby.coverage.reportPath=coverage/.resultset.json
8
+ sonar.ruby.file.suffixes=rb,ruby
9
+ sonar.ruby.coverage.framework=RSpec
10
+ sonar.ruby.rubocopConfig=.rubocop.yml
11
+ sonar.ruby.rubocop.reportPath=rubocop-result.json
12
+ sonar.ruby.rubocop.filePath=.
metadata CHANGED
@@ -1,113 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-30 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: codecov
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: rspec_junit_formatter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec_junit_formatter
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
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
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: legion-json
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '0.1'
103
+ version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '0.1'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: legion-logging
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '0.1'
117
+ version: '0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0.1'
124
+ version: '0'
111
125
  description: Based on Sensu's implementation of settings
112
126
  email:
113
127
  - matthewdiverson@gmail.com
@@ -117,13 +131,19 @@ extra_rdoc_files: []
117
131
  files:
118
132
  - ".circleci/config.yml"
119
133
  - ".gitignore"
134
+ - ".idea/.rakeTasks"
135
+ - ".idea/legion-settings.iml"
136
+ - ".idea/misc.xml"
137
+ - ".idea/modules.xml"
138
+ - ".idea/vagrant.xml"
139
+ - ".idea/workspace.xml"
120
140
  - ".rubocop.yml"
141
+ - CHANGELOG.md
121
142
  - Gemfile
143
+ - Gemfile.lock
122
144
  - LICENSE.txt
123
145
  - README.md
124
146
  - Rakefile
125
- - bin/console
126
- - bin/setup
127
147
  - bitbucket-pipelines.yml
128
148
  - legion-settings.gemspec
129
149
  - lib/legion/settings.rb
@@ -134,11 +154,12 @@ files:
134
154
  - lib/legion/settings/validators.rb
135
155
  - lib/legion/settings/validators/legion.rb
136
156
  - lib/legion/settings/version.rb
157
+ - sonar-project.properties
137
158
  homepage: https://bitbucket.org/whonodes/legion-settings
138
159
  licenses:
139
160
  - MIT
140
161
  metadata: {}
141
- post_install_message:
162
+ post_install_message:
142
163
  rdoc_options: []
143
164
  require_paths:
144
165
  - lib
@@ -153,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
174
  - !ruby/object:Gem::Version
154
175
  version: '0'
155
176
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.6.14
158
- signing_key:
177
+ rubygems_version: 3.1.2
178
+ signing_key:
159
179
  specification_version: 4
160
180
  summary: Used to load the json settings files
161
181
  test_files: []
@@ -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
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here