Class: PushyDaemon::Conf
- Inherits:
-
Object
- Object
- PushyDaemon::Conf
- Extended by:
- Chamber
- Defined in:
- lib/pushyd/conf.rb
Class Attribute Summary collapse
-
.env ⇒ Object
readonly
Returns the value of attribute env.
-
.files ⇒ Object
readonly
Returns the value of attribute files.
-
.host ⇒ Object
readonly
Returns the value of attribute host.
-
.name ⇒ Object
readonly
Returns the value of attribute name.
-
.spec ⇒ Object
readonly
Returns the value of attribute spec.
-
.version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Class Attribute Details
.env ⇒ Object (readonly)
Returns the value of attribute env.
16 17 18 |
# File 'lib/pushyd/conf.rb', line 16 def env @env end |
.files ⇒ Object (readonly)
Returns the value of attribute files.
14 15 16 |
# File 'lib/pushyd/conf.rb', line 14 def files @files end |
.host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/pushyd/conf.rb', line 17 def host @host end |
.name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/pushyd/conf.rb', line 12 def name @name end |
.spec ⇒ Object (readonly)
Returns the value of attribute spec.
13 14 15 |
# File 'lib/pushyd/conf.rb', line 13 def spec @spec end |
.version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/pushyd/conf.rb', line 15 def version @version end |
Class Method Details
.dump ⇒ Object
65 66 67 |
# File 'lib/pushyd/conf.rb', line 65 def self.dump self.to_hash.to_yaml end |
.newrelic_enabled? ⇒ Boolean
69 70 71 |
# File 'lib/pushyd/conf.rb', line 69 def Conf.newrelic_enabled? !!self[:newrelic] end |
.prepare(args = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 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 59 60 61 62 63 |
# File 'lib/pushyd/conf.rb', line 20 def self.prepare args = {} # Context parameters fail PushyDaemon::ConfigMissingParameter, "missing root" unless (@root = args[:root]) fail PushyDaemon::ConfigMissingParameter, "missing env" unless (@env = args[:env]) # Gemspec parameter gemspec_path = "#{args[:root]}/#{args[:gemspec]}.gemspec" fail PushyDaemon::ConfigMissingParameter, "missing gemspec" unless args[:gemspec] fail PushyDaemon::ConfigMissingParameter, "gemspec file not found: #{gemspec_path}" unless File.exist?(gemspec_path) # Init host if missing @host ||= `hostname`.to_s.chomp.split(".").first # Load Gemspec @spec = Gem::Specification::load gemspec_path @name = @spec.name @version = @spec.version fail PushyDaemon::ConfigMissingParameter, "missing name" unless @name # Init Chamber (defaults, etc, cmdline) @files = ["#{args[:root]}/defaults.yml"] @files << File.("/etc/#{@name}.yml") @files << args[:config].to_s if args[:config] # Load configuration files load files: @files, namespaces: { environment: @env } # Override some values self[:log] ||= {} if args[:logfile] self[:log][:file] = args[:logfile].to_s end # Init New Relic prepare_newrelic self[:newrelic] # Try to access any key to force parsing of the files self[:dummy] rescue Psych::SyntaxError => e fail PushyDaemon::ConfigParseError, e. rescue StandardError => e fail PushyDaemon::ConfigOtherError, "#{e.} \n #{e.backtrace.to_yaml}" end |