plainprograms-merb_virtuozzo 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +32 -0
- data/Rakefile +16 -0
- data/lib/virtuozzo/merb_virtuozzo.rb +76 -0
- data/lib/virtuozzo/merbtasks.rb +3 -0
- data/lib/virtuozzo/virtuozzo.yml.sample +14 -0
- data/lib/virtuozzo.rb +17 -0
- data/merb_virtuozzo.gemspec +40 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/virtuozzo_spec.rb +7 -0
- metadata +97 -0
data/README.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= +merb_virtuozzo+
|
2
|
+
|
3
|
+
by James Thompson
|
4
|
+
http://github.com/plainprograms/virtuozzo
|
5
|
+
|
6
|
+
A plugin for the Merb framework that provides integration with the +virtuozzo+
|
7
|
+
gem.
|
8
|
+
|
9
|
+
== LICENSE
|
10
|
+
|
11
|
+
(The MIT License)
|
12
|
+
|
13
|
+
Copyright (c) 2008 James Thompson <james@plainprograms.com>
|
14
|
+
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
16
|
+
a copy of this software and associated documentation files (the
|
17
|
+
'Software'), to deal in the Software without restriction, including
|
18
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
19
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
20
|
+
permit persons to whom the Software is furnished to do so, subject to
|
21
|
+
the following conditions:
|
22
|
+
|
23
|
+
The above copyright notice and this permission notice shall be
|
24
|
+
included in all copies or substantial portions of the Software.
|
25
|
+
|
26
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
27
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
28
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
29
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
30
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
31
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
32
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'echoe'
|
3
|
+
require 'merb-core'
|
4
|
+
require 'merb-core/tasks/merb'
|
5
|
+
|
6
|
+
Echoe.new('merb_virtuozzo', '0.1.1') do |p|
|
7
|
+
p.description = "Merb plugin for working with Virtuozzo."
|
8
|
+
p.url = "http://github.com/plainprograms/merb_virtuozzo"
|
9
|
+
p.author = "James Thompson"
|
10
|
+
p.email = "james@plainprograms.com"
|
11
|
+
p.ignore_pattern = ["tmp/*, script/*"]
|
12
|
+
p.development_dependencies = ["echoe"]
|
13
|
+
p.runtime_dependencies = ["merb >=1.0", "virtuozzo >=0.5.0"]
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Merb
|
2
|
+
module Virtuozzo
|
3
|
+
class << self
|
4
|
+
##
|
5
|
+
# Returns the expected location of a deployment configuration file.
|
6
|
+
def config_file() Merb.root / "config" / "virtuozzo.yml" end
|
7
|
+
|
8
|
+
##
|
9
|
+
# Returnes the expected location of a sample configuration file.
|
10
|
+
def sample_dest() Merb.root / "config" / "virtuozzo.yml.sample" end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Returnes the location of the template for a sample configuration file.
|
14
|
+
def sample_source() File.dirname(__FILE__) / "virtuozzo.yml.sample" end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Copies the template for the sample configuration file into the
|
18
|
+
# application's config folder.
|
19
|
+
def copy_sample_config
|
20
|
+
FileUtils.cp sample_source, sample_dest unless File.exists?(sample_dest)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Parses the configuration file converting keys to symbols and stores
|
25
|
+
# values to Merb::Plugins.config[:virtuozzo].
|
26
|
+
def config
|
27
|
+
@config ||= begin
|
28
|
+
# Convert string keys to symbols
|
29
|
+
full_config = Erubis.load_yaml_file(config_file)
|
30
|
+
config = (Merb::Plugins.config[:virtuozzo] = {})
|
31
|
+
(full_config[Merb.environment.to_sym] || full_config[Merb.environment] || full_config[:development]).each do |key, value|
|
32
|
+
config[key.to_sym] = value
|
33
|
+
end
|
34
|
+
config
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Extract and merge default values from configuration options.
|
40
|
+
def config_options(config = {})
|
41
|
+
options = {}
|
42
|
+
|
43
|
+
options[:host] = (config[:host] || "https://localhost:4646")
|
44
|
+
options[:username] = (config[:username] || config[:user] || "")
|
45
|
+
options[:password] = config[:password] || ""
|
46
|
+
options[:realm] = config[:realm] || Virtuozzo::DEFAULT_REALM
|
47
|
+
|
48
|
+
options
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Singleton method for accessing an established connection session.
|
53
|
+
def connection
|
54
|
+
@connection ||= connect
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Establishes connection or logs errors returning the connection on
|
59
|
+
# success.
|
60
|
+
def connect
|
61
|
+
if File.exists?(config_file)
|
62
|
+
Merb.logger.info!("Connecting to the '#{config[:database]}' Virtuozzo Agent at '#{config[:host]}' ...")
|
63
|
+
@connection = Virtuozzo::Connection.new(config_options(config))
|
64
|
+
Merb.logger.error!("Connection Error: #{e}") unless @connection
|
65
|
+
connection
|
66
|
+
else
|
67
|
+
copy_sample_config
|
68
|
+
Merb.logger.set_log(STDERR)
|
69
|
+
Merb.logger.error! "No virtuozzo.yml file found in #{Merb.root}/config."
|
70
|
+
Merb.logger.error! "A sample file was created called config/virtuozzo.yml.sample for you to copy and edit."
|
71
|
+
exit(1)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/virtuozzo.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# make sure we're running inside Merb
|
2
|
+
if defined?(Merb::Plugins)
|
3
|
+
dependency 'virtuozzo', '0.5.0'
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__) / "virtuozzo" / "merb_virtuozzo")
|
6
|
+
|
7
|
+
Merb::BootLoader.before_app_loads do
|
8
|
+
# code that can be required before the application loads
|
9
|
+
Merb::Virtuozzo.connect
|
10
|
+
end
|
11
|
+
|
12
|
+
Merb::BootLoader.after_app_loads do
|
13
|
+
# code that can be required after the application loads
|
14
|
+
end
|
15
|
+
|
16
|
+
Merb::Plugins.add_rakefiles "virtuozzo/merbtasks"
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{merb_virtuozzo}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["James Thompson"]
|
9
|
+
s.date = %q{2008-11-14}
|
10
|
+
s.description = %q{Merb plugin for working with Virtuozzo.}
|
11
|
+
s.email = %q{james@plainprograms.com}
|
12
|
+
s.extra_rdoc_files = ["lib/virtuozzo/merb_virtuozzo.rb", "lib/virtuozzo/merbtasks.rb", "lib/virtuozzo/virtuozzo.yml.sample", "lib/virtuozzo.rb", "README.rdoc"]
|
13
|
+
s.files = ["lib/virtuozzo/merb_virtuozzo.rb", "lib/virtuozzo/merbtasks.rb", "lib/virtuozzo/virtuozzo.yml.sample", "lib/virtuozzo.rb", "Manifest", "merb_virtuozzo.gemspec", "Rakefile", "README.rdoc", "spec/spec_helper.rb", "spec/virtuozzo_spec.rb"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/plainprograms/merb_virtuozzo}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Merb_virtuozzo", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{merb_virtuozzo}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Merb plugin for working with Virtuozzo.}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<merb>, [">= 1.0"])
|
28
|
+
s.add_runtime_dependency(%q<virtuozzo>, [">= 0.5.0"])
|
29
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<merb>, [">= 1.0"])
|
32
|
+
s.add_dependency(%q<virtuozzo>, [">= 0.5.0"])
|
33
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
34
|
+
end
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<merb>, [">= 1.0"])
|
37
|
+
s.add_dependency(%q<virtuozzo>, [">= 0.5.0"])
|
38
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plainprograms-merb_virtuozzo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Thompson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-14 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "1.0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: virtuozzo
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.5.0
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: echoe
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
description: Merb plugin for working with Virtuozzo.
|
43
|
+
email: james@plainprograms.com
|
44
|
+
executables: []
|
45
|
+
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
extra_rdoc_files:
|
49
|
+
- lib/virtuozzo/merb_virtuozzo.rb
|
50
|
+
- lib/virtuozzo/merbtasks.rb
|
51
|
+
- lib/virtuozzo/virtuozzo.yml.sample
|
52
|
+
- lib/virtuozzo.rb
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- lib/virtuozzo/merb_virtuozzo.rb
|
56
|
+
- lib/virtuozzo/merbtasks.rb
|
57
|
+
- lib/virtuozzo/virtuozzo.yml.sample
|
58
|
+
- lib/virtuozzo.rb
|
59
|
+
- Manifest
|
60
|
+
- merb_virtuozzo.gemspec
|
61
|
+
- Rakefile
|
62
|
+
- README.rdoc
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
- spec/virtuozzo_spec.rb
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://github.com/plainprograms/merb_virtuozzo
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --line-numbers
|
70
|
+
- --inline-source
|
71
|
+
- --title
|
72
|
+
- Merb_virtuozzo
|
73
|
+
- --main
|
74
|
+
- README.rdoc
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "1.2"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: merb_virtuozzo
|
92
|
+
rubygems_version: 1.2.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: Merb plugin for working with Virtuozzo.
|
96
|
+
test_files: []
|
97
|
+
|