Class: ActiveXMLService::Base
- Inherits:
-
Object
- Object
- ActiveXMLService::Base
- Defined in:
- lib/xmlservice.rb
Class Method Summary collapse
-
.adapter_factory(config) ⇒ Object
adapter factory (singleton).
-
.configurations ⇒ Object
last configuration (singleton).
- .connection ⇒ Object
-
.establish_configuration(config) ⇒ Object
configuration helper (singleton).
-
.establish_connection(config) ⇒ Object
standard rails connection (singleton).
-
.generate_key ⇒ Object
*NEW encrypted passwords - generate pass key cipher (see ibm_db_password.rb).
-
.generate_password(plaintext, key = "*DEFAULT") ⇒ Object
*NEW encrypted passwords - generate encrypted password (see ibm_db_password.rb) plaintext - password in plain text key - 32 char pass key.
-
.semaphore ⇒ Object
thread level one at a time.
-
.symbolize_keys(config) ⇒ Object
Converts all
config
keys to symbols.
Class Method Details
.adapter_factory(config) ⇒ Object
adapter factory (singleton)
55 56 57 58 59 |
# File 'lib/xmlservice.rb', line 55 def self.adapter_factory(config) config = ActiveXMLService::Base.establish_configuration(config) adapter = XMLServiceAdapters::adapter_factory(config) adapter end |
.configurations ⇒ Object
last configuration (singleton)
51 52 53 |
# File 'lib/xmlservice.rb', line 51 def self.configurations @xml_config end |
.connection ⇒ Object
64 65 66 |
# File 'lib/xmlservice.rb', line 64 def self.connection @xml_adapter end |
.establish_configuration(config) ⇒ Object
configuration helper (singleton)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/xmlservice.rb', line 27 def self.establish_configuration(config) # Converts all +config+ keys to symbols config = ActiveXMLService::Base.symbolize_keys(config) # *NEW test by yaml (see ibm_db_password.rb) if ENV['TEST_YAML'] config[:test_yaml] = ENV['TEST_YAML'] end if ENV['TEST_ENV'] config[:test_env] = ENV['TEST_ENV'] end if config.has_key?(:test_yaml) && config.has_key?(:test_env) require 'password/password' config = XMLSERVICEPassword::Encrypt.parse_yaml(config,config[:test_yaml],config[:test_env]) config = XMLSERVICEPassword::Encrypt.symbolize_keys(config) end # *NEW encrypted passwords - decrypt password or password.yml (see ibm_db_password.rb) if config.has_key?(:pwd_yaml) || config.has_key?(:pwd_enc) require 'password/password' config = XMLSERVICEPassword::Encrypt.parse_user_config(config) end @xml_config = config @xml_config end |
.establish_connection(config) ⇒ Object
standard rails connection (singleton)
61 62 63 |
# File 'lib/xmlservice.rb', line 61 def self.establish_connection(config) @xml_adapter = ActiveXMLService::Base.adapter_factory(config) end |
.generate_key ⇒ Object
*NEW encrypted passwords - generate pass key cipher (see ibm_db_password.rb)
68 69 70 71 72 |
# File 'lib/xmlservice.rb', line 68 def self.generate_key() require 'password/password' key_out = XMLSERVICEPassword::Encrypt.gen_key() key_out end |
.generate_password(plaintext, key = "*DEFAULT") ⇒ Object
*NEW encrypted passwords - generate encrypted password (see ibm_db_password.rb) plaintext - password in plain text key - 32 char pass key
76 77 78 79 80 |
# File 'lib/xmlservice.rb', line 76 def self.generate_password(plaintext, key="*DEFAULT") require 'password/password' pwd_out = XMLSERVICEPassword::Encrypt.gen_password(plaintext, key) pwd_out end |
.semaphore ⇒ Object
thread level one at a time
82 83 84 85 86 87 |
# File 'lib/xmlservice.rb', line 82 def self.semaphore if !(defined? @xml_semaphore) @xml_semaphore = Mutex.new end @xml_semaphore end |
.symbolize_keys(config) ⇒ Object
Converts all config
keys to symbols
17 18 19 20 21 22 23 24 25 |
# File 'lib/xmlservice.rb', line 17 def self.symbolize_keys(config) # config = config.symbolize_keys if config config.keys.each do |key| config[(key.to_sym rescue key) || key] = config.delete(key) end end config end |