rails_app_version 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 381e86a1a9a44077393c49d8f813c3ddab906e0672021d5498fac963bf2640b7
4
- data.tar.gz: 5826b91f6d12cd73f08ac4a7a6f987021f0b82303f126e22d5cd608168318ec6
3
+ metadata.gz: ec8b9fb82abafba7d8a6cc3e95b908be05ff5ed00b1150cdc8002bfa65bd1a23
4
+ data.tar.gz: 16aa8846723ac2fe2321139bd125084357fb739cdd23fd86a0955a4ade4eb1ec
5
5
  SHA512:
6
- metadata.gz: e522072844c9469560d3d199b2797cf0d9a494771e6df31fbba1349a4ba21d8b219c31443381080e803808c77df1a26b150886b744a053485131ddc7851d322f
7
- data.tar.gz: 5b1926f667890b37c4e58e52879623338bca9cf9b10c62ff25a2b730a0f0ddbd0cd9075dad7773457bca6d6675e0e9f3cbaf307e41b3788b297074e23f7ad94c
6
+ metadata.gz: a0057f8dbd4ee9e2ab10ff7d0b8f795ede4c4a3b8644cff9a31d4b7683cd6d7451ed01ac22b5aa51f4fd2d80b50545205bd27365059fc428c6c903f77cb5d290
7
+ data.tar.gz: 181f9d0d1def9eeca5c46034ad0848cd1094d0fd4ba9ecd080c2772b331d62e634bd7c2e60b5d01f9bf5696705f58142953bf0110085b42a73bbf85bb1a5734f
data/Rakefile CHANGED
@@ -3,3 +3,8 @@ require "bundler/setup"
3
3
  load "rails/tasks/statistics.rake"
4
4
 
5
5
  require "bundler/gem_tasks"
6
+
7
+ # Load Rakefile of the dummy app
8
+ load "test/dummy/Rakefile"
9
+
10
+ task :default, %i[test]
@@ -2,3 +2,4 @@ shared:
2
2
  version: <%= Rails.root.join('VERSION').read.strip rescue '0.0.0' %>
3
3
  revision: <%= Rails.root.join('REVISION').read.strip rescue (`git rev-parse HEAD`.strip rescue '0') %>
4
4
  show_revision: <%= Rails.env.local? %>
5
+ environment: <%= ENV.fetch('RAILS_APP_ENV', Rails.env) %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAppVersion
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -5,12 +5,34 @@ require "rails/application"
5
5
  require "rails_app_version/version"
6
6
 
7
7
  module RailsAppVersion
8
+ class Version < Gem::Version
9
+ # This method cache used by Rails.cache.fetch to generate a cache key
10
+ def to_cache_key
11
+ (to_s).parameterize
12
+ end
13
+ end
8
14
  class Engine < ::Rails::Engine
9
- attr_reader :app_config, :version, :environment
15
+ attr_reader :app_config, :version, :env
16
+
17
+ rake_tasks do
18
+ namespace :app do
19
+ namespace :version do
20
+ desc "Copy config/app_version.yml to the main app config directory"
21
+ task :config do
22
+ source = RailsAppVersion::Engine.root.join("config", "app_version.yml")
23
+ destination = Rails.root.join("config", "app_version.yml")
24
+
25
+ FileUtils.cp(source, destination)
26
+
27
+ puts "Installed app_version.yml to #{destination}"
28
+ end
29
+ end
30
+ end
31
+ end
10
32
 
11
33
  initializer "fetch_config" do |app|
12
34
  @app_config = begin
13
- app.config_for(:app_version)
35
+ app.config_for(:app_version, env: Rails.env)
14
36
  rescue RuntimeError
15
37
  # Load the default configuration from the gem, if the app does not have one
16
38
  require "erb"
@@ -19,8 +41,8 @@ module RailsAppVersion
19
41
  all_configs[:shared]
20
42
  end
21
43
 
22
- @version = @app_config[:version]
23
- @environment = @app_config[:environment] || Rails.env
44
+ @version = Version.new(@app_config[:version])
45
+ @env = ActiveSupport::StringInquirer.new(@app_config[:environment] || Rails.env)
24
46
  end
25
47
  end
26
48
 
@@ -40,15 +62,14 @@ module RailsAppVersion
40
62
  extend ActiveSupport::Concern
41
63
 
42
64
  included do
43
- def environment
44
- @environment ||= railties.find do |railtie|
65
+ def env
66
+ @env ||= railties.find do |railtie|
45
67
  railtie.is_a?(RailsAppVersion::Engine)
46
- end.environment
68
+ end.env
47
69
  end
48
70
  end
49
71
  end
50
72
  end
51
73
 
52
-
53
74
  Rails::Application.include RailsAppVersion::AppVersion
54
75
  Rails::Application.include RailsAppVersion::AppEnvironment
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_app_version
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Get the version of your Rails app
28
42
  email:
29
43
  - terminale@gmail.com