Class: SdbDal::Configuration
- Inherits:
-
Object
- Object
- SdbDal::Configuration
- Defined in:
- lib/sdb_dal/configuration.rb
Instance Attribute Summary collapse
-
#append_table_to_domain ⇒ Object
readonly
Returns the value of attribute append_table_to_domain.
-
#aws_key_id ⇒ Object
readonly
Returns the value of attribute aws_key_id.
-
#aws_secret_key ⇒ Object
readonly
Returns the value of attribute aws_secret_key.
-
#cipher_iv_file ⇒ Object
readonly
Returns the value of attribute cipher_iv_file.
-
#cipher_key_file ⇒ Object
readonly
Returns the value of attribute cipher_key_file.
-
#clob_bucket ⇒ Object
readonly
Returns the value of attribute clob_bucket.
-
#domain_prefix ⇒ Object
readonly
Returns the value of attribute domain_prefix.
-
#fail_fast ⇒ Object
readonly
Returns the value of attribute fail_fast.
-
#memcache_servers ⇒ Object
readonly
Returns the value of attribute memcache_servers.
-
#repository_class ⇒ Object
readonly
Returns the value of attribute repository_class.
Class Method Summary collapse
Instance Method Summary collapse
- #cipher_iv ⇒ Object
- #cipher_key ⇒ Object
- #crypto ⇒ Object
- #find_config_section ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sdb_dal/configuration.rb', line 24 def initialize() sdb_dal_config=find_config_section if sdb_dal_config if sdb_dal_config.has_key?("repository_class") @repository_class=eval sdb_dal_config["repository_class"] else @repository_class=SdbDal::Repository end @domain_prefix= sdb_dal_config["sdb_domain_prefix"] || "" @clob_bucket= sdb_dal_config["s3_clob_bucket"] @aws_key_id = sdb_dal_config["aws_key_id"] @aws_secret_key = sdb_dal_config["aws_secret_key"] @memcache_servers= sdb_dal_config['memcache_servers'] @memcache_servers = memcache_servers.split(",") if memcache_servers @append_table_to_domain=sdb_dal_config['append_table_to_domain'] @fail_fast=sdb_dal_config['fail_fast'] @cipher_key_file = sdb_dal_config['cipher_key_file'] @cipher_key_file ||= "./.cipher_key" if @cipher_key_file and File.exists?(@cipher_key_file) @cipher_key=File.open(@cipher_key_file).read end @cipher_iv_file ||= "./cipher_iv" @cipher_iv_file=sdb_dal_config['cipher_iv_file'] if @cipher_iv_file and File.exists?(@cipher_iv_file) @cipher_iv=File.open(@cipher_iv_file).read end end end |
Instance Attribute Details
#append_table_to_domain ⇒ Object (readonly)
Returns the value of attribute append_table_to_domain.
13 14 15 |
# File 'lib/sdb_dal/configuration.rb', line 13 def append_table_to_domain @append_table_to_domain end |
#aws_key_id ⇒ Object (readonly)
Returns the value of attribute aws_key_id.
10 11 12 |
# File 'lib/sdb_dal/configuration.rb', line 10 def aws_key_id @aws_key_id end |
#aws_secret_key ⇒ Object (readonly)
Returns the value of attribute aws_secret_key.
11 12 13 |
# File 'lib/sdb_dal/configuration.rb', line 11 def aws_secret_key @aws_secret_key end |
#cipher_iv_file ⇒ Object (readonly)
Returns the value of attribute cipher_iv_file.
17 18 19 |
# File 'lib/sdb_dal/configuration.rb', line 17 def cipher_iv_file @cipher_iv_file end |
#cipher_key_file ⇒ Object (readonly)
Returns the value of attribute cipher_key_file.
16 17 18 |
# File 'lib/sdb_dal/configuration.rb', line 16 def cipher_key_file @cipher_key_file end |
#clob_bucket ⇒ Object (readonly)
Returns the value of attribute clob_bucket.
9 10 11 |
# File 'lib/sdb_dal/configuration.rb', line 9 def clob_bucket @clob_bucket end |
#domain_prefix ⇒ Object (readonly)
Returns the value of attribute domain_prefix.
8 9 10 |
# File 'lib/sdb_dal/configuration.rb', line 8 def domain_prefix @domain_prefix end |
#fail_fast ⇒ Object (readonly)
Returns the value of attribute fail_fast.
14 15 16 |
# File 'lib/sdb_dal/configuration.rb', line 14 def fail_fast @fail_fast end |
#memcache_servers ⇒ Object (readonly)
Returns the value of attribute memcache_servers.
12 13 14 |
# File 'lib/sdb_dal/configuration.rb', line 12 def memcache_servers @memcache_servers end |
#repository_class ⇒ Object (readonly)
Returns the value of attribute repository_class.
7 8 9 |
# File 'lib/sdb_dal/configuration.rb', line 7 def repository_class @repository_class end |
Class Method Details
.singleton ⇒ Object
19 20 21 22 |
# File 'lib/sdb_dal/configuration.rb', line 19 def self.singleton @singleton ||= SdbDal::Configuration.new return @singleton end |
Instance Method Details
#cipher_iv ⇒ Object
74 75 76 |
# File 'lib/sdb_dal/configuration.rb', line 74 def cipher_iv return @cipher_iv end |
#cipher_key ⇒ Object
70 71 72 |
# File 'lib/sdb_dal/configuration.rb', line 70 def cipher_key return @cipher_key end |
#crypto ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sdb_dal/configuration.rb', line 57 def crypto return @crypto if @crypto ={} if cipher_key [:cipher_key=]= cipher_key [:cipher_iv ]= cipher_iv @crypto=Crypto.new() else @crypto=Crypto.new File.open(self.cipher_key_file,'w').write(@crypto.key) File.open(self.cipher_iv_file,'w').write(@crypto.iv) end end |
#find_config_section ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sdb_dal/configuration.rb', line 78 def find_config_section return $sdb_dal_config if $sdb_dal_config config_file_path=nil config_section=nil #when using rails use config/database.yml if Object.const_defined?(:RAILS_ROOT) and ENV.has_key?('RAILS_ENV') config_file_path = File.join("#{RAILS_ROOT}","config","database.yml") config_section =ENV['RAILS_ENV']+"_sdb_dal" else #when not using rails use try database.yml then try config/database.yml if File.exists?("database.yml") config_file_path = "database.yml" elsif File.exists?(File.join("config", "database.yml")) config_file_path = File.join("config", "database.yml") end config_section =(ENV['SDB_DAL_ENV'] || "production")+"_sdb_dal" end if config_file_path and config_section config_file = YAML.load(File.open( config_file_path)) $sdb_dal_config = config_file[config_section] end return $sdb_dal_config end |