nitro_config 0.1.0 → 0.1.1

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
2
  SHA256:
3
- metadata.gz: c7055701182010d5935ca398768db0f1d5dffeeda042bd7096278beaf6504da9
4
- data.tar.gz: 3bd0acd7ea41fcf58dfdca6811bb50a9ccf87df0619633908d5bd150a0aecb86
3
+ metadata.gz: d2106328cb7a570bf8f1be2906373b809cefde5e04f23f6a304f29c5a0326e72
4
+ data.tar.gz: a91b2f3fd1fb4094d0355d7f5f1143ee5e093f94766be229b1166771d7fe4579
5
5
  SHA512:
6
- metadata.gz: 7036c60be8e7b4ba9842220e5c8ff752d5d3d44a0256d20458f851aa77cd3cc1a9a76a546df0b0aa7536e1d55b92a6e92b641fd71db04471a19b4beaa473905c
7
- data.tar.gz: f14127304b5d4880b09cd467406b1941d63aa68662789b3e5efac5ad48aa38cc6e6500c47f4609b61e3311ce800d7a773c5e55504f62aed7b256ce7ac4febc53
6
+ metadata.gz: 5af554d4c85dd235f48be6fc2a4e35763bf86fd48903ab7419814fbbf7701cd0c55db8ea826bfdacff26731f2c63e7e55db2694e5c114519d19a4f171737d45f
7
+ data.tar.gz: ccb35797f5102f1888ba4ef6f9a78bb3241e00f8d293584cb838a04572438f713b2ea53497986baf801eb9717404e77c902d44f4695da0259347fe015f9f276e
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ require:
2
+ - rubocop-powerhome
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+
7
+ Rails:
8
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ rails_version = ENV.fetch("RAILS_VERSION", ">= 5.2.8.1")
8
+
9
+ gem "rails", rails_version
10
+
11
+ gem "byebug"
12
+ gem "license_finder", ">= 7.0"
13
+ gem "rake", ">= 13.0"
14
+ gem "rspec", ">= 3.0"
15
+ gem "rubocop", ">= 1.32"
16
+ gem "rubocop-powerhome", ">= 0.5.0"
data/config/config.yml ADDED
@@ -0,0 +1,12 @@
1
+ base: &base
2
+ key:
3
+ nested:
4
+ value: "Hello World"
5
+
6
+ test:
7
+ <<: *base
8
+ env_name: test
9
+
10
+ development:
11
+ <<: *base
12
+ env_name: development
data/config.ru ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize!
9
+ run Combustion::Application
@@ -0,0 +1,3 @@
1
+ ---
2
+ - - :inherit_from
3
+ - https://raw.githubusercontent.com/powerhome/oss-guide/master/license_rules.yml
data/docs/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.1] - 2022-07-28
4
+
5
+ - Support multiple versions of rails (>= 5.2.8.1)
6
+
7
+ ## [0.1.0] - 2022-07-28
8
+
9
+ - Initial release
@@ -1,16 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/hash/indifferent_access"
4
- require "active_support/core_ext/object/try"
5
4
  require "active_support/hash_with_indifferent_access"
6
5
 
7
- require "nitro_config/error"
8
-
9
6
  module NitroConfig
10
7
  PATH_SEPARATOR = "/"
11
8
 
12
9
  # Representation of a config key-value tree with path-based access
13
10
  class Options < HashWithIndifferentAccess
11
+ def self.load_yml(path, environment)
12
+ yaml = begin
13
+ YAML.load_file(path, aliases: true)
14
+ rescue ArgumentError
15
+ YAML.load_file(path)
16
+ end
17
+ new(yaml[environment])
18
+ end
19
+
14
20
  # Preserves values in the global configuration which might be altered within the yielded block.
15
21
  # This is useful for testing, where a test needs to assert behaviour with certain settings values,
16
22
  # but you want them to be restored for the next test.
@@ -54,7 +60,7 @@ module NitroConfig
54
60
  def get!(path)
55
61
  split_path = path.respond_to?(:split) ? path.split(PATH_SEPARATOR) : path
56
62
  split_path.flatten.reduce(self) do |config, key|
57
- raise(NitroConfig::Error, path) unless config.try(:has_key?, key)
63
+ raise(NitroConfig::Error, path) unless config&.key?(key)
58
64
 
59
65
  config[key]
60
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NitroConfig
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/nitro_config.rb CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  require "yaml"
4
4
 
5
+ require "nitro_config/error"
5
6
  require "nitro_config/options"
7
+ require "nitro_config/railtie" if defined?(Rails)
6
8
 
7
9
  # When included in a Rails application, NitroConfig loads the
8
10
  # configuration file at `config/config.yml` within the application
@@ -19,7 +21,7 @@ module NitroConfig
19
21
  #
20
22
  # @return [NitroConfig::Options] the loaded configuration
21
23
  def self.load!(file, env)
22
- @config = NitroConfig::Options.new(YAML.load_file(file)[env])
24
+ @config = NitroConfig::Options.load_yml(file, env)
23
25
  end
24
26
 
25
27
  # Provides the loaded global configuration
@@ -48,6 +50,4 @@ module NitroConfig
48
50
  def self.get_deferred!(*args)
49
51
  ->(*_args) { config.get!(*args) }
50
52
  end
51
-
52
- require "nitro_config/railtie" if defined?(Rails)
53
53
  end
data/mkdocs.yml ADDED
@@ -0,0 +1,5 @@
1
+ site_name: Nitro Config
2
+ nav:
3
+ - "Home": "README.md"
4
+ plugins:
5
+ - techdocs-core
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/nitro_config/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "nitro_config"
7
+ spec.version = NitroConfig::VERSION
8
+ spec.authors = ["Carlos Palhares", "Jill Klang"]
9
+ spec.email = ["chjunior@gmail.com", "jillian.emilie@gmail.com"]
10
+
11
+ spec.summary = "Nitro Configuration Loader"
12
+ spec.description = "Loads Nitro configuration and makes it available to the application"
13
+ spec.homepage = "https://github.com/powerhome/power-tools"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7"
16
+
17
+ spec.metadata["rubygems_mfa_required"] = "true"
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/packages/nitro_config/docs/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "activesupport", ">= 5.2.8.1"
34
+ spec.add_development_dependency "combustion", "~> 1.3"
35
+ end
data/test.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ bin/setup
5
+ bin/build
6
+ bin/doc
7
+ bin/test
metadata CHANGED
@@ -1,142 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
8
  - Jill Klang
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
- date: 2022-07-28 00:00:00.000000000 Z
12
+ date: 2022-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 5.2.8
20
+ version: 5.2.8.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 5.2.8
27
+ version: 5.2.8.1
28
28
  - !ruby/object:Gem::Dependency
29
- name: license_finder
29
+ name: combustion
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '7.0'
34
+ version: '1.3'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '7.0'
42
- - !ruby/object:Gem::Dependency
43
- name: pry-byebug
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - '='
47
- - !ruby/object:Gem::Version
48
- version: 3.9.0
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '='
54
- - !ruby/object:Gem::Version
55
- version: 3.9.0
56
- - !ruby/object:Gem::Dependency
57
- name: rainbow
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - '='
61
- - !ruby/object:Gem::Version
62
- version: 2.2.2
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - '='
68
- - !ruby/object:Gem::Version
69
- version: 2.2.2
70
- - !ruby/object:Gem::Dependency
71
- name: rake
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '13.0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '13.0'
84
- - !ruby/object:Gem::Dependency
85
- name: rspec
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - '='
89
- - !ruby/object:Gem::Version
90
- version: 3.9.0
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - '='
96
- - !ruby/object:Gem::Version
97
- version: 3.9.0
98
- - !ruby/object:Gem::Dependency
99
- name: rubocop-powerhome
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - '='
103
- - !ruby/object:Gem::Version
104
- version: 0.4.1
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - '='
110
- - !ruby/object:Gem::Version
111
- version: 0.4.1
112
- - !ruby/object:Gem::Dependency
113
- name: simplecov
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - '='
117
- - !ruby/object:Gem::Version
118
- version: 0.15.1
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - '='
124
- - !ruby/object:Gem::Version
125
- version: 0.15.1
126
- - !ruby/object:Gem::Dependency
127
- name: yard
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - '='
131
- - !ruby/object:Gem::Version
132
- version: 0.9.21
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - '='
138
- - !ruby/object:Gem::Version
139
- version: 0.9.21
41
+ version: '1.3'
140
42
  description: Loads Nitro configuration and makes it available to the application
141
43
  email:
142
44
  - chjunior@gmail.com
@@ -145,7 +47,13 @@ executables: []
145
47
  extensions: []
146
48
  extra_rdoc_files: []
147
49
  files:
50
+ - ".rubocop.yml"
51
+ - Gemfile
148
52
  - Rakefile
53
+ - config.ru
54
+ - config/config.yml
55
+ - doc/dependency_decisions.yml
56
+ - docs/CHANGELOG.md
149
57
  - docs/README.md
150
58
  - lib/nitro_config.rb
151
59
  - lib/nitro_config/error.rb
@@ -153,11 +61,17 @@ files:
153
61
  - lib/nitro_config/railtie.rb
154
62
  - lib/nitro_config/rspec.rb
155
63
  - lib/nitro_config/version.rb
156
- homepage: https://github.com/powerhome/power-tools/blob/main/packages/nitro_config/docs/README.md
64
+ - mkdocs.yml
65
+ - nitro_config.gemspec
66
+ - test.sh
67
+ homepage: https://github.com/powerhome/power-tools
157
68
  licenses:
158
69
  - MIT
159
70
  metadata:
160
71
  rubygems_mfa_required: 'true'
72
+ homepage_uri: https://github.com/powerhome/power-tools
73
+ source_code_uri: https://github.com/powerhome/power-tools
74
+ changelog_uri: https://github.com/powerhome/power-tools/blob/main/packages/nitro_config/docs/CHANGELOG.md
161
75
  post_install_message:
162
76
  rdoc_options: []
163
77
  require_paths: