legion-settings 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/NOTICE.txt ADDED
@@ -0,0 +1,9 @@
1
+ Legion::Settings(legion-settings)
2
+ Copyright 2021 Optum
3
+
4
+ Project Description:
5
+ ====================
6
+ A gem written to handle LegionIO Settings in a consistent way across extensions
7
+
8
+ Author(s):
9
+ Esity
data/README.md CHANGED
@@ -1,49 +1,36 @@
1
- # Legion::Settings
1
+ Legion::Settings
2
+ =====
2
3
 
3
- Legion::Settings is part of the Legion Framework
4
+ Legion::Settings is a hash like class used to store LegionIO Settings.
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)|
6
+ Supported Ruby versions and implementations
7
+ ------------------------------------------------
11
8
 
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)
9
+ Legion::Json should work identically on:
15
10
 
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)
19
- ## Installation
11
+ * JRuby 9.2+
12
+ * Ruby 2.4+
20
13
 
21
- Add this line to your application's Gemfile:
22
14
 
23
- ```ruby
24
- gem 'legion-settings'
25
- ```
26
-
27
- And then execute:
28
-
29
- $ bundle
30
-
31
- Or install it yourself as:
15
+ Installation and Usage
16
+ ------------------------
32
17
 
33
- $ gem install legion-settings
18
+ You can verify your installation using this piece of code:
34
19
 
35
- ## Usage
36
-
37
- This library is utilized by Legion to load config files
38
-
39
- ## Gem
20
+ ```bash
21
+ gem install legion-json
22
+ ```
40
23
 
41
- This gem can be viewed and download from [RubyGems - Legion-Settings](https://rubygems.org/gems/legion-settings)
24
+ ```ruby
25
+ require 'legion-settings'
26
+ Legion::Settings.load(config_dir: './') # will automatically load json files it has access to inside this dir
42
27
 
43
- ## Contributing
28
+ Legion::Settings[:client][:hostname]
29
+ Legion::Settings[:client][:new_attribute] = 'foobar'
44
30
 
45
- Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/legion-io/legion-settings/issues This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
31
+ ```
46
32
 
47
- ## License
33
+ Authors
34
+ ----------
48
35
 
49
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+ * [Matthew Iverson](https://github.com/Esity) - current maintainer
data/SECURITY.md ADDED
@@ -0,0 +1,9 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+ | Version | Supported |
5
+ | ------- | ------------------ |
6
+ | 1.x.x | :white_check_mark: |
7
+
8
+ ## Reporting a Vulnerability
9
+ To be added
data/attribution.txt ADDED
@@ -0,0 +1 @@
1
+ Add attributions here.
@@ -1,30 +1,30 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'legion/settings/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/settings/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'legion-settings'
6
+ spec.name = 'legion-settings'
7
7
  spec.version = Legion::Settings::VERSION
8
8
  spec.authors = ['Esity']
9
- spec.email = ['matthewdiverson@gmail.com']
10
-
11
- spec.summary = 'Used to load the json settings files'
12
- spec.description = "Based on Sensu's implementation of settings"
13
- spec.homepage = 'https://bitbucket.org/whonodes/legion-settings'
14
- spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 2.5.0'
9
+ spec.email = %w[matthewdiverson@gmail.com ruby@optum.com]
16
10
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
11
+ spec.summary = 'Legion::Settings'
12
+ spec.description = 'A gem written to handle LegionIO Settings in a consistent way across extensions'
13
+ spec.homepage = 'https://github.com/Optum/legion-settings'
14
+ spec.license = 'Apache-2.0'
20
15
  spec.require_paths = ['lib']
16
+ spec.required_ruby_version = '>= 2.4'
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.test_files = spec.files.select { |p| p =~ %r{^test/.*_test.rb} }
19
+ spec.extra_rdoc_files = %w[README.md LICENSE CHANGELOG.md]
20
+ spec.metadata = {
21
+ 'bug_tracker_uri' => 'https://github.com/Optum/legion-settings/issues',
22
+ 'changelog_uri' => 'https://github.com/Optum/legion-settings/src/main/CHANGELOG.md',
23
+ 'documentation_uri' => 'https://github.com/Optum/legion-settings',
24
+ 'homepage_uri' => 'https://github.com/Optum/LegionIO',
25
+ 'source_code_uri' => 'https://github.com/Optum/legion-settings',
26
+ 'wiki_uri' => 'https://github.com/Optum/legion-settings/wiki'
27
+ }
21
28
 
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', '< 0.18.0'
28
- spec.add_dependency 'legion-json'
29
- spec.add_dependency 'legion-logging'
29
+ spec.add_dependency 'legion-json', '>= 1.2'
30
30
  end
@@ -24,11 +24,11 @@ module Legion
24
24
  end
25
25
 
26
26
  def [](key)
27
- Legion::Logging.info('Legion::Settings was not loading, auto loading now!') if @loader.nil?
27
+ logger.info('Legion::Settings was not loading, auto loading now!') if @loader.nil?
28
28
  @loader = load if @loader.nil?
29
29
  @loader[key]
30
30
  rescue NoMethodError, TypeError
31
- Legion::Logging.fatal 'rescue inside [](key)'
31
+ logger.fatal 'rescue inside [](key)'
32
32
  nil
33
33
  end
34
34
 
@@ -43,6 +43,15 @@ module Legion
43
43
  thing[key.to_sym] = hash
44
44
  @loader.load_module_settings(thing)
45
45
  end
46
+
47
+ def logger
48
+ @logger = if ::Legion.const_defined?('Logging')
49
+ ::Legion::Logging
50
+ else
51
+ require 'logger'
52
+ ::Logger.new($stdout)
53
+ end
54
+ end
46
55
  end
47
56
  end
48
57
  end
@@ -1,8 +1,11 @@
1
1
  require 'socket'
2
+ require 'legion/settings/os'
2
3
 
3
4
  module Legion
4
5
  module Settings
5
6
  class Loader
7
+ include Legion::Settings::OS
8
+
6
9
  class Error < RuntimeError; end
7
10
  attr_reader :warnings, :errors, :loaded_files, :settings
8
11
 
@@ -0,0 +1,34 @@
1
+ module Legion
2
+ module Settings
3
+ module OS
4
+ def self.windows?
5
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
6
+ end
7
+
8
+ def self.mac?
9
+ (/darwin/ =~ RUBY_PLATFORM) != nil
10
+ end
11
+
12
+ def self.unix?
13
+ !OS.windows?
14
+ end
15
+
16
+ def self.linux?
17
+ OS.unix? and !OS.mac?
18
+ end
19
+
20
+ def self.jruby?
21
+ RUBY_ENGINE == 'jruby'
22
+ end
23
+
24
+ def os
25
+ return 'jruby' if jruby?
26
+ return 'windows' if windows?
27
+ return 'mac' if mac?
28
+ return 'unix' if unix?
29
+
30
+ 'linux'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Settings
3
- VERSION = '1.1.3'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
data/sourcehawk.yml ADDED
@@ -0,0 +1,4 @@
1
+
2
+ config-locations:
3
+ - https://raw.githubusercontent.com/optum/.github/main/sourcehawk.yml
4
+
metadata CHANGED
@@ -1,159 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
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: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
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: rspec_junit_formatter
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
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.18.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.18.0
97
13
  - !ruby/object:Gem::Dependency
98
14
  name: legion-json
99
15
  requirement: !ruby/object:Gem::Requirement
100
16
  requirements:
101
17
  - - ">="
102
18
  - !ruby/object:Gem::Version
103
- version: '0'
19
+ version: '1.2'
104
20
  type: :runtime
105
21
  prerelease: false
106
22
  version_requirements: !ruby/object:Gem::Requirement
107
23
  requirements:
108
24
  - - ">="
109
25
  - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: legion-logging
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- description: Based on Sensu's implementation of settings
26
+ version: '1.2'
27
+ description: A gem written to handle LegionIO Settings in a consistent way across
28
+ extensions
126
29
  email:
127
30
  - matthewdiverson@gmail.com
31
+ - ruby@optum.com
128
32
  executables: []
129
33
  extensions: []
130
- extra_rdoc_files: []
34
+ extra_rdoc_files:
35
+ - README.md
36
+ - LICENSE
37
+ - CHANGELOG.md
131
38
  files:
132
- - ".circleci/config.yml"
39
+ - ".github/workflows/sourcehawk-scan.yml"
133
40
  - ".gitignore"
134
41
  - ".rubocop.yml"
135
42
  - CHANGELOG.md
43
+ - CODE_OF_CONDUCT.md
44
+ - CONTRIBUTING.md
136
45
  - Gemfile
137
- - Gemfile.lock
138
- - LICENSE.txt
46
+ - INDIVIDUAL_CONTRIBUTOR_LICENSE.md
47
+ - LICENSE
48
+ - NOTICE.txt
139
49
  - README.md
140
- - Rakefile
141
- - bitbucket-pipelines.yml
50
+ - SECURITY.md
51
+ - attribution.txt
142
52
  - legion-settings.gemspec
143
53
  - lib/legion/settings.rb
144
- - lib/legion/settings/constants.rb
145
54
  - lib/legion/settings/loader.rb
146
- - lib/legion/settings/rules.rb
147
- - lib/legion/settings/validator.rb
148
- - lib/legion/settings/validators.rb
55
+ - lib/legion/settings/os.rb
149
56
  - lib/legion/settings/validators/legion.rb
150
57
  - lib/legion/settings/version.rb
151
58
  - sonar-project.properties
152
- homepage: https://bitbucket.org/whonodes/legion-settings
59
+ - sourcehawk.yml
60
+ homepage: https://github.com/Optum/legion-settings
153
61
  licenses:
154
- - MIT
155
- metadata: {}
156
- post_install_message:
62
+ - Apache-2.0
63
+ metadata:
64
+ bug_tracker_uri: https://github.com/Optum/legion-settings/issues
65
+ changelog_uri: https://github.com/Optum/legion-settings/src/main/CHANGELOG.md
66
+ documentation_uri: https://github.com/Optum/legion-settings
67
+ homepage_uri: https://github.com/Optum/LegionIO
68
+ source_code_uri: https://github.com/Optum/legion-settings
69
+ wiki_uri: https://github.com/Optum/legion-settings/wiki
70
+ post_install_message:
157
71
  rdoc_options: []
158
72
  require_paths:
159
73
  - lib
@@ -161,15 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
75
  requirements:
162
76
  - - ">="
163
77
  - !ruby/object:Gem::Version
164
- version: 2.5.0
78
+ version: '2.4'
165
79
  required_rubygems_version: !ruby/object:Gem::Requirement
166
80
  requirements:
167
81
  - - ">="
168
82
  - !ruby/object:Gem::Version
169
83
  version: '0'
170
84
  requirements: []
171
- rubygems_version: 3.1.4
172
- signing_key:
85
+ rubygems_version: 3.1.6
86
+ signing_key:
173
87
  specification_version: 4
174
- summary: Used to load the json settings files
88
+ summary: Legion::Settings
175
89
  test_files: []