rails_app_version 0.1.2 → 0.2.1
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 +4 -4
- data/Rakefile +5 -0
- data/config/app_version.yml +1 -0
- data/lib/rails_app_version/version.rb +1 -1
- data/lib/rails_app_version.rb +37 -12
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12fcf73c08d447843831ce2387b14fae8302f8d3ec2c08dd3548e471435c2a1
|
4
|
+
data.tar.gz: 88361140e3a6ac93c378aaf8e38f253864fb2bebc1920b81903fb305c4863631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce3f381f908e7eb51dc36bf82cb0d1f32a521563f93d4c68642cba6f7a6e54a7a460f55333352b0aca4a1348e740f959a08c4333495e20e9e874843edbf2fde6
|
7
|
+
data.tar.gz: f7a240228914ad118252befd33fcaf60647194da681a72360265c7274715d388026e29815c2bdc025c8cc1014aa6c8a6daa9b6f62aaa70fca1cd65b2afb71071
|
data/Rakefile
CHANGED
data/config/app_version.yml
CHANGED
@@ -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) %>
|
data/lib/rails_app_version.rb
CHANGED
@@ -5,22 +5,48 @@ require "rails/application"
|
|
5
5
|
require "rails_app_version/version"
|
6
6
|
|
7
7
|
module RailsAppVersion
|
8
|
-
class
|
9
|
-
|
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
|
14
|
+
class Railtie < ::Rails::Railtie
|
15
|
+
attr_reader :app_config, :version, :env
|
16
|
+
|
17
|
+
def root
|
18
|
+
@root ||= Pathname.new(File.expand_path("..", __dir__))
|
19
|
+
end
|
20
|
+
|
21
|
+
rake_tasks do
|
22
|
+
namespace :app do
|
23
|
+
namespace :version do
|
24
|
+
desc "Copy config/app_version.yml to the main app config directory"
|
25
|
+
task :config do
|
26
|
+
source = RailsAppVersion::Railtie.root.join("config", "app_version.yml")
|
27
|
+
destination = Rails.root.join("config", "app_version.yml")
|
28
|
+
|
29
|
+
FileUtils.cp(source, destination)
|
30
|
+
|
31
|
+
puts "Installed app_version.yml to #{destination}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
10
36
|
|
11
37
|
initializer "fetch_config" do |app|
|
12
38
|
@app_config = begin
|
13
|
-
app.config_for(:app_version)
|
39
|
+
app.config_for(:app_version, env: Rails.env)
|
14
40
|
rescue RuntimeError
|
15
41
|
# Load the default configuration from the gem, if the app does not have one
|
16
42
|
require "erb"
|
17
|
-
yaml =
|
43
|
+
yaml = Railtie.root.join("config", "app_version.yml")
|
18
44
|
all_configs = ActiveSupport::ConfigurationFile.parse(yaml).deep_symbolize_keys
|
19
45
|
all_configs[:shared]
|
20
46
|
end
|
21
47
|
|
22
|
-
@version = @app_config[:version]
|
23
|
-
@
|
48
|
+
@version = Version.new(@app_config[:version])
|
49
|
+
@env = ActiveSupport::StringInquirer.new(@app_config[:environment] || Rails.env)
|
24
50
|
end
|
25
51
|
end
|
26
52
|
|
@@ -30,7 +56,7 @@ module RailsAppVersion
|
|
30
56
|
included do
|
31
57
|
def version
|
32
58
|
@version ||= railties.find do |railtie|
|
33
|
-
railtie.is_a?(RailsAppVersion::
|
59
|
+
railtie.is_a?(RailsAppVersion::Railtie)
|
34
60
|
end.version
|
35
61
|
end
|
36
62
|
end
|
@@ -40,15 +66,14 @@ module RailsAppVersion
|
|
40
66
|
extend ActiveSupport::Concern
|
41
67
|
|
42
68
|
included do
|
43
|
-
def
|
44
|
-
@
|
45
|
-
railtie.is_a?(RailsAppVersion::
|
46
|
-
end.
|
69
|
+
def env
|
70
|
+
@env ||= railties.find do |railtie|
|
71
|
+
railtie.is_a?(RailsAppVersion::Railtie)
|
72
|
+
end.env
|
47
73
|
end
|
48
74
|
end
|
49
75
|
end
|
50
76
|
end
|
51
77
|
|
52
|
-
|
53
78
|
Rails::Application.include RailsAppVersion::AppVersion
|
54
79
|
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
|
4
|
+
version: 0.2.1
|
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-
|
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
|