nxt_config 0.2.0 → 0.2.1
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/CHANGELOG.md +28 -0
- data/Gemfile +7 -3
- data/Gemfile.lock +39 -19
- data/Guardfile +31 -0
- data/README.md +4 -2
- data/bin/guard +29 -0
- data/lib/nxt_config/struct.rb +5 -5
- data/lib/nxt_config/version.rb +1 -1
- data/lib/nxt_config.rb +0 -1
- data/nxt_config.gemspec +0 -2
- metadata +6 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d8967fb731cfbb8388f8f72b4111137b1a65f59e597982d43e86f9da0280d89
|
4
|
+
data.tar.gz: b111ac2f900a61e4361c0475fb9cc2d85a55e12a78764b5fef04baf948d06821
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc788737cce9c3addc730d6f6999b536b1d9cd2fe0d53a3c75f6ced49e3195fc622300486ee70c6942385c6b16971e08615858c8ab6c8abaa0312a7c410321a
|
7
|
+
data.tar.gz: 2e44b14680acb33d9bb9585dc563d8536ddf131842b66963e8e3a6fe6c4227a9c8a48a1206f68fd857ca6ca9a7d3864629e269bb7758939496a965144d8fdac8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# v0.2.1 2019-01-11
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
- [internal] Added [guard](https://github.com/guard/guard) to run specs automatically upon file changes.
|
6
|
+
|
7
|
+
### Changes
|
8
|
+
|
9
|
+
- [internal] Removed [activesupport](https://github.com/rails/rails/tree/master/activesupport) as a dependency.
|
10
|
+
|
11
|
+
[Compare v0.2.0...v0.2.1](https://github.com/nxt-insurance/nxt_config/compare/v0.2.0...v0.2.1)
|
12
|
+
|
13
|
+
# v0.2.0 2019-01-08
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- Added the `#fetch` method to `NxtConfig::Struct`.
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
|
21
|
+
- Removed the `#[]` method from `NxtConfig::Struct` (BREAKING).
|
22
|
+
- Replaced `NxtConfig::load_and_constantize` with `NxtConfig::load` and changed the way configs are assigned to constants.
|
23
|
+
|
24
|
+
[Compare v0.1.0...v0.2.0](https://github.com/nxt-insurance/nxt_config/compare/v0.1.0...v0.2.0)
|
25
|
+
|
26
|
+
# v0.1.0 2019-01-04
|
27
|
+
|
28
|
+
Initial release.
|
data/Gemfile
CHANGED
@@ -3,9 +3,13 @@ source "https://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in nxt_config.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "rake"
|
7
|
-
gem "rspec"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec"
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem "guard-rspec", require: false
|
11
|
+
end
|
8
12
|
|
9
13
|
group :test do
|
10
|
-
gem
|
14
|
+
gem "rspec_junit_formatter" # for CircleCI
|
11
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,45 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nxt_config (0.2.
|
5
|
-
activesupport
|
4
|
+
nxt_config (0.2.1)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
9
8
|
specs:
|
10
|
-
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 0.7, < 2)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
zeitwerk (~> 2.2)
|
16
|
-
concurrent-ruby (1.1.5)
|
9
|
+
coderay (1.1.2)
|
17
10
|
diff-lcs (1.3)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
ffi (1.11.3)
|
12
|
+
formatador (0.2.5)
|
13
|
+
guard (2.16.1)
|
14
|
+
formatador (>= 0.2.4)
|
15
|
+
listen (>= 2.7, < 4.0)
|
16
|
+
lumberjack (>= 1.0.12, < 2.0)
|
17
|
+
nenv (~> 0.1)
|
18
|
+
notiffany (~> 0.0)
|
19
|
+
pry (>= 0.9.12)
|
20
|
+
shellany (~> 0.0)
|
21
|
+
thor (>= 0.18.1)
|
22
|
+
guard-compat (1.2.1)
|
23
|
+
guard-rspec (4.7.3)
|
24
|
+
guard (~> 2.1)
|
25
|
+
guard-compat (~> 1.1)
|
26
|
+
rspec (>= 2.99.0, < 4.0)
|
27
|
+
listen (3.2.1)
|
28
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
29
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
30
|
+
lumberjack (1.1.1)
|
31
|
+
method_source (0.9.2)
|
32
|
+
nenv (0.3.0)
|
33
|
+
notiffany (0.1.3)
|
34
|
+
nenv (~> 0.1)
|
35
|
+
shellany (~> 0.0)
|
36
|
+
pry (0.12.2)
|
37
|
+
coderay (~> 1.1.0)
|
38
|
+
method_source (~> 0.9.0)
|
39
|
+
rake (13.0.1)
|
40
|
+
rb-fsevent (0.10.3)
|
41
|
+
rb-inotify (0.10.1)
|
42
|
+
ffi (~> 1.0)
|
22
43
|
rspec (3.9.0)
|
23
44
|
rspec-core (~> 3.9.0)
|
24
45
|
rspec-expectations (~> 3.9.0)
|
@@ -34,18 +55,17 @@ GEM
|
|
34
55
|
rspec-support (3.9.2)
|
35
56
|
rspec_junit_formatter (0.4.1)
|
36
57
|
rspec-core (>= 2, < 4, != 2.12.0)
|
37
|
-
|
38
|
-
|
39
|
-
thread_safe (~> 0.1)
|
40
|
-
zeitwerk (2.2.2)
|
58
|
+
shellany (0.0.1)
|
59
|
+
thor (1.0.1)
|
41
60
|
|
42
61
|
PLATFORMS
|
43
62
|
ruby
|
44
63
|
|
45
64
|
DEPENDENCIES
|
65
|
+
guard-rspec
|
46
66
|
nxt_config!
|
47
|
-
rake
|
48
|
-
rspec
|
67
|
+
rake
|
68
|
+
rspec
|
49
69
|
rspec_junit_formatter
|
50
70
|
|
51
71
|
BUNDLED WITH
|
data/Guardfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
watch(%r{^spec/.+_spec\.rb$})
|
29
|
+
watch(%r{^lib/nxt_pipeline/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
30
|
+
watch("spec/spec_helper.rb") { "spec" }
|
31
|
+
end
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ This is a very simple tool to load YAML files into strict configuration structs,
|
|
7
7
|
* Load the content of a YAML file as a configuration object
|
8
8
|
* Strict attribute accessors
|
9
9
|
* Infinite amount of YAML files/configuration objects loadable (not just one)
|
10
|
-
* Configuration objects can be registered in a given namespace (especially useful when in use in ruby gems loaded by other applications)
|
10
|
+
* Configuration objects can be registered in a given namespace (especially useful when in use in ruby gems loaded by other applications) by calling `NxtConfig::load` in the namespace where the constant lives that its config struct is assigned to.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -66,10 +66,12 @@ MyRailsApp::ExternalApiConfig.http
|
|
66
66
|
|
67
67
|
## Development
|
68
68
|
|
69
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
69
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
70
|
|
71
71
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
72
|
|
73
|
+
Run `bin/guard` for [guard](https://github.com/guard/guard) to start watching for file changes and running the corresponding specs accordingly.
|
74
|
+
|
73
75
|
## Contributing
|
74
76
|
|
75
77
|
Bug reports and pull requests are welcome on GitHub at https://github.com/nxt-insurance/nxt_config.
|
data/bin/guard
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'guard' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("guard", "guard")
|
data/lib/nxt_config/struct.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module NxtConfig
|
2
2
|
class Struct
|
3
3
|
def initialize(hash)
|
4
|
-
@hash = hash.
|
4
|
+
@hash = hash.transform_keys(&:to_sym)
|
5
5
|
define_key_accessor_methods
|
6
6
|
hash.freeze
|
7
7
|
end
|
@@ -10,9 +10,9 @@ module NxtConfig
|
|
10
10
|
if keys.length == 0
|
11
11
|
raise ArgumentError, "Provide at least one key"
|
12
12
|
elsif keys.length == 1
|
13
|
-
hash.fetch(keys.first, &block)
|
13
|
+
hash.fetch(keys.first.to_sym, &block)
|
14
14
|
else
|
15
|
-
hash.fetch(keys.first, &block).fetch(*keys[1..-1], &block)
|
15
|
+
hash.fetch(keys.first.to_sym, &block).fetch(*keys[1..-1], &block)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -27,8 +27,8 @@ module NxtConfig
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def transform_hash_value(value)
|
30
|
-
if value.is_a?(
|
31
|
-
Struct.new(value)
|
30
|
+
if value.is_a?(Hash)
|
31
|
+
Struct.new(value.transform_keys(&:to_sym))
|
32
32
|
elsif value.is_a?(Array)
|
33
33
|
value.map { |item| transform_hash_value(item) }
|
34
34
|
else
|
data/lib/nxt_config/version.rb
CHANGED
data/lib/nxt_config.rb
CHANGED
data/nxt_config.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nxt_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nils Sommer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Create namespaced, immutable objects serving configuration properties
|
28
14
|
to your ruby application.
|
29
15
|
email:
|
@@ -37,12 +23,15 @@ files:
|
|
37
23
|
- ".gitignore"
|
38
24
|
- ".rspec"
|
39
25
|
- ".ruby-version"
|
26
|
+
- CHANGELOG.md
|
40
27
|
- Gemfile
|
41
28
|
- Gemfile.lock
|
29
|
+
- Guardfile
|
42
30
|
- LICENSE.txt
|
43
31
|
- README.md
|
44
32
|
- Rakefile
|
45
33
|
- bin/console
|
34
|
+
- bin/guard
|
46
35
|
- bin/rspec
|
47
36
|
- bin/setup
|
48
37
|
- lib/nxt_config.rb
|