envlogic 1.0.3 → 1.1.3

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
- SHA1:
3
- metadata.gz: d0aeeb99acb205744f90ccb491b41f46f40ce5d6
4
- data.tar.gz: ebb9711460b43b627156b1c2b1428c2ee6cb8615
2
+ SHA256:
3
+ metadata.gz: '08a91557e34fc15b5ce8809d6908d8f295f649f33d1e052662ff3024c577680f'
4
+ data.tar.gz: f0bcf298f1f39a5e33226d917ac07d05a126f7dbb9adccfb9fb768af7a247249
5
5
  SHA512:
6
- metadata.gz: 262e011bf46adfff12f47e0fc4d4a64305ee07a8f737a892f6ca72b079c44448a7c0e6f6f30615e020c994898f041d785cd3cfa29e421b5978b44a3c63bf81db
7
- data.tar.gz: 1a65ccc52ee950953e06f6ebf50ef5a7123ed0c1eac5db8a52a26214c55434207ed440c992997ac7d3e271e94647e55357deec16edc41220dd57789c431196cf
6
+ metadata.gz: 323528643b3df77a23d5d44f7e631a53bea21f971840b29e44457a730d2b684c07dd0749311c3b0eca73ffc5904c1b62ca3c7d1f3e3149ae2d4a6f2c8c6660ef
7
+ data.tar.gz: fb973ba469fca1ea05666c84e8000a9186cc311e9030b8341dc9cef3450f27bdc884f5ddc42b1d09359f9d32e25751b463c7a30b1f251203d33d9d6648662d72
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/.coditsu/ci.yml ADDED
@@ -0,0 +1,3 @@
1
+ repository_id: '8e9c10ac-336a-485a-9f9b-69ea15075c2b'
2
+ api_key: <%= ENV['CODITSU_API_KEY'] %>
3
+ api_secret: <%= ENV['CODITSU_API_SECRET'] %>
data/.diffend.yml ADDED
@@ -0,0 +1,3 @@
1
+ project_id: '2aea122d-f4f1-4a9d-a1d1-34f9bbd769be'
2
+ shareable_id: '4cb899b8-bf3c-4976-8948-70f367bbdc7c'
3
+ shareable_key: '7479aeaf-1ecc-403d-9325-2c4e6abbb68b'
@@ -0,0 +1 @@
1
+ open_collective: karafka
@@ -0,0 +1,72 @@
1
+ name: ci
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ schedule:
7
+ - cron: '0 1 * * *'
8
+
9
+ jobs:
10
+ specs:
11
+ runs-on: ubuntu-latest
12
+ needs: diffend
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby:
17
+ - '3.0'
18
+ - '2.7'
19
+ - '2.6'
20
+ - 'jruby'
21
+ - 'truffleruby'
22
+ include:
23
+ - ruby: '3.0'
24
+ coverage: 'true'
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Install package dependencies
28
+ run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{matrix.ruby}}
33
+ - name: Install latest bundler
34
+ run: |
35
+ gem install bundler --no-document
36
+ bundle config set without 'tools benchmarks docs'
37
+ - name: Bundle install
38
+ run: bundle install --jobs 4 --retry 3
39
+ - name: Run all tests
40
+ env:
41
+ GITHUB_COVERAGE: ${{matrix.coverage}}
42
+ run: bundle exec rspec
43
+
44
+ diffend:
45
+ runs-on: ubuntu-latest
46
+ strategy:
47
+ fail-fast: false
48
+ steps:
49
+ - uses: actions/checkout@v2
50
+ with:
51
+ fetch-depth: 0
52
+ - name: Set up Ruby
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: 3.0
56
+ - name: Install latest bundler
57
+ run: gem install bundler --no-document
58
+ - name: Install Diffend plugin
59
+ run: bundle plugin install diffend
60
+ - name: Bundle Secure
61
+ run: bundle secure
62
+
63
+ coditsu:
64
+ runs-on: ubuntu-latest
65
+ strategy:
66
+ fail-fast: false
67
+ steps:
68
+ - uses: actions/checkout@v2
69
+ with:
70
+ fetch-depth: 0
71
+ - name: Run Coditsu
72
+ run: \curl -sSL https://api.coditsu.io/run/ci | bash
data/.gitignore CHANGED
@@ -54,3 +54,4 @@ build/
54
54
 
55
55
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
56
56
  .rvmrc
57
+ .coditsu/local.yml
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 3.0.1
data/CHANGELOG.md CHANGED
@@ -1,9 +1,45 @@
1
1
  # Envlogic gem changelog
2
2
 
3
- ## 1.0.3
3
+ ## 1.1.3 (2021-04-21)
4
+ - Restore MIT license
5
+ - Remove Ruby 2.5 support and update minimum Ruby requirement to 2.6
6
+
7
+ ## 1.1.2 (2020-04-24)
8
+ - restore JRuby support
9
+ - add TruffleRuby support
10
+ - Change license to LGPL-3.0
11
+
12
+ ## 1.1.1 (2020-04-22)
13
+ - drop jruby support
14
+ - drop Ruby 2.2 support
15
+ - drop Ruby 2.3 support
16
+ - drop Ruby 2.4 support
17
+ - Ruby 2.6.5 support
18
+ - Ruby 2.7.1 support
19
+ - Replace travis with GH actions
20
+ - Update docs to show per instance support
21
+ - Support signing the releases
22
+
23
+ ## 1.1.0
24
+ - Ruby 2.4.2 support
25
+ - Ruby 2.5.0 support
26
+ - ActiveSupport dependency dropped in favor of dry-inflector
27
+
28
+ ## 1.0.4
29
+ - Switched with quality metrics to Coditsu (https://coditsu.io/)
4
30
  - Gem dump
5
- - Ruby version defaults to 2.3.1
31
+ - Quality improvements
32
+ - Gems cleanup
33
+ - Ruby dump to 2.4.1
34
+ - Better specs (less internal, more integration)
35
+ - License added to the gemspec file
36
+
37
+ ## 1.0.3
38
+ - Gem dump x3
39
+ - ~~Ruby version defaults to 2.3.3~~
40
+ - Ruby version defaults to 2.4.0
6
41
  - Dropped support for Ruby 2.1.*
42
+ - added .rspec for default spec helper require
7
43
 
8
44
  ## 1.0.2
9
45
  - Dev tools update
data/Gemfile CHANGED
@@ -1,7 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
5
+ plugin 'diffend'
6
+
3
7
  gemspec
4
8
 
5
9
  group :development, :test do
6
- gem 'polishgeeks-dev-tools'
10
+ gem 'rake'
11
+ end
12
+
13
+ group :test do
14
+ gem 'rspec'
15
+ gem 'simplecov'
7
16
  end
data/Gemfile.lock CHANGED
@@ -1,160 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- envlogic (1.0.3)
5
- activesupport
4
+ envlogic (1.1.3)
5
+ dry-inflector (~> 0.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.0.0)
11
- concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (~> 0.7)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- addressable (2.4.0)
16
- ast (2.3.0)
17
- axiom-types (0.1.1)
18
- descendants_tracker (~> 0.0.4)
19
- ice_nine (~> 0.11.0)
20
- thread_safe (~> 0.3, >= 0.3.1)
21
- brakeman (3.3.3)
22
- bundler-audit (0.5.0)
23
- bundler (~> 1.2)
24
- thor (~> 0.18)
25
- codeclimate-engine-rb (0.3.1)
26
- virtus (~> 1.0)
27
- coderay (1.1.1)
28
- coercible (1.0.0)
29
- descendants_tracker (~> 0.0.1)
30
- colorize (0.8.1)
31
- concurrent-ruby (1.0.2)
32
- descendants_tracker (0.0.4)
33
- thread_safe (~> 0.3, >= 0.3.1)
34
- diff-lcs (1.2.5)
35
- docile (1.1.5)
36
- equalizer (0.0.11)
37
- erubis (2.7.0)
38
- faker (1.6.6)
39
- i18n (~> 0.5)
40
- flay (2.8.0)
41
- erubis (~> 2.7.0)
42
- path_expander (~> 1.0)
43
- ruby_parser (~> 3.0)
44
- sexp_processor (~> 4.0)
45
- flog (4.4.0)
46
- path_expander (~> 1.0)
47
- ruby_parser (~> 3.1, > 3.1.0)
48
- sexp_processor (~> 4.4)
49
- haml (4.0.7)
50
- tilt
51
- haml_lint (0.18.1)
52
- haml (~> 4.0)
53
- rake (>= 10, < 12)
54
- rubocop (>= 0.36.0)
55
- sysexits (~> 1.1)
56
- i18n (0.7.0)
57
- ice_nine (0.11.2)
58
- json (2.0.2)
59
- launchy (2.4.3)
60
- addressable (~> 2.3)
61
- method_source (0.8.2)
62
- minitest (5.9.0)
63
- parser (2.3.1.2)
64
- ast (~> 2.2)
65
- path_expander (1.0.0)
66
- polishgeeks-dev-tools (1.3.2)
67
- brakeman
68
- bundler-audit
69
- faker
70
- haml_lint
71
- pry
72
- rspec
73
- rubocop
74
- rubocop-rspec
75
- rubycritic
76
- shoulda
77
- simplecov
78
- timecop
79
- yard
80
- powerpack (0.1.1)
81
- pry (0.10.4)
82
- coderay (~> 1.1.0)
83
- method_source (~> 0.8.1)
84
- slop (~> 3.4)
85
- rainbow (2.1.0)
86
- rake (11.2.2)
87
- reek (4.1.0)
88
- codeclimate-engine-rb (~> 0.3.1)
89
- parser (~> 2.3.1, >= 2.3.1.2)
90
- rainbow (~> 2.0)
91
- rspec (3.5.0)
92
- rspec-core (~> 3.5.0)
93
- rspec-expectations (~> 3.5.0)
94
- rspec-mocks (~> 3.5.0)
95
- rspec-core (3.5.1)
96
- rspec-support (~> 3.5.0)
97
- rspec-expectations (3.5.0)
10
+ diff-lcs (1.4.4)
11
+ docile (1.3.5)
12
+ dry-inflector (0.2.0)
13
+ rake (13.0.3)
14
+ rspec (3.10.0)
15
+ rspec-core (~> 3.10.0)
16
+ rspec-expectations (~> 3.10.0)
17
+ rspec-mocks (~> 3.10.0)
18
+ rspec-core (3.10.1)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-expectations (3.10.1)
98
21
  diff-lcs (>= 1.2.0, < 2.0)
99
- rspec-support (~> 3.5.0)
100
- rspec-mocks (3.5.0)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-mocks (3.10.2)
101
24
  diff-lcs (>= 1.2.0, < 2.0)
102
- rspec-support (~> 3.5.0)
103
- rspec-support (3.5.0)
104
- rubocop (0.42.0)
105
- parser (>= 2.3.1.1, < 3.0)
106
- powerpack (~> 0.1)
107
- rainbow (>= 1.99.1, < 3.0)
108
- ruby-progressbar (~> 1.7)
109
- unicode-display_width (~> 1.0, >= 1.0.1)
110
- rubocop-rspec (1.5.1)
111
- rubocop (>= 0.41.2)
112
- ruby-progressbar (1.8.1)
113
- ruby_parser (3.8.2)
114
- sexp_processor (~> 4.1)
115
- rubycritic (2.9.2)
116
- colorize
117
- flay (= 2.8.0)
118
- flog (= 4.4.0)
119
- launchy (= 2.4.3)
120
- parser (= 2.3.1.2)
121
- reek (= 4.1.0)
122
- ruby_parser (~> 3.8)
123
- virtus (~> 1.0)
124
- sexp_processor (4.7.0)
125
- shoulda (3.5.0)
126
- shoulda-context (~> 1.0, >= 1.0.1)
127
- shoulda-matchers (>= 1.4.1, < 3.0)
128
- shoulda-context (1.2.1)
129
- shoulda-matchers (2.8.0)
130
- activesupport (>= 3.0.0)
131
- simplecov (0.12.0)
132
- docile (~> 1.1.0)
133
- json (>= 1.8, < 3)
134
- simplecov-html (~> 0.10.0)
135
- simplecov-html (0.10.0)
136
- slop (3.6.0)
137
- sysexits (1.2.0)
138
- thor (0.19.1)
139
- thread_safe (0.3.5)
140
- tilt (2.0.5)
141
- timecop (0.8.1)
142
- tzinfo (1.2.2)
143
- thread_safe (~> 0.1)
144
- unicode-display_width (1.1.0)
145
- virtus (1.0.5)
146
- axiom-types (~> 0.1)
147
- coercible (~> 1.0)
148
- descendants_tracker (~> 0.0, >= 0.0.3)
149
- equalizer (~> 0.0, >= 0.0.9)
150
- yard (0.9.5)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-support (3.10.2)
27
+ simplecov (0.21.2)
28
+ docile (~> 1.1)
29
+ simplecov-html (~> 0.11)
30
+ simplecov_json_formatter (~> 0.1)
31
+ simplecov-html (0.12.3)
32
+ simplecov_json_formatter (0.1.2)
151
33
 
152
34
  PLATFORMS
153
- ruby
35
+ x86_64-linux
154
36
 
155
37
  DEPENDENCIES
156
38
  envlogic!
157
- polishgeeks-dev-tools
39
+ rake
40
+ rspec
41
+ simplecov
158
42
 
159
43
  BUNDLED WITH
160
- 1.12.5
44
+ 2.2.16
File without changes
data/README.md CHANGED
@@ -1,21 +1,22 @@
1
1
  # Envlogic
2
2
 
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)
3
+ [![Build Status](https://github.com/karafka/envlogic/workflows/ci/badge.svg)](https://github.com/karafka/envlogic/actions?query=workflow%3Aci)
5
4
  [![Gem Version](https://badge.fury.io/rb/envlogic.svg)](http://badge.fury.io/rb/envlogic)
6
- [![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
+ [![Join the chat at https://gitter.im/karafka/karafka](https://badges.gitter.im/karafka/karafka.svg)](https://gitter.im/karafka/karafka)
7
6
 
8
7
  Envlogic is a library used to manage environments for your Ruby application in a similar to Rails.env way.
9
8
 
10
9
  ## Installation
11
10
 
12
- Add gem to your Gemfile
11
+ Add the gem to your Gemfile
13
12
  ```ruby
14
13
  gem 'envlogic'
15
14
  ```
16
15
 
17
16
  ## Usage
18
17
 
18
+ ### On a class/module level
19
+
19
20
  Extend your class or module in which you want to use this library with **Envlogic** module.
20
21
 
21
22
  ```ruby
@@ -36,11 +37,34 @@ Once you extend your class/module with it, you will have two additional methods
36
37
  ExampleModule.env.production? # => false
37
38
  ```
38
39
 
40
+ ### On a per instance basis
41
+
42
+ Include the **Envlogic** module in the class for which instances you want to use it.
43
+
44
+ ```ruby
45
+ class ExampleClass
46
+ include Envlogic
47
+ # code of this class
48
+ end
49
+ ```
50
+
51
+ Once you include it in your class, you will have two additional methods (with two aliases):
52
+
53
+ - *.env* (.environment) - obtain current env and work with it
54
+ - *.env=* (.environment=) - set your own environment
55
+
56
+ ```ruby
57
+ instance = ExampleClass.new
58
+ instance.env = 'development'
59
+ instance.env.development? # => true
60
+ instance.env.production? # => false
61
+ ```
62
+
39
63
  ### ENV variables key names and default fallbacks
40
64
 
41
65
  #### Application root directory env key name
42
66
 
43
- By default gem is looking for ENV variable that is based on your application root directory.
67
+ By default, the gem is looking for ENV variable that is based on your application root directory.
44
68
 
45
69
  For example, if your application lies in */home/deploy/my_app* it will look for **MY_APP_ENV** variable.
46
70
 
@@ -87,24 +111,15 @@ Basic::Karafka.env.development? # => true
87
111
  ## References
88
112
 
89
113
  * [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
- * [Envlogic Travis CI](https://travis-ci.org/karafka/envlogic)
95
- * [Envlogic Code Climate](https://codeclimate.com/github/karafka/envlogic)
114
+ * [Envlogic Actions CI](https://github.com/karafka/envlogic/actions?query=workflow%3Aci)
115
+ * [Envlogic Coditsu](https://app.coditsu.io/karafka/repositories/envlogic)
96
116
 
97
- ## Note on Patches/Pull Requests
117
+ ## Note on contributions
98
118
 
99
- Fork the project.
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.
119
+ First, thank you for considering contributing to Envlogic! It's people like you that make the open source community such a great community!
103
120
 
104
- Each pull request must pass our quality requirements. To check if everything is as it should be, we use [PolishGeeks Dev Tools](https://github.com/polishgeeks/polishgeeks-dev-tools) that combine multiple linters and code analyzers. Please run:
121
+ Each pull request must pass all the RSpec specs and meet our quality requirements.
105
122
 
106
- ```bash
107
- bundle exec rake
108
- ```
123
+ 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.
109
124
 
110
- to check if everything is in order. After that you can submit a pull request.
125
+ 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.
data/Rakefile CHANGED
@@ -1,18 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'rake'
4
- require 'polishgeeks-dev-tools'
5
-
6
- PolishGeeks::DevTools.setup do |config|
7
- config.brakeman = false
8
- config.haml_lint = false
9
- end
6
+ require 'rspec/core/rake_task'
10
7
 
11
- desc 'Self check using polishgeeks-dev-tools'
12
- task :check do
13
- PolishGeeks::DevTools::Runner.new.execute(
14
- PolishGeeks::DevTools::Logger.new
15
- )
16
- end
8
+ RSpec::Core::RakeTask.new(:spec)
17
9
 
18
- task default: :check
10
+ task default: :spec
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhtYWNp
3
+ ZWovREM9bWVuc2ZlbGQvREM9cGwwHhcNMjAwODExMDkxNTM3WhcNMjEwODExMDkx
4
+ NTM3WjAjMSEwHwYDVQQDDBhtYWNpZWovREM9bWVuc2ZlbGQvREM9cGwwggGiMA0G
5
+ CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDCpXsCgmINb6lHBXXBdyrgsBPSxC4/
6
+ 2H+weJ6L9CruTiv2+2/ZkQGtnLcDgrD14rdLIHK7t0o3EKYlDT5GhD/XUVhI15JE
7
+ N7IqnPUgexe1fbZArwQ51afxz2AmPQN2BkB2oeQHXxnSWUGMhvcEZpfbxCCJH26w
8
+ hS0Ccsma8yxA6hSlGVhFVDuCr7c2L1di6cK2CtIDpfDaWqnVNJEwBYHIxrCoWK5g
9
+ sIGekVt/admS9gRhIMaIBg+Mshth5/DEyWO2QjteTodItlxfTctrfmiAl8X8T5JP
10
+ VXeLp5SSOJ5JXE80nShMJp3RFnGw5fqjX/ffjtISYh78/By4xF3a25HdWH9+qO2Z
11
+ tx0wSGc9/4gqNM0APQnjN/4YXrGZ4IeSjtE+OrrX07l0TiyikzSLFOkZCAp8oBJi
12
+ Fhlosz8xQDJf7mhNxOaZziqASzp/hJTU/tuDKl5+ql2icnMv5iV/i6SlmvU29QNg
13
+ LCV71pUv0pWzN+OZbHZKWepGhEQ3cG9MwvkCAwEAAaN3MHUwCQYDVR0TBAIwADAL
14
+ BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFImGed2AXS070ohfRidiCEhXEUN+MB0GA1Ud
15
+ EQQWMBSBEm1hY2llakBtZW5zZmVsZC5wbDAdBgNVHRIEFjAUgRJtYWNpZWpAbWVu
16
+ c2ZlbGQucGwwDQYJKoZIhvcNAQELBQADggGBAKiHpwoENVrMi94V1zD4o8/6G3AU
17
+ gWz4udkPYHTZLUy3dLznc/sNjdkJFWT3E6NKYq7c60EpJ0m0vAEg5+F5pmNOsvD3
18
+ 2pXLj9kisEeYhR516HwXAvtngboUcb75skqvBCU++4Pu7BRAPjO1/ihLSBexbwSS
19
+ fF+J5OWNuyHHCQp+kGPLtXJe2yUYyvSWDj3I2//Vk0VhNOIlaCS1+5/P3ZJThOtm
20
+ zJUBI7h3HgovwRpcnmk2mXTmU4Zx/bCzX8EA6VY0khEvnmiq7S6eBF0H9qH8KyQ6
21
+ EkVLpvmUDFcf/uNaBQdazEMB5jYtwoA8gQlANETNGPi51KlkukhKgaIEDMkBDJOx
22
+ 65N7DzmkcyY0/GwjIVIxmRhcrCt1YeCUElmfFx0iida1/YRm6sB2AXqScc1+ECRi
23
+ 2DND//YJUikn1zwbz1kT70XmHd97B4Eytpln7K+M1u2g1pHVEPW4owD/ammXNpUy
24
+ nt70FcDD4yxJQ+0YNiHd0N8IcVBM1TMIVctMNQ==
25
+ -----END CERTIFICATE-----
data/envlogic.gemspec CHANGED
@@ -1,24 +1,30 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
 
4
6
  require 'envlogic/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = 'envlogic'
8
- spec.platform = Gem::Platform::RUBY
9
- spec.version = Envlogic::VERSION
10
- spec.authors = ['pavlo_vavruk', 'Maciej Mensfeld']
11
- spec.email = %w( pavlo.vavruk@gmail.com maciej@mensfeld.pl )
9
+ spec.name = 'envlogic'
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.version = Envlogic::VERSION
12
+ spec.authors = ['pavlo_vavruk', 'Maciej Mensfeld']
13
+ spec.email = %w[pavlo.vavruk@gmail.com maciej@mensfeld.pl]
14
+ spec.summary = 'Library which allows to set and get environments values'
15
+ spec.description = 'Library used to manage environments for your Ruby application'
16
+ spec.homepage = 'https://github.com/karafka/envlogic'
17
+ spec.license = 'MIT'
12
18
 
13
- spec.summary = %q{ Ruby based library which allows to set and get environments values
14
- and easily check environment }
15
- spec.description = %q{ Library used to manage environments for your Ruby application }
16
- spec.homepage = 'https://github.com/karafka/envlogic'
19
+ spec.add_dependency 'dry-inflector', '~> 0.1'
20
+ spec.required_ruby_version = '>= 2.5.0'
17
21
 
18
- spec.add_dependency 'activesupport'
19
- spec.required_ruby_version = '>= 2.2.0'
22
+ if $PROGRAM_NAME.end_with?('gem')
23
+ spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
24
+ end
20
25
 
26
+ spec.cert_chain = %w[certs/mensfeld.pem]
21
27
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
22
28
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
- spec.require_paths = %w( lib )
29
+ spec.require_paths = %w[lib]
24
30
  end
data/lib/envlogic.rb CHANGED
@@ -1,21 +1,33 @@
1
- %w(
2
- active_support/inflector
3
- active_support/string_inquirer
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ dry/inflector
4
5
  envlogic/version
5
- envlogic/string_refinements
6
6
  envlogic/env
7
- ).each { |lib| require lib }
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 env support
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
- # RandomClass.env #=> Envlogic::Env instance
17
- # RandomClass.env.production? #=> false
18
- # RandomClass.env.development? #=> true
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 backword compatibility with some code that uses full names
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
@@ -1,35 +1,51 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Main module
3
4
  module Envlogic
4
5
  # Env module to get and set environment
5
- class Env < ActiveSupport::StringInquirer
6
- using StringRefinements
7
-
6
+ class Env < String
8
7
  # What environment key should be used by default
9
8
  FALLBACK_ENV_KEY = 'RACK_ENV'
10
- # What default environment should be asumed when there's nothing else
9
+ # What default environment should be assumed when there's nothing else
11
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
12
20
 
13
21
  # @param klass [Class, Module] class/module for which we want to build a Envlogic::Env object
14
22
  # @return [Envlogic::Env] envlogic env object]
23
+ # @note Will load appropriate environment automatically
15
24
  # @example
16
25
  # Envlogic::Env.new(User)
17
- # @note Will load appropriate environment automatically
18
26
  def initialize(klass)
19
- env = ENV[app_dir_name.to_env_key]
20
- env ||= ENV[klass.to_s.to_env_key]
27
+ super('')
28
+
29
+ env = ENV[to_env_key(app_dir_name)]
30
+ env ||= ENV[to_env_key(klass.to_s)]
21
31
  env ||= ENV[FALLBACK_ENV_KEY]
22
32
 
23
33
  update(env || FALLBACK_ENV)
24
34
  end
25
35
 
26
- # @param environment [String] new environment that we want to set
27
- # @example
28
- # env.update('production')
29
- def update(environment)
30
- replace(
31
- ActiveSupport::StringInquirer.new(environment)
32
- )
36
+ # @param method_name [String] method name
37
+ # @param include_private [Boolean] should we include private methods as well
38
+ # @return [Boolean] true if we respond to a given missing method, otherwise false
39
+ def respond_to_missing?(method_name, include_private = false)
40
+ (method_name[-1] == '?') || super
41
+ end
42
+
43
+ # Reacts to missing methods, from which some might be the env checks.
44
+ # If the method ends with '?' we assume, that it is an env check
45
+ # @param method_name [String] method name for missing or env name with question mark
46
+ # @param arguments [Array] any arguments that we pass to the method
47
+ def method_missing(method_name, *arguments)
48
+ method_name[-1] == '?' ? self == method_name[0..-2] : super
33
49
  end
34
50
 
35
51
  private
@@ -44,5 +60,15 @@ module Envlogic
44
60
  .basename
45
61
  .to_s
46
62
  end
63
+
64
+ # Converts any string into a bash ENV key
65
+ # @param string [String] string we want to convert into an env key
66
+ # @return [String] converted name that can be an ENV key
67
+ def to_env_key(string)
68
+ INFLECTOR
69
+ .underscore(string)
70
+ .tr('/', '_')
71
+ .upcase + ENV_KEY_POSTFIX
72
+ end
47
73
  end
48
74
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Main module to encapsulate logic
3
4
  module Envlogic
4
5
  # Current version of gem
5
- VERSION = '1.0.3'
6
+ VERSION = '1.1.3'
6
7
  end
metadata CHANGED
@@ -1,31 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.3
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
- date: 2016-07-28 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhtYWNp
15
+ ZWovREM9bWVuc2ZlbGQvREM9cGwwHhcNMjAwODExMDkxNTM3WhcNMjEwODExMDkx
16
+ NTM3WjAjMSEwHwYDVQQDDBhtYWNpZWovREM9bWVuc2ZlbGQvREM9cGwwggGiMA0G
17
+ CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDCpXsCgmINb6lHBXXBdyrgsBPSxC4/
18
+ 2H+weJ6L9CruTiv2+2/ZkQGtnLcDgrD14rdLIHK7t0o3EKYlDT5GhD/XUVhI15JE
19
+ N7IqnPUgexe1fbZArwQ51afxz2AmPQN2BkB2oeQHXxnSWUGMhvcEZpfbxCCJH26w
20
+ hS0Ccsma8yxA6hSlGVhFVDuCr7c2L1di6cK2CtIDpfDaWqnVNJEwBYHIxrCoWK5g
21
+ sIGekVt/admS9gRhIMaIBg+Mshth5/DEyWO2QjteTodItlxfTctrfmiAl8X8T5JP
22
+ VXeLp5SSOJ5JXE80nShMJp3RFnGw5fqjX/ffjtISYh78/By4xF3a25HdWH9+qO2Z
23
+ tx0wSGc9/4gqNM0APQnjN/4YXrGZ4IeSjtE+OrrX07l0TiyikzSLFOkZCAp8oBJi
24
+ Fhlosz8xQDJf7mhNxOaZziqASzp/hJTU/tuDKl5+ql2icnMv5iV/i6SlmvU29QNg
25
+ LCV71pUv0pWzN+OZbHZKWepGhEQ3cG9MwvkCAwEAAaN3MHUwCQYDVR0TBAIwADAL
26
+ BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFImGed2AXS070ohfRidiCEhXEUN+MB0GA1Ud
27
+ EQQWMBSBEm1hY2llakBtZW5zZmVsZC5wbDAdBgNVHRIEFjAUgRJtYWNpZWpAbWVu
28
+ c2ZlbGQucGwwDQYJKoZIhvcNAQELBQADggGBAKiHpwoENVrMi94V1zD4o8/6G3AU
29
+ gWz4udkPYHTZLUy3dLznc/sNjdkJFWT3E6NKYq7c60EpJ0m0vAEg5+F5pmNOsvD3
30
+ 2pXLj9kisEeYhR516HwXAvtngboUcb75skqvBCU++4Pu7BRAPjO1/ihLSBexbwSS
31
+ fF+J5OWNuyHHCQp+kGPLtXJe2yUYyvSWDj3I2//Vk0VhNOIlaCS1+5/P3ZJThOtm
32
+ zJUBI7h3HgovwRpcnmk2mXTmU4Zx/bCzX8EA6VY0khEvnmiq7S6eBF0H9qH8KyQ6
33
+ EkVLpvmUDFcf/uNaBQdazEMB5jYtwoA8gQlANETNGPi51KlkukhKgaIEDMkBDJOx
34
+ 65N7DzmkcyY0/GwjIVIxmRhcrCt1YeCUElmfFx0iida1/YRm6sB2AXqScc1+ECRi
35
+ 2DND//YJUikn1zwbz1kT70XmHd97B4Eytpln7K+M1u2g1pHVEPW4owD/ammXNpUy
36
+ nt70FcDD4yxJQ+0YNiHd0N8IcVBM1TMIVctMNQ==
37
+ -----END CERTIFICATE-----
38
+ date: 2021-04-21 00:00:00.000000000 Z
13
39
  dependencies:
14
40
  - !ruby/object:Gem::Dependency
15
- name: activesupport
41
+ name: dry-inflector
16
42
  requirement: !ruby/object:Gem::Requirement
17
43
  requirements:
18
- - - ">="
44
+ - - "~>"
19
45
  - !ruby/object:Gem::Version
20
- version: '0'
46
+ version: '0.1'
21
47
  type: :runtime
22
48
  prerelease: false
23
49
  version_requirements: !ruby/object:Gem::Requirement
24
50
  requirements:
25
- - - ">="
51
+ - - "~>"
26
52
  - !ruby/object:Gem::Version
27
- version: '0'
28
- description: " Library used to manage environments for your Ruby application "
53
+ version: '0.1'
54
+ description: Library used to manage environments for your Ruby application
29
55
  email:
30
56
  - pavlo.vavruk@gmail.com
31
57
  - maciej@mensfeld.pl
@@ -33,23 +59,28 @@ executables: []
33
59
  extensions: []
34
60
  extra_rdoc_files: []
35
61
  files:
62
+ - ".coditsu/ci.yml"
63
+ - ".diffend.yml"
64
+ - ".github/FUNDING.yml"
65
+ - ".github/workflows/ci.yml"
36
66
  - ".gitignore"
67
+ - ".rspec"
37
68
  - ".ruby-gemset"
38
69
  - ".ruby-version"
39
- - ".travis.yml"
40
70
  - CHANGELOG.md
41
71
  - Gemfile
42
72
  - Gemfile.lock
43
- - MIT-LICENCE
73
+ - MIT-LICENSE
44
74
  - README.md
45
75
  - Rakefile
76
+ - certs/mensfeld.pem
46
77
  - envlogic.gemspec
47
78
  - lib/envlogic.rb
48
79
  - lib/envlogic/env.rb
49
- - lib/envlogic/string_refinements.rb
50
80
  - lib/envlogic/version.rb
51
81
  homepage: https://github.com/karafka/envlogic
52
- licenses: []
82
+ licenses:
83
+ - MIT
53
84
  metadata: {}
54
85
  post_install_message:
55
86
  rdoc_options: []
@@ -59,17 +90,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
90
  requirements:
60
91
  - - ">="
61
92
  - !ruby/object:Gem::Version
62
- version: 2.2.0
93
+ version: 2.5.0
63
94
  required_rubygems_version: !ruby/object:Gem::Requirement
64
95
  requirements:
65
96
  - - ">="
66
97
  - !ruby/object:Gem::Version
67
98
  version: '0'
68
99
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 2.5.1
100
+ rubygems_version: 3.2.15
71
101
  signing_key:
72
102
  specification_version: 4
73
- summary: Ruby based library which allows to set and get environments values and easily
74
- check environment
103
+ summary: Library which allows to set and get environments values
75
104
  test_files: []
metadata.gz.sig ADDED
Binary file
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.7
4
- - 2.2.2
5
- - 2.2.3
6
- - 2.3.0
7
- script:
8
- - bundle exec rake
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
- module Envlogic
3
- # String refinements used in this library
4
- module StringRefinements
5
- # Postfix for ENV keys
6
- ENV_KEY_POSTFIX = '_ENV'
7
-
8
- refine String do
9
- # Converts any string into a bash ENV key
10
- def to_env_key
11
- underscore
12
- .tr('/', '_')
13
- .upcase + Envlogic::StringRefinements::ENV_KEY_POSTFIX
14
- end
15
- end
16
- end
17
- end