Skip to content

Commit 78400b2

Browse files
author
Joselito Tapangan
committed
Add method that will reload the initialize env_details once the rails is fully loaded.
1 parent e68523e commit 78400b2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ After you install stackify-api-ruby you need to run the generator:
3636

3737
The generator creates a file 'config/initializers/stackify.rb' configuring stackify-api-ruby with your API key. You can change default settings there.
3838

39+
In your 'config/initializers/stackify.rb' file don't forget to add 'Stackify::EnvDetails.instance.set_rails_info'
40+
3941
### Non-Rails
4042

4143
For using stackify-api-ruby gem within any Ruby application add to top of your main file:

lib/stackify/env_details.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ class EnvDetails
1111

1212

1313
def initialize
14+
@info = { 'Application root' => Dir.pwd, 'Environment' => 'development'}
15+
@request_details = {}
16+
@app_name = app_name
17+
app_location = Stackify.configuration.app_location || @info['Application root']
18+
@details = {
19+
'DeviceName' => Socket.gethostname,
20+
'AppLocation' => app_location,
21+
'AppName' => @app_name,
22+
'ConfiguredAppName' => @app_name,
23+
'ConfiguredEnvironmentName' =>@info['Environment']
24+
}
25+
end
26+
27+
def set_rails_info
1428
rails_info = defined?(Rails) ? Rails::Info.properties.to_h : nil
1529
@info = rails_info || { 'Application root' => Dir.pwd, 'Environment' => 'development'}
1630
@request_details = {}

0 commit comments

Comments
 (0)