merb_virtuozzo 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +10 -0
- data/README.rdoc +32 -0
- data/Rakefile +17 -0
- data/lib/virtuozzo.rb +17 -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/merb_virtuozzo.gemspec +40 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/virtuozzo_spec.rb +7 -0
- metadata +100 -0
data/Manifest
ADDED
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,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'echoe'
|
3
|
+
require 'merb-core'
|
4
|
+
require 'merb-core/tasks/merb'
|
5
|
+
|
6
|
+
Echoe.new('merb_virtuozzo', '0.1.2') 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.project = "virtuozzo"
|
12
|
+
p.ignore_pattern = ["tmp/*, script/*"]
|
13
|
+
p.development_dependencies = ["echoe"]
|
14
|
+
p.runtime_dependencies = ["merb >=1.0", "virtuozzo >=0.5.0"]
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
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,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
|
@@ -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.2"
|
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{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,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_virtuozzo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
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 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: virtuozzo
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: echoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Merb plugin for working with Virtuozzo.
|
46
|
+
email: james@plainprograms.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- lib/virtuozzo/merb_virtuozzo.rb
|
53
|
+
- lib/virtuozzo/merbtasks.rb
|
54
|
+
- lib/virtuozzo/virtuozzo.yml.sample
|
55
|
+
- lib/virtuozzo.rb
|
56
|
+
- README.rdoc
|
57
|
+
files:
|
58
|
+
- lib/virtuozzo/merb_virtuozzo.rb
|
59
|
+
- lib/virtuozzo/merbtasks.rb
|
60
|
+
- lib/virtuozzo/virtuozzo.yml.sample
|
61
|
+
- lib/virtuozzo.rb
|
62
|
+
- Manifest
|
63
|
+
- merb_virtuozzo.gemspec
|
64
|
+
- Rakefile
|
65
|
+
- README.rdoc
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
- spec/virtuozzo_spec.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/plainprograms/merb_virtuozzo
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --line-numbers
|
73
|
+
- --inline-source
|
74
|
+
- --title
|
75
|
+
- Merb_virtuozzo
|
76
|
+
- --main
|
77
|
+
- README.rdoc
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "1.2"
|
91
|
+
version:
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: virtuozzo
|
95
|
+
rubygems_version: 1.3.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 2
|
98
|
+
summary: Merb plugin for working with Virtuozzo.
|
99
|
+
test_files: []
|
100
|
+
|