envlogic 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +10 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +19 -29
- data/README.md +7 -20
- data/envlogic.gemspec +2 -2
- data/lib/envlogic.rb +1 -3
- data/lib/envlogic/env.rb +33 -12
- data/lib/envlogic/version.rb +1 -1
- metadata +8 -9
- data/lib/envlogic/string_refinements.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8a09f4a02ecb4aa854f21c30620be8670fc22f41eb3eb464ec5d8bb67dda98d
|
4
|
+
data.tar.gz: 706f85a46eb589b93492e3a0b3fa08cbd5c4685471305c60fa6dd0d6745f6981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d47e67ed63559fa4a23f5a28952fd0ee63bab890ed24e79e126e15b52c1fe09fa51343463b8396d3d4e58f9cbd14ebb1a8d4522d0c5b052a8b00308589c3096d
|
7
|
+
data.tar.gz: 8be0454147aa97749c5ff9c1e0832dd5173d596abdda9f58865065b5b6c1a248b02da1413b1c6fda16f2ef77158a9080aa2d4eff5e246f9664a0e51f90675d18
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.0
|
data/.travis.yml
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
2
3
|
rvm:
|
3
|
-
- 2.2.2
|
4
|
-
- 2.2.3
|
5
4
|
- 2.3.0
|
6
5
|
- 2.3.1
|
7
6
|
- 2.3.2
|
8
7
|
- 2.3.3
|
8
|
+
- 2.3.4
|
9
9
|
- 2.4.0
|
10
10
|
- 2.4.1
|
11
|
-
|
12
|
-
-
|
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
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# Envlogic gem changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## 1.1.0
|
4
|
+
- Ruby 2.4.2 support
|
5
|
+
- Ruby 2.5.0 support
|
6
|
+
- ActiveSupport dependency dropped in favor of dry-inflector
|
7
|
+
|
8
|
+
## 1.0.4
|
4
9
|
- Switched with quality metrics to Coditsu (https://coditsu.io/)
|
5
10
|
- Gem dump
|
6
11
|
- Quality improvements
|
7
12
|
- Gems cleanup
|
8
13
|
- Ruby dump to 2.4.1
|
9
14
|
- Better specs (less internal, more integrational)
|
15
|
+
- License added to the gemspec file
|
10
16
|
|
11
17
|
## 1.0.3
|
12
18
|
- Gem dump x3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,45 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
envlogic (1.0
|
5
|
-
|
4
|
+
envlogic (1.1.0)
|
5
|
+
dry-inflector (~> 0.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (5.1.3)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (~> 0.7)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
concurrent-ruby (1.0.5)
|
16
10
|
diff-lcs (1.3)
|
17
|
-
docile (1.
|
18
|
-
|
11
|
+
docile (1.3.0)
|
12
|
+
dry-inflector (0.1.1)
|
19
13
|
json (2.1.0)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rspec-
|
24
|
-
rspec-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rspec-expectations (3.6.0)
|
14
|
+
rake (12.3.1)
|
15
|
+
rspec (3.7.0)
|
16
|
+
rspec-core (~> 3.7.0)
|
17
|
+
rspec-expectations (~> 3.7.0)
|
18
|
+
rspec-mocks (~> 3.7.0)
|
19
|
+
rspec-core (3.7.1)
|
20
|
+
rspec-support (~> 3.7.0)
|
21
|
+
rspec-expectations (3.7.0)
|
29
22
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.
|
31
|
-
rspec-mocks (3.
|
23
|
+
rspec-support (~> 3.7.0)
|
24
|
+
rspec-mocks (3.7.0)
|
32
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.
|
34
|
-
rspec-support (3.
|
35
|
-
simplecov (0.
|
36
|
-
docile (~> 1.1
|
26
|
+
rspec-support (~> 3.7.0)
|
27
|
+
rspec-support (3.7.1)
|
28
|
+
simplecov (0.16.1)
|
29
|
+
docile (~> 1.1)
|
37
30
|
json (>= 1.8, < 3)
|
38
31
|
simplecov-html (~> 0.10.0)
|
39
32
|
simplecov-html (0.10.2)
|
40
|
-
thread_safe (0.3.6)
|
41
|
-
tzinfo (1.2.3)
|
42
|
-
thread_safe (~> 0.1)
|
43
33
|
|
44
34
|
PLATFORMS
|
45
35
|
ruby
|
@@ -51,4 +41,4 @@ DEPENDENCIES
|
|
51
41
|
simplecov
|
52
42
|
|
53
43
|
BUNDLED WITH
|
54
|
-
1.
|
44
|
+
1.16.1
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Envlogic
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/karafka/envlogic.png)](https://travis-ci.org/karafka/envlogic)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/karafka/envlogic/badges/gpa.svg)](https://codeclimate.com/github/karafka/envlogic)
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/envlogic.svg)](http://badge.fury.io/rb/envlogic)
|
6
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)
|
7
5
|
|
8
6
|
Envlogic is a library used to manage environments for your Ruby application in a similar to Rails.env way.
|
@@ -87,28 +85,17 @@ Basic::Karafka.env.development? # => true
|
|
87
85
|
## References
|
88
86
|
|
89
87
|
* [Karafka framework](https://github.com/karafka/karafka)
|
90
|
-
* [Waterdrop](https://github.com/karafka/waterdrop)
|
91
|
-
* [Envlogic](https://github.com/karafka/envlogic)
|
92
|
-
* [Worker Glass](https://github.com/karafka/worker-glass)
|
93
|
-
* [Null Logger](https://github.com/karafka/null-logger)
|
94
88
|
* [Envlogic Travis CI](https://travis-ci.org/karafka/envlogic)
|
95
|
-
* [Envlogic
|
89
|
+
* [Envlogic Coditsu](https://app.coditsu.io/karafka/repositories/envlogic)
|
96
90
|
|
97
|
-
## Note on
|
91
|
+
## Note on contributions
|
98
92
|
|
99
|
-
|
100
|
-
Make your feature addition or bug fix.
|
101
|
-
Add tests for it. This is important so I don't break it in a future version unintentionally.
|
102
|
-
Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull). Send me a pull request. Bonus points for topic branches.
|
93
|
+
First, thank you for considering contributing to Envlogic! It's people like you that make the open source community such a great community!
|
103
94
|
|
104
|
-
|
95
|
+
Each pull request must pass all the rspec specs and meet our quality requirements.
|
105
96
|
|
106
|
-
|
97
|
+
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.
|
107
98
|
|
108
|
-
|
99
|
+
Coditsu will automatically check your work against our quality standards. You can find your commit check results on the [builds page](https://app.coditsu.io/karafka/repositories/envlogic/builds/commit_builds) of Envlogic repository.
|
109
100
|
|
110
|
-
|
111
|
-
bundle exec rake
|
112
|
-
```
|
113
|
-
|
114
|
-
to check if everything is in order. After that you can submit a pull request.
|
101
|
+
[![coditsu](https://coditsu.io/assets/quality_bar.svg)](https://app.coditsu.io/karafka/repositories/envlogic/builds/commit_builds)
|
data/envlogic.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
require 'envlogic/version'
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = 'https://github.com/karafka/envlogic'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
|
-
spec.add_dependency '
|
19
|
+
spec.add_dependency 'dry-inflector', '~> 0.1'
|
20
20
|
spec.required_ruby_version = '>= 2.2.0'
|
21
21
|
|
22
22
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
data/lib/envlogic.rb
CHANGED
data/lib/envlogic/env.rb
CHANGED
@@ -3,13 +3,20 @@
|
|
3
3
|
# Main module
|
4
4
|
module Envlogic
|
5
5
|
# Env module to get and set environment
|
6
|
-
class Env <
|
7
|
-
using StringRefinements
|
8
|
-
|
6
|
+
class Env < String
|
9
7
|
# What environment key should be used by default
|
10
8
|
FALLBACK_ENV_KEY = 'RACK_ENV'
|
11
9
|
# What default environment should be asumed when there's nothing else
|
12
10
|
FALLBACK_ENV = 'development'
|
11
|
+
# Postfix for ENV keys
|
12
|
+
ENV_KEY_POSTFIX = '_ENV'
|
13
|
+
# String inflecting engine
|
14
|
+
INFLECTOR = Dry::Inflector.new
|
15
|
+
|
16
|
+
private_constant :FALLBACK_ENV_KEY, :FALLBACK_ENV, :ENV_KEY_POSTFIX, :INFLECTOR
|
17
|
+
|
18
|
+
# It's just a string replace alias for the envlogic compatibility
|
19
|
+
alias update replace
|
13
20
|
|
14
21
|
# @param klass [Class, Module] class/module for which we want to build a Envlogic::Env object
|
15
22
|
# @return [Envlogic::Env] envlogic env object]
|
@@ -17,20 +24,26 @@ module Envlogic
|
|
17
24
|
# Envlogic::Env.new(User)
|
18
25
|
# @note Will load appropriate environment automatically
|
19
26
|
def initialize(klass)
|
20
|
-
env = ENV[app_dir_name
|
21
|
-
env ||= ENV[klass.to_s
|
27
|
+
env = ENV[to_env_key(app_dir_name)]
|
28
|
+
env ||= ENV[to_env_key(klass.to_s)]
|
22
29
|
env ||= ENV[FALLBACK_ENV_KEY]
|
23
30
|
|
24
31
|
update(env || FALLBACK_ENV)
|
25
32
|
end
|
26
33
|
|
27
|
-
# @param
|
28
|
-
# @
|
29
|
-
#
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
# @param method_name [String] method name
|
35
|
+
# @param include_private [Boolean] should we include private methods as well
|
36
|
+
# @return [Boolean] true if we respond to a given missing method, otherwise false
|
37
|
+
def respond_to_missing?(method_name, include_private = false)
|
38
|
+
(method_name[-1] == '?') || super
|
39
|
+
end
|
40
|
+
|
41
|
+
# Reacts to missing methods, from which some might be the env checkings.
|
42
|
+
# If the method ends with '?' we assume, that it is an env check
|
43
|
+
# @param method_name [String] method name for missing or env name with question mark
|
44
|
+
# @param arguments [Array] any arguments that we pass to the method
|
45
|
+
def method_missing(method_name, *arguments)
|
46
|
+
method_name[-1] == '?' ? self == method_name[0..-2] : super
|
34
47
|
end
|
35
48
|
|
36
49
|
private
|
@@ -45,5 +58,13 @@ module Envlogic
|
|
45
58
|
.basename
|
46
59
|
.to_s
|
47
60
|
end
|
61
|
+
|
62
|
+
# Converts any string into a bash ENV key
|
63
|
+
def to_env_key(string)
|
64
|
+
INFLECTOR
|
65
|
+
.underscore(string)
|
66
|
+
.tr('/', '_')
|
67
|
+
.upcase + ENV_KEY_POSTFIX
|
68
|
+
end
|
48
69
|
end
|
49
70
|
end
|
data/lib/envlogic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pavlo_vavruk
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: dry-inflector
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
20
|
+
version: '0.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: '0'
|
27
|
+
version: '0.1'
|
28
28
|
description: Library used to manage environments for your Ruby application
|
29
29
|
email:
|
30
30
|
- pavlo.vavruk@gmail.com
|
@@ -47,7 +47,6 @@ files:
|
|
47
47
|
- envlogic.gemspec
|
48
48
|
- lib/envlogic.rb
|
49
49
|
- lib/envlogic/env.rb
|
50
|
-
- lib/envlogic/string_refinements.rb
|
51
50
|
- lib/envlogic/version.rb
|
52
51
|
homepage: https://github.com/karafka/envlogic
|
53
52
|
licenses:
|
@@ -69,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
68
|
version: '0'
|
70
69
|
requirements: []
|
71
70
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.6
|
71
|
+
rubygems_version: 2.7.6
|
73
72
|
signing_key:
|
74
73
|
specification_version: 4
|
75
74
|
summary: Library which allows to set and get environments values
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Envlogic
|
4
|
-
# String refinements used in this library
|
5
|
-
module StringRefinements
|
6
|
-
# Postfix for ENV keys
|
7
|
-
ENV_KEY_POSTFIX = '_ENV'
|
8
|
-
|
9
|
-
refine String do
|
10
|
-
# Converts any string into a bash ENV key
|
11
|
-
def to_env_key
|
12
|
-
underscore
|
13
|
-
.tr('/', '_')
|
14
|
-
.upcase + Envlogic::StringRefinements::ENV_KEY_POSTFIX
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|