Class: Conf
Class Attribute Summary collapse
-
.app_env ⇒ Object
Returns the value of attribute app_env.
-
.app_libs ⇒ Object
readonly
Returns the value of attribute app_libs.
-
.app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
.app_root ⇒ Object
readonly
Returns the value of attribute app_root.
-
.app_started ⇒ Object
readonly
Returns the value of attribute app_started.
-
.app_ver ⇒ Object
readonly
Returns the value of attribute app_ver.
-
.files ⇒ Object
readonly
Returns the value of attribute files.
-
.host ⇒ Object
readonly
Returns the value of attribute host.
-
.pidfile ⇒ Object
readonly
Returns the value of attribute pidfile.
-
.spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
-
.at(*path) ⇒ Object
Direct access to any depth.
- .dump ⇒ Object
- .init(app_root = nil) ⇒ Object
- .newrelic_enabled? ⇒ Boolean
- .prepare(args = {}) ⇒ Object
- .reload! ⇒ Object
Class Attribute Details
.app_env ⇒ Object
Returns the value of attribute app_env.
16 17 18 |
# File 'lib/pushyd/conf.rb', line 16 def app_env @app_env end |
.app_libs ⇒ Object (readonly)
Returns the value of attribute app_libs.
19 20 21 |
# File 'lib/pushyd/conf.rb', line 19 def app_libs @app_libs end |
.app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
21 22 23 |
# File 'lib/pushyd/conf.rb', line 21 def app_name @app_name end |
.app_root ⇒ Object (readonly)
Returns the value of attribute app_root.
18 19 20 |
# File 'lib/pushyd/conf.rb', line 18 def app_root @app_root end |
.app_started ⇒ Object (readonly)
Returns the value of attribute app_started.
23 24 25 |
# File 'lib/pushyd/conf.rb', line 23 def app_started @app_started end |
.app_ver ⇒ Object (readonly)
Returns the value of attribute app_ver.
22 23 24 |
# File 'lib/pushyd/conf.rb', line 22 def app_ver @app_ver end |
.files ⇒ Object (readonly)
Returns the value of attribute files.
26 27 28 |
# File 'lib/pushyd/conf.rb', line 26 def files @files end |
.host ⇒ Object (readonly)
Returns the value of attribute host.
27 28 29 |
# File 'lib/pushyd/conf.rb', line 27 def host @host end |
.pidfile ⇒ Object (readonly)
Returns the value of attribute pidfile.
28 29 30 |
# File 'lib/pushyd/conf.rb', line 28 def pidfile @pidfile end |
.spec ⇒ Object (readonly)
Returns the value of attribute spec.
25 26 27 |
# File 'lib/pushyd/conf.rb', line 25 def spec @spec end |
Class Method Details
.at(*path) ⇒ Object
Direct access to any depth
91 92 93 |
# File 'lib/pushyd/conf.rb', line 91 def self.at *path path.reduce(Conf) { |m, key| m && m[key.to_s] } end |
.dump ⇒ Object
86 87 88 |
# File 'lib/pushyd/conf.rb', line 86 def self.dump to_hash.to_yaml(indent: 4, useheader: true, useversion: false ) end |
.init(app_root = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pushyd/conf.rb', line 32 def self.init app_root = nil # Defaults, hostname @files = [] @app_env = "production" @app_started = Time.now @host = `hostname`.to_s.chomp.split(".").first # Grab app root @app_root = File.( File.dirname(__FILE__) + "/../../") @app_libs = File.( File.dirname(__FILE__) ) # Try to find any gemspec file matches = Dir["#{@app_root}/*.gemspec"] fail ConfigMissingGemspec, "gemspec file not found: #{gemspec_path}" if matches.size < 1 fail ConfigMultipleGemspec, "gemspec file not found: #{gemspec_path}" if matches.size > 1 # Load Gemspec (just the only match) @spec = Gem::Specification::load(matches.first) @app_name = @spec.name @app_ver = @spec.version fail ConfigMissingParameter, "gemspec: missing name" unless @app_name fail ConfigMissingParameter, "gemspec: missing version" unless @app_ver # Add config files add_default_config add_etc_config end |
.newrelic_enabled? ⇒ Boolean
95 96 97 |
# File 'lib/pushyd/conf.rb', line 95 def self.newrelic_enabled? !!self[:newrelic] end |
.prepare(args = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pushyd/conf.rb', line 60 def self.prepare args = {} # Add extra config file add_extra_config args[:config] # Load configuration files load_files # Init New Relic prepare_newrelic self[:newrelic], self.at(:logs, :newrelic) # Prepare PID file is not present prepare_pidfile # Try to access any key to force parsing of the files self[:dummy] rescue Psych::SyntaxError => e fail ConfigParseError, e. rescue StandardError => e fail ConfigOtherError, "#{e.message} \n #{e.backtrace.to_yaml}" end |
.reload! ⇒ Object
82 83 84 |
# File 'lib/pushyd/conf.rb', line 82 def self.reload! load_files end |