Class: AdapterHelper::Base
- Inherits:
-
Object
- Object
- AdapterHelper::Base
show all
- Defined in:
- lib/adapter_helper/base.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.adapter ⇒ Object
Returns the value of attribute adapter.
4
5
6
|
# File 'lib/adapter_helper/base.rb', line 4
def adapter
@adapter
end
|
Class Method Details
.error_msg_adapter_helper ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/adapter_helper/base.rb', line 43
def error_msg_adapter_helper
"Adapter Setup Helper:\n To run \#{adapter} tests, you need to setup your \#{adapter} connections.\n In your local/database_connections.rb file, within the ENV['cpk_adapter'] hash, add:\n\"\#{adapter}\" => { adapter settings }\n\n That is, it will look like:\n ENV['cpk_adapters'] = {\n\"\#{adapter}\" => {\n :adapter => \"\#{adapter}\",\n :username => \"root\",\n :password => \"root\",\n # ...\n}\n }.to_yaml\n EOS\nend\n"
|
.error_msg_setup_helper ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/adapter_helper/base.rb', line 22
def error_msg_setup_helper
"Setup Helper:\n CPK now has a place for your individual testing configuration.\n That is, instead of hardcoding it in the Rakefile and test/connections files,\n there is now a local/database_connections.rb file that is NOT in the\n repository. Your personal DB information (username, password etc) can\n be stored here without making it difficult to submit patches etc.\n\nInstallation:\n i) cp locals/database_connections.rb.sample locals/database_connections.rb\n ii) For \#{adapter} connection details see \"Adapter Setup Helper\" below.\n iii) Rerun this task\n \n\#{error_msg_adapter_helper}\n \nCurrent ENV:\n \#{ENV.inspect}\n EOS\nend\n"
|
.load_connection_from_env(adapter) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/adapter_helper/base.rb', line 6
def load_connection_from_env(adapter)
self.adapter = adapter
unless ENV['cpk_adapters']
puts error_msg_setup_helper
exit
end
ActiveRecord::Base.configurations = YAML.load(ENV['cpk_adapters'])
unless spec = ActiveRecord::Base.configurations[adapter]
puts error_msg_adapter_helper
exit
end
spec[:adapter] = adapter
spec
end
|