dotenv-missing_variable_notifier 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f2dd3c13da01e1884a717b6a00b408f627c1abf529146c91cc5d5b41b9eb310f
4
+ data.tar.gz: 14644cd592db0088ef9e1685af95ecfd7e195b422c8ea84bceb538b58628b236
5
+ SHA512:
6
+ metadata.gz: 6d05e3c1b13894d7535392c0826afb10f4cda411cac736d466ceda51b864e6c7c3c729f919be304e70a42c2d9b06b575e4d57fec55d4cc33d829933de043e54c
7
+ data.tar.gz: cdc27a149dd64bef3d7496fa14fd903103bac14c360b0bcf59073350a6f8306e6f92b0453745deaa489b72f876f87dc13e673bebae67e28d5ec527d47abd101a
@@ -0,0 +1,3 @@
1
+ /.ruby-gemset
2
+ /Gemfile.lock
3
+ /*.gem
@@ -0,0 +1 @@
1
+ 2.7.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Glen Crawford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # dotenv-missing_variable_notifier
2
+
3
+ dotenv-missing_variable_notifier is a tiny (literally 6 lines of code) extension for [dotenv](https://github.com/bkeepers/dotenv) to notify you if your development environment is missing any environment variables listed in the example dotenv file in your Rails application. This is useful for projects that use an example file for their environment variables (usually `.env.template` or `.env.example`), which is most projects that use dotenv. Now you won't need to check for new environment variables after you do a `git pull`!
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your Gemfile _after_ `dotenv-rails`.
8
+
9
+ ```ruby
10
+ group :development, :test do
11
+ gem 'dotenv-rails'
12
+ gem 'dotenv-missing_variable_notifier', '~> 1.0'
13
+ end
14
+ ```
15
+
16
+ And then install:
17
+
18
+ ```
19
+ bundle install
20
+ ```
21
+
22
+ ### Load order
23
+
24
+ `dotenv-missing_variable_notifier` is basically a tiny [Railtie](https://api.rubyonrails.org/classes/Rails/Railtie.html) that runs in a `before_configuration` callback while your application is booting. If it runs before dotenv does then it will complain that _every_ environment variable is missing, and it would be right! This means that you _must_ list `dotenv-missing_variable_notifier` in your Gemfile after `dotenv-rails`.
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/GlenCrawford/dotenv-missing_variable_notifier.
29
+
30
+ ## Acknowledgements
31
+
32
+ A huge thanks to the author(s) of [dotenv](https://github.com/bkeepers/dotenv) for their amazing gem.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'dotenv/missing_variable_notifier/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'dotenv-missing_variable_notifier'
7
+ spec.version = Dotenv::MissingVariableNotifier::VERSION
8
+ spec.authors = ['Glen Crawford']
9
+
10
+ spec.summary = 'Tiny extension for dotenv to notify you if you are missing any environment variables listed in your example file.'
11
+ spec.homepage = 'https://github.com/GlenCrawford/dotenv-missing_variable_notifier'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
+ `git ls-files -z`.split("\x0").reject { |file| file.match(%r{^(spec)/}) }
16
+ end
17
+
18
+ spec.require_paths = ['lib']
19
+
20
+ # Runtime versions deliberately left unspecified.
21
+ spec.add_runtime_dependency 'dotenv-rails'
22
+ spec.add_runtime_dependency 'railties'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 2.1'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.9'
27
+ end
@@ -0,0 +1,4 @@
1
+ if defined?(Rails) && defined?(Dotenv) && Rails.env.development?
2
+ require 'dotenv/missing_variable_notifier/railtie'
3
+ require 'dotenv/missing_variable_notifier/core'
4
+ end
@@ -0,0 +1,19 @@
1
+ module Dotenv
2
+ module MissingVariableNotifier
3
+ class MissingEnvironmentVariableError < StandardError; end
4
+
5
+ class Core
6
+ def self.check_for_missing_environment_variables!
7
+ example_file = ['.env.template', '.env.example'].detect { |example_file| Rails.root.join(example_file).exist? }
8
+ return unless example_file
9
+
10
+ example_file_contents = File.open(Rails.root.join(example_file), 'rb:bom|utf-8', &:read)
11
+ example_file_variables = Dotenv::Parser.call(example_file_contents, false) # Thank you dotenv <3
12
+ missing_variables = example_file_variables.keys.reject { |variable| ENV.has_key?(variable) }
13
+ if missing_variables.any?
14
+ raise MissingEnvironmentVariableError, "There are environment variables in your dotenv template file that are not set in your development environment: #{missing_variables.join(', ')}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Dotenv
2
+ module MissingVariableNotifier
3
+ class Railtie < Rails::Railtie
4
+ config.before_configuration { Dotenv::MissingVariableNotifier::Core.check_for_missing_environment_variables! }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Dotenv
2
+ module MissingVariableNotifier
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dotenv-missing_variable_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Glen Crawford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv-rails
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ description:
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".gitignore"
90
+ - ".ruby-version"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - dotenv-missing_variable_notifier.gemspec
96
+ - lib/dotenv-missing_variable_notifier.rb
97
+ - lib/dotenv/missing_variable_notifier/core.rb
98
+ - lib/dotenv/missing_variable_notifier/railtie.rb
99
+ - lib/dotenv/missing_variable_notifier/version.rb
100
+ homepage: https://github.com/GlenCrawford/dotenv-missing_variable_notifier
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.1.4
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Tiny extension for dotenv to notify you if you are missing any environment
123
+ variables listed in your example file.
124
+ test_files: []