envlogic 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.coditsu/ci.yml +3 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/ci.yml +43 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +19 -21
- data/README.md +29 -4
- data/envlogic.gemspec +6 -1
- data/lib/envlogic.rb +17 -5
- data/lib/envlogic/env.rb +5 -3
- data/lib/envlogic/version.rb +1 -1
- metadata +34 -7
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 111d26f3d2e7c8bdcccf966cb4290d6fd5f019e57ba616111a1131790499aa8b
|
4
|
+
data.tar.gz: 9b5e99b1e28a507730ab7c1e14b195302e272ac2ea5294d6f7a8a65c32c197ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e15698e86e7f54148262f668e4d612dc6b3a02e164a8f99692c47ae5a4337b0b045ebb3f95fef7cba59d1098ab43785b6fdd4294bba1fac9f9bba0e7db37d80
|
7
|
+
data.tar.gz: 4bcd82c8dd5e64964283d453f884c34effea553121d05ea1541d51c46afc237a11c399ff9b8a4d70c4b4d170a7d94e1992a5111d36c018e289e3629787484423
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/.coditsu/ci.yml
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
open_collective: karafka
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
paths:
|
6
|
+
- '**'
|
7
|
+
schedule:
|
8
|
+
- cron: '0 1 * * *'
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
specs:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- "2.7"
|
18
|
+
- "2.6"
|
19
|
+
- "2.5"
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v1
|
22
|
+
- name: Install package dependencies
|
23
|
+
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{matrix.ruby}}
|
28
|
+
- name: Install latest bundler
|
29
|
+
run: |
|
30
|
+
gem install bundler --no-document
|
31
|
+
bundle config set without 'tools benchmarks docs'
|
32
|
+
- name: Bundle install
|
33
|
+
run: bundle install --jobs 4 --retry 3
|
34
|
+
- name: Run all tests
|
35
|
+
run: bundle exec rspec
|
36
|
+
coditsu:
|
37
|
+
runs-on: ubuntu-latest
|
38
|
+
strategy:
|
39
|
+
fail-fast: false
|
40
|
+
steps:
|
41
|
+
- uses: actions/checkout@v1
|
42
|
+
- name: Run Coditsu
|
43
|
+
run: \curl -sSL https://api.coditsu.io/run/ci | bash
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Envlogic gem changelog
|
2
2
|
|
3
|
+
## Unreleased (master)
|
4
|
+
- drop jruby support
|
5
|
+
- drop Ruby 2.2 support
|
6
|
+
- drop Ruby 2.3 support
|
7
|
+
- drop Ruby 2.4 support
|
8
|
+
- Ruby 2.6.5 support
|
9
|
+
- Ruby 2.7.1 support
|
10
|
+
- Replace travis with GH actions
|
11
|
+
- Update docs to show per instance support
|
12
|
+
|
3
13
|
## 1.1.0
|
4
14
|
- Ruby 2.4.2 support
|
5
15
|
- Ruby 2.5.0 support
|
@@ -11,7 +21,7 @@
|
|
11
21
|
- Quality improvements
|
12
22
|
- Gems cleanup
|
13
23
|
- Ruby dump to 2.4.1
|
14
|
-
- Better specs (less internal, more
|
24
|
+
- Better specs (less internal, more integration)
|
15
25
|
- License added to the gemspec file
|
16
26
|
|
17
27
|
## 1.0.3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
envlogic (1.1.
|
4
|
+
envlogic (1.1.1)
|
5
5
|
dry-inflector (~> 0.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.3)
|
11
|
-
docile (1.3.
|
12
|
-
dry-inflector (0.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rspec-
|
17
|
-
rspec-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
rspec-expectations (3.7.0)
|
11
|
+
docile (1.3.2)
|
12
|
+
dry-inflector (0.2.0)
|
13
|
+
rake (13.0.1)
|
14
|
+
rspec (3.9.0)
|
15
|
+
rspec-core (~> 3.9.0)
|
16
|
+
rspec-expectations (~> 3.9.0)
|
17
|
+
rspec-mocks (~> 3.9.0)
|
18
|
+
rspec-core (3.9.1)
|
19
|
+
rspec-support (~> 3.9.1)
|
20
|
+
rspec-expectations (3.9.1)
|
22
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-mocks (3.
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-mocks (3.9.1)
|
25
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-support (3.
|
28
|
-
simplecov (0.
|
25
|
+
rspec-support (~> 3.9.0)
|
26
|
+
rspec-support (3.9.2)
|
27
|
+
simplecov (0.18.5)
|
29
28
|
docile (~> 1.1)
|
30
|
-
|
31
|
-
|
32
|
-
simplecov-html (0.10.2)
|
29
|
+
simplecov-html (~> 0.11)
|
30
|
+
simplecov-html (0.12.2)
|
33
31
|
|
34
32
|
PLATFORMS
|
35
33
|
ruby
|
@@ -41,4 +39,4 @@ DEPENDENCIES
|
|
41
39
|
simplecov
|
42
40
|
|
43
41
|
BUNDLED WITH
|
44
|
-
1.
|
42
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# Envlogic
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/karafka/envlogic/workflows/ci/badge.svg)](https://github.com/karafka/envlogic/actions?query=workflow%3Aci)
|
4
4
|
[![Join the chat at https://gitter.im/karafka/karafka](https://badges.gitter.im/karafka/karafka.svg)](https://gitter.im/karafka/karafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
|
6
6
|
Envlogic is a library used to manage environments for your Ruby application in a similar to Rails.env way.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
Add gem to your Gemfile
|
10
|
+
Add the gem to your Gemfile
|
11
11
|
```ruby
|
12
12
|
gem 'envlogic'
|
13
13
|
```
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
### On a class/module level
|
18
|
+
|
17
19
|
Extend your class or module in which you want to use this library with **Envlogic** module.
|
18
20
|
|
19
21
|
```ruby
|
@@ -34,11 +36,34 @@ Once you extend your class/module with it, you will have two additional methods
|
|
34
36
|
ExampleModule.env.production? # => false
|
35
37
|
```
|
36
38
|
|
39
|
+
### On a per instance basis
|
40
|
+
|
41
|
+
Include the **Envlogic** module in the class for which instances you want to use it.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
class ExampleClass
|
45
|
+
include Envlogic
|
46
|
+
# code of this class
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
Once you include it in your class, you will have two additional methods (with two aliases):
|
51
|
+
|
52
|
+
- *.env* (.environment) - obtain current env and work with it
|
53
|
+
- *.env=* (.environment=) - set your own environment
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
instance = ExampleClass.new
|
57
|
+
instance.env = 'development'
|
58
|
+
instance.env.development? # => true
|
59
|
+
instance.env.production? # => false
|
60
|
+
```
|
61
|
+
|
37
62
|
### ENV variables key names and default fallbacks
|
38
63
|
|
39
64
|
#### Application root directory env key name
|
40
65
|
|
41
|
-
By default gem is looking for ENV variable that is based on your application root directory.
|
66
|
+
By default, the gem is looking for ENV variable that is based on your application root directory.
|
42
67
|
|
43
68
|
For example, if your application lies in */home/deploy/my_app* it will look for **MY_APP_ENV** variable.
|
44
69
|
|
@@ -92,7 +117,7 @@ Basic::Karafka.env.development? # => true
|
|
92
117
|
|
93
118
|
First, thank you for considering contributing to Envlogic! It's people like you that make the open source community such a great community!
|
94
119
|
|
95
|
-
Each pull request must pass all the
|
120
|
+
Each pull request must pass all the RSpec specs and meet our quality requirements.
|
96
121
|
|
97
122
|
To check if everything is as it should be, we use [Coditsu](https://coditsu.io) that combines multiple linters and code analyzers for both code and documentation. Once you're done with your changes, submit a pull request.
|
98
123
|
|
data/envlogic.gemspec
CHANGED
@@ -17,8 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
19
|
spec.add_dependency 'dry-inflector', '~> 0.1'
|
20
|
-
spec.required_ruby_version = '>= 2.
|
20
|
+
spec.required_ruby_version = '>= 2.5.0'
|
21
21
|
|
22
|
+
if $PROGRAM_NAME.end_with?('gem')
|
23
|
+
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.cert_chain = %w[certs/mensfeld.pem]
|
22
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
23
28
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
29
|
spec.require_paths = %w[lib]
|
data/lib/envlogic.rb
CHANGED
@@ -7,15 +7,27 @@
|
|
7
7
|
].each { |lib| require lib }
|
8
8
|
|
9
9
|
# Main module that encapsulates logic that should be used to extend any class/module
|
10
|
-
# @note This module should be extended into the class/module in which we want to have
|
10
|
+
# @note This module should be extended/included into the class/module in which we want to have
|
11
|
+
# env support
|
12
|
+
#
|
11
13
|
# @example Use it in RandomClass class
|
12
14
|
# class RandomClass
|
13
15
|
# extend Envlogic
|
14
16
|
# end
|
15
17
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
18
|
+
# RandomClass.env #=> Envlogic::Env instance
|
19
|
+
# RandomClass.env.production? #=> false
|
20
|
+
# RandomClass.env.development? #=> true
|
21
|
+
#
|
22
|
+
# @example Use it for instances of objects
|
23
|
+
# class RandomClass
|
24
|
+
# include Envlogic
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# instance = RandomClass.new
|
28
|
+
# instance.env #=> Envlogic::Env instance
|
29
|
+
# instance.env.production? #=> false
|
30
|
+
# instance.env.development? #=> true
|
19
31
|
module Envlogic
|
20
32
|
# @return [Envlogic::Env] envlogic env instance that allows us to check environment
|
21
33
|
# @example Invoke env in TestClass
|
@@ -32,7 +44,7 @@ module Envlogic
|
|
32
44
|
env.update(environment.to_s)
|
33
45
|
end
|
34
46
|
|
35
|
-
# We alias this for
|
47
|
+
# We alias this for backward compatibility with some code that uses full names
|
36
48
|
alias environment env
|
37
49
|
alias environment= env=
|
38
50
|
end
|
data/lib/envlogic/env.rb
CHANGED
@@ -6,7 +6,7 @@ module Envlogic
|
|
6
6
|
class Env < String
|
7
7
|
# What environment key should be used by default
|
8
8
|
FALLBACK_ENV_KEY = 'RACK_ENV'
|
9
|
-
# What default environment should be
|
9
|
+
# What default environment should be assumed when there's nothing else
|
10
10
|
FALLBACK_ENV = 'development'
|
11
11
|
# Postfix for ENV keys
|
12
12
|
ENV_KEY_POSTFIX = '_ENV'
|
@@ -20,9 +20,9 @@ module Envlogic
|
|
20
20
|
|
21
21
|
# @param klass [Class, Module] class/module for which we want to build a Envlogic::Env object
|
22
22
|
# @return [Envlogic::Env] envlogic env object]
|
23
|
+
# @note Will load appropriate environment automatically
|
23
24
|
# @example
|
24
25
|
# Envlogic::Env.new(User)
|
25
|
-
# @note Will load appropriate environment automatically
|
26
26
|
def initialize(klass)
|
27
27
|
env = ENV[to_env_key(app_dir_name)]
|
28
28
|
env ||= ENV[to_env_key(klass.to_s)]
|
@@ -38,7 +38,7 @@ module Envlogic
|
|
38
38
|
(method_name[-1] == '?') || super
|
39
39
|
end
|
40
40
|
|
41
|
-
# Reacts to missing methods, from which some might be the env
|
41
|
+
# Reacts to missing methods, from which some might be the env checks.
|
42
42
|
# If the method ends with '?' we assume, that it is an env check
|
43
43
|
# @param method_name [String] method name for missing or env name with question mark
|
44
44
|
# @param arguments [Array] any arguments that we pass to the method
|
@@ -60,6 +60,8 @@ module Envlogic
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Converts any string into a bash ENV key
|
63
|
+
# @param string [String] string we want to convert into an env key
|
64
|
+
# @return [String] converted name that can be an ENV key
|
63
65
|
def to_env_key(string)
|
64
66
|
INFLECTOR
|
65
67
|
.underscore(string)
|
data/lib/envlogic/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pavlo_vavruk
|
8
8
|
- Maciej Mensfeld
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BA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|
29
|
+
ZXsL+kRb2hLvsQJS/kLyM21oMlu+LN0aPj3qEFR8mE/YeDD8rLAfruBRTltPNbR7
|
30
|
+
xA5eE1gkxY5LfExUtK3b2wPqfmo7mZgfcsMwfYg/tUXw1WpBCnrhAJodpGH6SXmp
|
31
|
+
A40qFUZst0vjiOoO+aTblIHPmMJXoZ3K42dTlNKlEiDKUWMRKSgpjjYGEYalFNWI
|
32
|
+
hHfCz2r8L2t+dYdMZg1JGbEkq4ADGsAA8ioZIpJd7V4hI17u5TCdi7X5wh/0gN0E
|
33
|
+
CgP+nLox3D+l2q0QuQEkayr+auFYkzTCkF+BmEk1D0Ru4mcf3F4CJvEmW4Pzbjqt
|
34
|
+
i1tsCWPtJ4E/UUKnKaWKqGbjrjHJ0MuShYzHkodox5IOiCXIQg+1+YSzfXUV6WEK
|
35
|
+
KJG/fhg1JV5vVDdVy6x+tv5SQ5ctU0feCsVfESi3rE3zRd+nvzE9HcZ5aXeL1UtJ
|
36
|
+
nT5Xrioegu2w1jPyVEgyZgTZC5rvD0nNS5sFNQ==
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
13
39
|
dependencies:
|
14
40
|
- !ruby/object:Gem::Dependency
|
15
41
|
name: dry-inflector
|
@@ -33,11 +59,13 @@ executables: []
|
|
33
59
|
extensions: []
|
34
60
|
extra_rdoc_files: []
|
35
61
|
files:
|
62
|
+
- ".coditsu/ci.yml"
|
63
|
+
- ".github/FUNDING.yml"
|
64
|
+
- ".github/workflows/ci.yml"
|
36
65
|
- ".gitignore"
|
37
66
|
- ".rspec"
|
38
67
|
- ".ruby-gemset"
|
39
68
|
- ".ruby-version"
|
40
|
-
- ".travis.yml"
|
41
69
|
- CHANGELOG.md
|
42
70
|
- Gemfile
|
43
71
|
- Gemfile.lock
|
@@ -60,15 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
88
|
requirements:
|
61
89
|
- - ">="
|
62
90
|
- !ruby/object:Gem::Version
|
63
|
-
version: 2.
|
91
|
+
version: 2.5.0
|
64
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
requirements: []
|
70
|
-
|
71
|
-
rubygems_version: 2.7.6
|
98
|
+
rubygems_version: 3.1.2
|
72
99
|
signing_key:
|
73
100
|
specification_version: 4
|
74
101
|
summary: Library which allows to set and get environments values
|
metadata.gz.sig
ADDED
Binary file
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
rvm:
|
4
|
-
- 2.3.0
|
5
|
-
- 2.3.1
|
6
|
-
- 2.3.2
|
7
|
-
- 2.3.3
|
8
|
-
- 2.3.4
|
9
|
-
- 2.4.0
|
10
|
-
- 2.4.1
|
11
|
-
- 2.4.2
|
12
|
-
- 2.5.0
|
13
|
-
- jruby-head
|
14
|
-
script: bundle exec rspec spec/
|
15
|
-
env:
|
16
|
-
global:
|
17
|
-
- JRUBY_OPTS='--debug'
|
18
|
-
install: bundle install --jobs=3 --retry=3
|