liferay_database_config_reader 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,12 +14,13 @@ Create a preinitializer.rb in config/ if you do not have one, after add the snip
14
14
  end
15
15
 
16
16
  Change you config/database.yml
17
- <% l = LiferayDatabaseConfigReader.attr %>
17
+ <% if RUBY_PLATFORM =~ /java/ and ENV['RAILS_ENV'] == 'production' %>
18
18
  production:
19
- adapter: <%= l[:adapter] %>
20
- database: <%= l[:database] %>
21
- username: <%= l[:username] %>
22
- password: <%= l[:password] %>
19
+ adapter: <%= LiferayDatabaseConfigReader.attr[:adapter] %>
20
+ database: <%= LiferayDatabaseConfigReader.attr[:database] %>
21
+ username: <%= LiferayDatabaseConfigReader.attr[:username] %>
22
+ password: <%= LiferayDatabaseConfigReader.attr[:password] %>
23
23
  encoding: unicode
24
24
  pool: 5
25
25
  timeout: 5000
26
+ <% end %>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -6,15 +6,13 @@ module LiferayDatabaseConfigReader
6
6
 
7
7
  @@properties ||= {}
8
8
 
9
- CATALINA_HOME = java.lang.System.getProperty('catalina.home')
9
+ CATALINA_HOME = java.lang.System.getProperty('catalina.home') || ''
10
10
  PROPERTIES_EXT_FILE = 'portal-ext.properties'
11
11
  WEB_INF_CLASSES = CATALINA_HOME + '/webapps/ROOT/WEB-INF/classes/'
12
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}"
13
+ def self.init! path = File.expand_path(WEB_INF_CLASSES + PROPERTIES_EXT_FILE)
14
+ log "RAILS_ENV=#{ENV['RAILS_ENV']}"
15
+ log "reading #{path}"
18
16
 
19
17
  properties = Properties.new
20
18
  properties.load(FileInputStream.new(path))
@@ -30,11 +28,44 @@ module LiferayDatabaseConfigReader
30
28
  @@properties[:host], @@properties[:port] = fragments[1].split(':')
31
29
  @@properties[:database] = fragments[2]
32
30
 
33
- puts "[LiferayDatabaseReader] :: adapter: #{attr[:adapter]}, host: #{attr[:host]}:#{attr[:port]}, database: #{attr[:database]}\n\n"
31
+ log "adapter: #{attr[:adapter]}, host: #{attr[:host]}:#{attr[:port]}, database: #{attr[:database]}\n"
34
32
  end
35
33
 
36
34
  def self.attr; @@properties end
35
+
36
+ def self.log msg
37
+ msg = "[LiferayDatabaseReader] :: #{msg}"
38
+ (defined? RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER.info(msg) : STDOUT.puts(msg)
39
+ end
37
40
 
38
41
  end
39
42
 
40
- require 'liferay_database_config_reader'
43
+ require 'liferay_database_config_reader'
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'liferay_database_config_reader'
3
+
4
+ describe LiferayDatabaseConfigReader do
5
+
6
+ before :each do
7
+ @properties_file_path = File.expand_path(File.dirname(__FILE__) + '/../resources/portal-ext.properties')
8
+ end
9
+
10
+ it 'should load portal-ext properties' do
11
+ LiferayDatabaseConfigReader.init! @properties_file_path
12
+ att = LiferayDatabaseConfigReader.attr
13
+ att.should_not be_nil
14
+ att[:username].should == 'postgres'
15
+ att[:password].should == 'postgres'
16
+ att[:adapter].should == 'jdbcpostgresql'
17
+ att[:host].should == 'localhost'
18
+ att[:port].should == '5432'
19
+ att[:database].should == 'liferay6'
20
+ end
21
+
22
+ end
@@ -0,0 +1,6 @@
1
+ #PostgreSQL
2
+ #
3
+ jdbc.default.driverClassName=org.postgresql.Driver
4
+ jdbc.default.url=jdbc:postgresql://localhost:5432/liferay6
5
+ jdbc.default.username=postgres
6
+ jdbc.default.password=postgres
@@ -0,0 +1 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liferay_database_config_reader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "T\xC3\xBAlio Ornelas"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-09 00:00:00 -02:00
18
+ date: 2010-11-16 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,9 @@ files:
63
63
  - Rakefile
64
64
  - VERSION
65
65
  - lib/liferay_database_config_reader.rb
66
+ - spec/lib/liferay_database_config_reader_spec.rb
67
+ - spec/resources/portal-ext.properties
68
+ - spec/spec_helper.rb
66
69
  has_rdoc: true
67
70
  homepage: http://github.com/tulios/liferay_database_config_reader
68
71
  licenses: []