liferay_database_config_reader 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +25 -0
- data/Rakefile +17 -0
- data/VERSION +1 -0
- data/lib/liferay_database_config_reader.rb +40 -0
- metadata +101 -0
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= Liferay Database Config Reader
|
2
|
+
|
3
|
+
== Setup
|
4
|
+
jgem install liferay_database_config_reader
|
5
|
+
|
6
|
+
Add the gem dependency in config/warble.rb
|
7
|
+
config.gems << 'liferay_database_config_reader'
|
8
|
+
|
9
|
+
Create a preinitializer.rb in config/ if you do not have one, after add the snippet below
|
10
|
+
if RUBY_PLATFORM =~ /java/ and ENV['RAILS_ENV'] == 'production'
|
11
|
+
require 'rubygems'
|
12
|
+
require 'liferay_database_config_reader'
|
13
|
+
LiferayDatabaseConfigReader.init!
|
14
|
+
end
|
15
|
+
|
16
|
+
Change you config/database.yml
|
17
|
+
<% l = LiferayDatabaseConfigReader.attr %>
|
18
|
+
production:
|
19
|
+
adapter: <%= l[:adapter] %>
|
20
|
+
database: <%= l[:database] %>
|
21
|
+
username: <%= l[:username] %>
|
22
|
+
password: <%= l[:password] %>
|
23
|
+
encoding: unicode
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "liferay_database_config_reader"
|
5
|
+
gemspec.summary = "Allow the rails portlet app to read and configure database with liferay portal-ext.properties"
|
6
|
+
gemspec.description = "Allow the rails portlet app to read and configure database with liferay portal-ext.properties"
|
7
|
+
gemspec.email = "ornelas.tulio@gmail.com"
|
8
|
+
gemspec.homepage = "http://github.com/tulios/liferay_database_config_reader"
|
9
|
+
gemspec.authors = ["Túlio Ornelas"]
|
10
|
+
gemspec.test_files = Dir.glob('spec/*_spec.rb')
|
11
|
+
gemspec.add_development_dependency "rspec", ">= 2.0.1"
|
12
|
+
gemspec.add_development_dependency "rspec-core", ">= 2.0.1"
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
17
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'java'
|
2
|
+
java_import java.util.Properties
|
3
|
+
java_import java.io.FileInputStream
|
4
|
+
|
5
|
+
module LiferayDatabaseConfigReader
|
6
|
+
|
7
|
+
@@properties ||= {}
|
8
|
+
|
9
|
+
CATALINA_HOME = java.lang.System.getProperty('catalina.home')
|
10
|
+
PROPERTIES_EXT_FILE = 'portal-ext.properties'
|
11
|
+
WEB_INF_CLASSES = CATALINA_HOME + '/webapps/ROOT/WEB-INF/classes/'
|
12
|
+
|
13
|
+
def self.init!
|
14
|
+
path = File.expand_path(WEB_INF_CLASSES + PROPERTIES_EXT_FILE)
|
15
|
+
|
16
|
+
puts "\n[LiferayDatabaseReader] :: RAILS_ENV=#{ENV['RAILS_ENV']}"
|
17
|
+
puts "[LiferayDatabaseReader] :: reading #{path}"
|
18
|
+
|
19
|
+
properties = Properties.new
|
20
|
+
properties.load(FileInputStream.new(path))
|
21
|
+
url = properties.getProperty("jdbc.default.url")
|
22
|
+
|
23
|
+
@@properties[:username] = properties.getProperty("jdbc.default.username")
|
24
|
+
@@properties[:password] = properties.getProperty("jdbc.default.password")
|
25
|
+
|
26
|
+
fragments = url.split /\/+/
|
27
|
+
raise "Fail to check adapter, host and database in liferay config file" if fragments.nil? or fragments.size < 3
|
28
|
+
|
29
|
+
@@properties[:adapter] = fragments[0].gsub(':', '')
|
30
|
+
@@properties[:host], @@properties[:port] = fragments[1].split(':')
|
31
|
+
@@properties[:database] = fragments[2]
|
32
|
+
|
33
|
+
puts "[LiferayDatabaseReader] :: adapter: #{attr[:adapter]}, host: #{attr[:host]}:#{attr[:port]}, database: #{attr[:database]}\n\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.attr; @@properties end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'liferay_database_config_reader'
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liferay_database_config_reader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "T\xC3\xBAlio Ornelas"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-09 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 1
|
34
|
+
version: 2.0.1
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec-core
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 13
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 1
|
50
|
+
version: 2.0.1
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Allow the rails portlet app to read and configure database with liferay portal-ext.properties
|
54
|
+
email: ornelas.tulio@gmail.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.rdoc
|
61
|
+
files:
|
62
|
+
- README.rdoc
|
63
|
+
- Rakefile
|
64
|
+
- VERSION
|
65
|
+
- lib/liferay_database_config_reader.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/tulios/liferay_database_config_reader
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Allow the rails portlet app to read and configure database with liferay portal-ext.properties
|
100
|
+
test_files: []
|
101
|
+
|