Module: Merb::Virtuozzo
- Defined in:
- lib/merb_virtuozzo/merb_virtuozzo.rb
Class Method Summary collapse
-
.config ⇒ Object
Parses the configuration file converting keys to symbols and stores values to Merb::Plugins.config.
-
.config_file ⇒ Object
Returns the expected location of a deployment configuration file.
-
.config_options(config = {}) ⇒ Object
Extract and merge default values from configuration options.
-
.connect ⇒ Object
Establishes connection or logs errors returning the connection on success.
-
.connection ⇒ Object
Singleton method for accessing an established connection session.
-
.copy_sample_config ⇒ Object
Copies the template for the sample configuration file into the application’s config folder.
-
.sample_dest ⇒ Object
Returnes the expected location of a sample configuration file.
-
.sample_source ⇒ Object
Returnes the location of the template for a sample configuration file.
Class Method Details
.config ⇒ Object
Parses the configuration file converting keys to symbols and stores values to Merb::Plugins.config.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 26 def config @config ||= begin # Convert string keys to symbols full_config = Erubis.load_yaml_file(config_file) config = (Merb::Plugins.config[:virtuozzo] = {}) (full_config[Merb.environment.to_sym] || full_config[Merb.environment] || full_config[:development]).each do |key, value| config[key.to_sym] = value end config end end |
.config_file ⇒ Object
Returns the expected location of a deployment configuration file.
6 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 6 def config_file() Merb.root / "config" / "virtuozzo.yml" end |
.config_options(config = {}) ⇒ Object
Extract and merge default values from configuration options.
40 41 42 43 44 45 46 47 48 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 40 def (config = {}) = {} [:host] = (config[:host] || "https://localhost:4646") [:username] = (config[:username] || config[:user] || "") [:password] = config[:password] || "" end |
.connect ⇒ Object
Establishes connection or logs errors returning the connection on success.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 59 def connect if File.exists?(config_file) Merb.logger.info!("Connecting to the Virtuozzo Agent at '#{config[:host]}' ...") o = (config) = [ o[:host], o[:username], o[:password], o.except(:host, :username, :password) ] @connection = ::Virtuozzo::SOAP::Connection.new(*) Merb.logger.error!("Connection Error: #{e}") unless @connection connection else copy_sample_config Merb.logger.set_log(STDERR) Merb.logger.error! "No virtuozzo.yml file found in #{Merb.root}/config." Merb.logger.error! "A sample file was created called config/virtuozzo.yml.sample for you to copy and edit." exit(1) end end |
.connection ⇒ Object
Singleton method for accessing an established connection session.
52 53 54 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 52 def connection @connection ||= connect end |
.copy_sample_config ⇒ Object
Copies the template for the sample configuration file into the application’s config folder.
19 20 21 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 19 def copy_sample_config FileUtils.cp sample_source, sample_dest unless File.exists?(sample_dest) end |
.sample_dest ⇒ Object
Returnes the expected location of a sample configuration file.
10 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 10 def sample_dest() Merb.root / "config" / "virtuozzo.yml.sample" end |
.sample_source ⇒ Object
Returnes the location of the template for a sample configuration file.
14 |
# File 'lib/merb_virtuozzo/merb_virtuozzo.rb', line 14 def sample_source() File.dirname(__FILE__) / "virtuozzo.yml.sample" end |