oci8_simple 0.8.5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.rdoc +5 -4
- data/VERSION +1 -1
- data/lib/oci8_simple/client.rb +2 -14
- data/lib/oci8_simple/config.rb +43 -0
- data/lib/oci8_simple.rb +1 -0
- data/oci8_simple.gemspec +1 -0
- metadata +5 -4
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -21,10 +21,11 @@ You can also use oci8_simple in your Ruby scripts by creating an instance of <co
|
|
21
21
|
gem install oci8_simple
|
22
22
|
|
23
23
|
== Configuration
|
24
|
-
|
25
|
-
database.yml
|
26
|
-
|
27
|
-
|
24
|
+
Oci8Simple will look in three places for your database configuration, in the following order:
|
25
|
+
* Dir.pwd + database.yml
|
26
|
+
* Dir.pwd + config/database.yml
|
27
|
+
* ~/.oci8_simple/database.yml
|
28
|
+
The database.yml format is compatible with the Rails format.
|
28
29
|
development:
|
29
30
|
database: oracle.hostname:1521/sid
|
30
31
|
username: foo_dev
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/oci8_simple/client.rb
CHANGED
@@ -36,7 +36,7 @@ module Oci8Simple
|
|
36
36
|
# SQL
|
37
37
|
class Client
|
38
38
|
USER_DIR = File.join(ENV["HOME"], ".oci8_simple")
|
39
|
-
|
39
|
+
CONFIG = Config.new
|
40
40
|
LOG_FILE = File.join(USER_DIR, "oci8_simple.log")
|
41
41
|
|
42
42
|
attr_accessor :log_file, :env
|
@@ -97,17 +97,7 @@ module Oci8Simple
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def config
|
100
|
-
@config ||=
|
101
|
-
rescue Errno::ENOENT => e
|
102
|
-
raise ConfigError.new <<-ERR
|
103
|
-
File #{CONFIG_FILE} doesn't exist - use the following template:
|
104
|
-
|
105
|
-
environment:
|
106
|
-
database: 192.168.1.3:1521/sid
|
107
|
-
username: foo_user
|
108
|
-
password: foobar
|
109
|
-
|
110
|
-
ERR
|
100
|
+
@config ||= CONFIG[ env]
|
111
101
|
end
|
112
102
|
|
113
103
|
# Create and return raw Oci8 connection
|
@@ -117,8 +107,6 @@ ERR
|
|
117
107
|
|
118
108
|
private
|
119
109
|
|
120
|
-
|
121
|
-
|
122
110
|
def new_connection
|
123
111
|
c = OCI8.new(config["username"], config["password"], config["database"])
|
124
112
|
c.autocommit = true
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Oci8Simple
|
2
|
+
##
|
3
|
+
# Config will look in three places for your database.yml file. Here is the order:
|
4
|
+
# Dir.pwd + database.yml
|
5
|
+
# Dir.pwd + config/database.yml
|
6
|
+
# ~/.oci8_simple/database.yml
|
7
|
+
#
|
8
|
+
class Config
|
9
|
+
USER_DIR = File.join(ENV["HOME"], ".oci8_simple")
|
10
|
+
|
11
|
+
def [](key)
|
12
|
+
@raw_config[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
load_yaml
|
17
|
+
end
|
18
|
+
|
19
|
+
def database_yaml_path
|
20
|
+
path = File.join(Dir.pwd, "database.yml")
|
21
|
+
return path if File.exists?(path)
|
22
|
+
path = File.join(Dir.pwd, "config", "database.yml")
|
23
|
+
return path if File.exists?(path)
|
24
|
+
File.join(USER_DIR, "database.yml")
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_yaml
|
28
|
+
begin
|
29
|
+
@raw_config = YAML.load_file(database_yaml_path)
|
30
|
+
rescue Errno::ENOENT => e
|
31
|
+
raise ConfigError.new <<-ERR
|
32
|
+
File #{CONFIG_FILE} doesn't exist - use the following template:
|
33
|
+
|
34
|
+
environment:
|
35
|
+
database: 192.168.1.3:1521/sid
|
36
|
+
username: foo_user
|
37
|
+
password: foobar
|
38
|
+
|
39
|
+
ERR
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/oci8_simple.rb
CHANGED
data/oci8_simple.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oci8_simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-oci8
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/oci8_simple/cli.rb
|
55
55
|
- lib/oci8_simple/client.rb
|
56
56
|
- lib/oci8_simple/command.rb
|
57
|
+
- lib/oci8_simple/config.rb
|
57
58
|
- lib/oci8_simple/describe.rb
|
58
59
|
- lib/oci8_simple/show.rb
|
59
60
|
- oci8_simple.gemspec
|
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
78
|
version: '0'
|
78
79
|
segments:
|
79
80
|
- 0
|
80
|
-
hash: -
|
81
|
+
hash: -178540163749839115
|
81
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
83
|
none: false
|
83
84
|
requirements:
|
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
87
|
version: '0'
|
87
88
|
segments:
|
88
89
|
- 0
|
89
|
-
hash: -
|
90
|
+
hash: -178540163749839115
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
93
|
rubygems_version: 1.8.25
|