rails-app_env 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 14e75a290a83ff554c4a22d5b4de442f067335f7520bf32cac50e1cca8402587
4
+ data.tar.gz: 1ce34786cc77f55066f68999286290fea50ebdb77ca4067657ca9e56f378bd8d
5
+ SHA512:
6
+ metadata.gz: bec82722ff90a2fcb647e0c705793f19568b4105bb9c8b1d7836c139e6aca334a77902d74ff5166f1db057c0906c677a517214b5a66c68dc6bed4be1730bc173
7
+ data.tar.gz: 9cf5d2d52dbe36a1dc98c83239fcfe0a49dfd3f6425b94dd480514e441eb5d15ac466370494f7d0b50afac09ebc3a91d0732ab9f15c200d8de604b7da0235276
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Typist Tech Limited
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.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Rails::AppEnv
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "rails-app_env"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install rails-app_env
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ module Rails
2
+ module AppEnv
3
+ module Credentials
4
+ class << self
5
+ def content_path
6
+ path = Rails.root.join("config/credentials/#{Rails.app_env}.yml.enc")
7
+ path = Rails.root.join("config/credentials.yml.enc") unless path.exist?
8
+ path
9
+ end
10
+
11
+ def key_path
12
+ path = Rails.root.join("config/credentials/#{Rails.app_env}.key")
13
+ path = Rails.root.join("config/master.key") unless path.exist?
14
+ path
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module Rails
2
+ module AppEnv
3
+ class EnvironmentInquirer < ActiveSupport::EnvironmentInquirer
4
+ # Optimization for the two extra Heroku pipeline stages, so this inquirer doesn't need to rely on
5
+ # the slower delegation through method_missing that StringInquirer would normally entail.
6
+ DEFAULT_ENVIRONMENTS = %w[staging review]
7
+
8
+ def initialize(env)
9
+ super
10
+
11
+ DEFAULT_ENVIRONMENTS.each do |default|
12
+ instance_variable_set :"@#{default}", env == default
13
+ end
14
+ end
15
+
16
+ DEFAULT_ENVIRONMENTS.each do |env|
17
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
18
+ def #{env}?
19
+ @#{env}
20
+ end
21
+ RUBY
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ module Rails
2
+ module AppEnv
3
+ module Helpers
4
+ def app_env
5
+ return Rails.env if ENV["APP_ENV"].blank?
6
+
7
+ @_app_env ||= EnvironmentInquirer.new(ENV["APP_ENV"])
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module Rails
2
+ module AppEnv
3
+ class Railtie < Rails::Railtie
4
+ config.before_configuration do
5
+ Rails.extend(Helpers)
6
+ end
7
+
8
+ config.before_configuration do |app|
9
+ app.config.credentials.content_path = Rails::AppEnv::Credentials.content_path
10
+ app.config.credentials.key_path = Rails::AppEnv::Credentials.key_path
11
+ end
12
+
13
+ config.after_initialize do
14
+ Rails::Info.property "Application environment" do
15
+ Rails.app_env
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module AppEnv
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "app_env/version"
2
+ require_relative "app_env/environment_inquirer"
3
+ require_relative "app_env/helpers"
4
+ require_relative "app_env/credentials"
5
+ require_relative "app_env/railtie"
6
+
7
+ module Rails
8
+ module AppEnv
9
+ # Your code goes here...
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_app_env do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-app_env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Typist Tech Limited
8
+ - Tang Rufus
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 8.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 8.0.2
27
+ email:
28
+ - opensource+swagger_ui_standalone@typist.tech
29
+ - tangrufus@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/rails/app_env.rb
38
+ - lib/rails/app_env/credentials.rb
39
+ - lib/rails/app_env/environment_inquirer.rb
40
+ - lib/rails/app_env/helpers.rb
41
+ - lib/rails/app_env/railtie.rb
42
+ - lib/rails/app_env/version.rb
43
+ - lib/tasks/rails/app_env_tasks.rake
44
+ homepage: https://github.com/typisttech/rails-app_env
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/typisttech/rails-app_env
49
+ source_code_uri: https://github.com/typisttech/rails-app_env
50
+ changelog_uri: https://github.com/typisttech/rails-app_env/releases
51
+ bug_tracker_uri: https://github.com/typisttech/rails-app_env/issues
52
+ funding_uri: https://github.com/sponsors/tangrufus
53
+ rubygems_mfa_required: 'true'
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.6.7
69
+ specification_version: 4
70
+ summary: Summary of Rails::AppEnv.
71
+ test_files: []