rails_app_version 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: b88a327da8016755f2d83c27196a5a397727b65a84352fb1bc66f86902e44fca
4
+ data.tar.gz: 40025876dbfb8327aa5aca6cc0ff0601af7232f557e1daff581d78b6523e80b6
5
+ SHA512:
6
+ metadata.gz: 7a37e92c5cd0de896b0d82fe248e158a5faa4247aac81e0795b67660899acb80924143a446a34917c154034ad19de96d66b468825b9f49ce088d53fa40ed57bf
7
+ data.tar.gz: f9ab9e0958f3587eebe3e7cb56359bb39c21ca1d10a0135d92ad673e6271483eeb23db81dfd1e424c017efe3bcb9f388b97539080a42797bc0f198e577019d97
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # RailsAppVersion
2
+
3
+ RailsAppVersion is a Ruby on Rails engine designed to easily manage and access your application's version and environment information. It allows for a seamless integration of versioning within your Rails application, providing a straightforward way to access the current application version and environment without hardcoding these values.
4
+
5
+ ## Usage
6
+ How to use my plugin.
7
+
8
+ ## Installation
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "rails_app_version"
13
+ ```
14
+
15
+ And then execute:
16
+ ```bash
17
+ $ bundle
18
+ ```
19
+
20
+ ## Usage:
21
+ After adding the gem, you can access the application version and environment information anywhere in your Rails application.
22
+ ```ruby
23
+ Rails.application.version # => "1.0.0"
24
+ Rails.application.environment # => "staging"
25
+ ```
26
+
27
+ ## Features
28
+ - Easy Configuration: Set up your application version and environment in a simple YAML file.
29
+ - Automatic Integration: The engine automatically integrates with your Rails application, making the version and environment information accessible.
30
+ - Flexible Usage: Access the application version and environment information anywhere in your Rails application.
31
+
32
+ ## Contributing
33
+ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
34
+ 1. Fork the repo
35
+ 2. Create your feature branch (git checkout -b my-new-feature)
36
+ 3. Commit your changes (git commit -am 'Add some feature')
37
+ 4. Push to the branch (git push origin my-new-feature)
38
+ 5. Create a new Pull Request
39
+
40
+ ## License
41
+ 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,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
5
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAppVersion
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_app_version/version'
4
+
5
+ module RailsAppVersion
6
+ class Engine < ::Rails::Engine
7
+ attr_reader :app_config, :version, :environment
8
+
9
+ initializer 'fetch_config' do |app|
10
+ @app_config = begin
11
+ app.config_for(:app_version)
12
+ rescue RuntimeError
13
+ # Load the default configuration from the gem, if the app does not have one
14
+ require 'erb'
15
+ yaml = Engine.root.join('config', 'app_version.yml')
16
+ all_configs = ActiveSupport::ConfigurationFile.parse(yaml).deep_symbolize_keys
17
+ all_configs[:shared]
18
+ end
19
+
20
+ @version = @app_config[:version]
21
+ @environment = @app_config[:environment] || Rails.env
22
+ end
23
+ initializer 'patch_application' do |app|
24
+ # Inject the module into the application
25
+ app.class.send(:include, RailsAppVersion::AppVersion)
26
+ app.class.send(:include, RailsAppVersion::AppEnvironment)
27
+ end
28
+ end
29
+
30
+ module AppVersion
31
+ extend ActiveSupport::Concern
32
+
33
+ included do
34
+ def version
35
+ @version ||= railties.find do |railtie|
36
+ railtie.is_a?(RailsAppVersion::Engine)
37
+ end.version
38
+ end
39
+ end
40
+ end
41
+
42
+ module AppEnvironment
43
+ extend ActiveSupport::Concern
44
+
45
+ included do
46
+ def environment
47
+ @environment ||= railties.find do |railtie|
48
+ railtie.is_a?(RailsAppVersion::Engine)
49
+ end.environment
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_app_version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Abdelkader Boudih
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ description: Get the version of your Rails app
28
+ email:
29
+ - terminale@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - Rakefile
36
+ - lib/rails_app_version.rb
37
+ - lib/rails_app_version/version.rb
38
+ homepage: https://github.com/seuros/rails_app_version
39
+ licenses: []
40
+ metadata:
41
+ homepage_uri: https://github.com/seuros/rails_app_version
42
+ source_code_uri: https://github.com/seuros/rails_app_version
43
+ changelog_uri: https://github.com/seuros/rails_app_version/blob/master/CHANGELOG.md
44
+ rubygems_mfa_required: 'true'
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.5.11
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Get the version of your Rails app
64
+ test_files: []