oracle_client_provision 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWZiYzM5YWM1ZDhjN2U2MWQ1YzFkMjc0ZDA4NTFjY2FlOTYyZDMzMQ==
5
+ data.tar.gz: !binary |-
6
+ MWNhM2IxMzFjNzA3ZDA5YjQyM2ZkNWY3NzkzMWQ1ZWU5MzhjNTQyNw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDA4MWM5NDQ0MGQzNjAzMDE4NmM1MzRiZmY0MjM4ZDI4MGI2MDNhMDY1M2Vh
10
+ YjViYzg2NDAwNWY4NWM3NTZkZjM5Mjg5OGUyODc4NzJjMTlkMmRhNmE4MDFk
11
+ ZWI5MjFhZjBlMmQ2NWE3OTc4NjhjZWM0ZGJkNzBkZTMzYmE1MTg=
12
+ data.tar.gz: !binary |-
13
+ NTExOGEwZDBiNDAwMTEzZGY0NjNmNmY4NDFiZTJmYmM1ZGFhMGM2NTQ0YmU5
14
+ MGEyYzM5ZTA5YmJlMTBkNDFhZTk4NzNmOTljOWU4OGY0MDZmYjE5MGEwZTlj
15
+ NGEwODQ0ZDE1YTIxMDAwOTY4ZTRmMWEyMDNiMGVjYTQ3NDUzZGU=
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+ /downloads/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
@@ -0,0 +1 @@
1
+ oracle_client_provision
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Installs oracle ruby-oci8 support" fullCmd="oracle_install" taksId="oracle_install" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="build" taksId="build" /><RakeTask description="" fullCmd="gen" taksId="gen" /><RakeTask description="" fullCmd="install" taksId="install" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeTask description="" fullCmd="uninstall" taksId="uninstall" /></RakeGroup></Settings>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p545 [mutant_examples]" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/oracle_client_provision.iml" filepath="$PROJECT_DIR$/.idea/oracle_client_provision.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,73 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="CompassSettings">
4
+ <option name="compassSupportEnabled" value="true" />
5
+ </component>
6
+ <component name="FacetManager">
7
+ <facet type="gem" name="Ruby Gem">
8
+ <configuration>
9
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
10
+ <option name="GEM_APP_TEST_PATH" value="" />
11
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
12
+ </configuration>
13
+ </facet>
14
+ </component>
15
+ <component name="ModuleRunConfigurationManager">
16
+ <configuration default="false" name="OracleClientProvision#install calls install method: oracle_client_provision" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
17
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
18
+ <module name="oracle_client_provision" />
19
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
20
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
21
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
22
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
23
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
24
+ <envs>
25
+ <env name="JRUBY_OPTS" value="-X+O" />
26
+ </envs>
27
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
28
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
29
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
30
+ <COVERAGE_PATTERN ENABLED="true">
31
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
32
+ </COVERAGE_PATTERN>
33
+ </EXTENSION>
34
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
35
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
36
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/oracle_client_provision_spec.rb" />
37
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
38
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
39
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="OracleClientProvision#install calls install method" />
40
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
41
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
42
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
43
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
44
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
45
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
46
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
47
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
48
+ <RunnerSettings RunnerId="RubyRunner" />
49
+ <ConfigurationWrapper RunnerId="RubyRunner" />
50
+ <method />
51
+ </configuration>
52
+ </component>
53
+ <component name="NewModuleRootManager">
54
+ <content url="file://$MODULE_DIR$" />
55
+ <orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p545 [oracle_client_provision]" jdkType="RUBY_SDK" />
56
+ <orderEntry type="sourceFolder" forTests="false" />
57
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.7, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.1.2, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="highline (v1.6.21, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
64
+ <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.4, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
65
+ <orderEntry type="library" scope="PROVIDED" name="mocha (v1.1.0, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
66
+ <orderEntry type="library" scope="PROVIDED" name="net-ssh (v2.9.1, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
67
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.0.0, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="script_executor (v1.5.2, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
69
+ <orderEntry type="library" scope="PROVIDED" name="text-interpolator (v1.1.6, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, RVM: ruby-1.9.3-p545 [oracle_client_provision]) [gem]" level="application" />
71
+ </component>
72
+ </module>
73
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
@@ -0,0 +1,32 @@
1
+ {
2
+
3
+ "node": {
4
+ "domain": "127.0.0.1",
5
+ "user": "ENV['USER']",
6
+ "home": "ENV['HOME']",
7
+ "port": "",
8
+ "remote": false
9
+ },
10
+
11
+ "project": {
12
+ "home": "#{node.home}/oracle_client_provision",
13
+ "ruby_home": "ENV['MY_RUBY_HOME']"
14
+ },
15
+
16
+ "instant_client": {
17
+ "src_dir": "./downloads",
18
+ "dest_dir": "#{oracle.oracle_base}/instantclient_11_2",
19
+
20
+ "basic_zip": "#{instant_client.src_dir}/instantclient-basic-macos.x64-#{oracle.oracle_version}.zip",
21
+ "sdk_zip": "#{instant_client.src_dir}/instantclient-sdk-macos.x64-#{oracle.oracle_version}.zip",
22
+ "sqlplus_zip": "#{instant_client.src_dir}/instantclient-sqlplus-macos.x64-#{oracle.oracle_version}.zip"
23
+ },
24
+
25
+ "oracle": {
26
+ "oracle_base": "/usr/local/oracle",
27
+ "oracle_version": "11.2.0.4.0",
28
+ "ruby_oci_version": "2.1.7",
29
+ "tns_admin_dir": "#{oracle.oracle_base}/network/admin"
30
+ }
31
+
32
+ }
@@ -0,0 +1 @@
1
+ oracle_client_provision
@@ -0,0 +1 @@
1
+ 1.9.3
data/CHANGES ADDED
@@ -0,0 +1,5 @@
1
+ = Oracle Instant Client Provision Changelog
2
+
3
+ == Version 1.0.0
4
+
5
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Run "bundle install --without=oracle" to install gems without ruby-oci8 driver
4
+
5
+ group :default do
6
+ gem "text-interpolator", "~>1.1"
7
+ gem "script_executor", "~>1.5"
8
+ gem "thor", "~>0.19"
9
+ gem "json_pure", "~>1.8"
10
+ end
11
+
12
+ group :development do
13
+ gem "gemspec_deps_gen", "~>1.1"
14
+ gem "gemcutter", "~>0.7"
15
+ end
16
+
17
+ group :oracle do
18
+ gem "ruby-oci8", "2.1.7"
19
+ end
20
+
21
+ group :test do
22
+ gem "rspec"
23
+ gem "mocha"
24
+ end
@@ -0,0 +1,49 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.2.5)
5
+ file_utils (1.0.7)
6
+ gemcutter (0.7.1)
7
+ gemspec_deps_gen (1.1.2)
8
+ bundler
9
+ file_utils
10
+ highline (1.6.21)
11
+ json_pure (1.8.1)
12
+ metaclass (0.0.4)
13
+ mocha (1.1.0)
14
+ metaclass (~> 0.0.1)
15
+ net-ssh (2.9.1)
16
+ rspec (3.0.0)
17
+ rspec-core (~> 3.0.0)
18
+ rspec-expectations (~> 3.0.0)
19
+ rspec-mocks (~> 3.0.0)
20
+ rspec-core (3.0.4)
21
+ rspec-support (~> 3.0.0)
22
+ rspec-expectations (3.0.4)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.0.0)
25
+ rspec-mocks (3.0.4)
26
+ rspec-support (~> 3.0.0)
27
+ rspec-support (3.0.4)
28
+ ruby-oci8 (2.1.7)
29
+ script_executor (1.5.2)
30
+ highline (~> 1.6)
31
+ json_pure (~> 1.8)
32
+ net-ssh (~> 2.8)
33
+ text-interpolator (~> 1.0)
34
+ text-interpolator (1.1.6)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ gemcutter (~> 0.7)
42
+ gemspec_deps_gen (~> 1.1)
43
+ json_pure (~> 1.8)
44
+ mocha
45
+ rspec
46
+ ruby-oci8 (= 2.1.7)
47
+ script_executor (~> 1.5)
48
+ text-interpolator (~> 1.1)
49
+ thor (~> 0.19)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Alexander Shvets
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,213 @@
1
+ # Oracle Client Provision - thor-based tasks for facilitating Oracle Instant Client installation
2
+
3
+ ## Introduction
4
+
5
+ Installing database driver for Oracle (activerecord-oracle_enhanced-adapter) is not a simple process.
6
+
7
+ - First, you need to install Oracle Instant Client.
8
+ - Second, you have to install ruby wrapper around Instant Client (ruby-oci8 gem). On some platforms it
9
+ requires compiling source code.
10
+
11
+ Only after that you can install oracle database driver.
12
+
13
+ Here we discuss how to do it for OSX 10 operating system.
14
+
15
+ ## Create new gem group
16
+
17
+ Create separate group (e.g. "oracle") in Gemfile for oracle ruby-oci8 client wrapper. You have to keep
18
+ this gem in separate group because it requires special steps to be done before database driver
19
+ can be installed.
20
+
21
+ ```ruby
22
+ # Gemfile
23
+
24
+ group :oracle do
25
+ gem "ruby-oci8", "2.1.7"
26
+ end
27
+ ```
28
+
29
+ ## Install gems for the project (except ruby-oci8 gem)
30
+
31
+ Install ruby gems for your project with bundler tool. You have to bypass oracle client wrapper installation:
32
+
33
+ ```bash
34
+ bundle install --without=oracle
35
+ ```
36
+
37
+ **without** parameter will exclude **oracle** bundler group from the execution.
38
+
39
+ Check that you don't have ruby-oci8 installed yet:
40
+
41
+ ```bash
42
+ gem list
43
+ ```
44
+
45
+ ## Download Oracle Instant Client
46
+
47
+ Download Oracle Instant Client packages and save them locally (e.g. in "downloads" folder). You can find
48
+ installation packages on **www.oracle.com** web site (you have to be registered user though).
49
+
50
+ ## Configuration file
51
+
52
+ Create configuration file for the installation (.oracle\_client\_provision.json) in the root of your project.
53
+ It will define where you have downloaded files and some other parameters:
54
+
55
+ ```json
56
+ {
57
+
58
+ "node": {
59
+ "domain": "127.0.0.1",
60
+ "user": "ENV['USER']",
61
+ "home": "ENV['HOME']",
62
+ "port": "",
63
+ "remote": false
64
+ }
65
+
66
+ "project": {
67
+ "home": "#{node.home}/my_project_with_oracle_driver",
68
+ "ruby_home": "ENV['MY_RUBY_HOME']"
69
+ },
70
+
71
+ "instant_client": {
72
+ "src_dir": "#{project.home}/downloads",
73
+ "dest_dir": "#{oracle.oracle_base}/instantclient_11_2",
74
+
75
+ "basic_zip": "#{instant_client.src_dir}/instantclient-basic-macos.x64-#{oracle.oracle_version}.zip",
76
+ "sdk_zip": "#{instant_client.src_dir}/instantclient-sdk-macos.x64-#{oracle.oracle_version}.zip",
77
+ "sqlplus_zip": "#{instant_client.src_dir}/instantclient-sqlplus-macos.x64-#{oracle.oracle_version}.zip"
78
+ },
79
+
80
+ "oracle": {
81
+ "oracle_base": "/usr/local/oracle",
82
+ "oracle_version": "11.2.0.4.0",
83
+ "ruby_oci_version": "2.1.7",
84
+ "tns_admin_dir": "#{oracle.oracle_base}/network/admin"
85
+ }
86
+
87
+ }
88
+ ```
89
+
90
+ We are going to run ruby from **project.ruby_home** on behalf of the **node.user** and we will use specific versions
91
+ of **oracle** client and **ruby-oci8** gem. We also specify where to look for installation packages (instant_client.src\_dir)
92
+ and where to install Instant Client (instant_client.dest\_dir). Also, as you can see, we are using **macos** as a platform
93
+ and **x64** as an architecture.
94
+
95
+ ## Provide execution script
96
+
97
+ Library itself if written in ruby, but for launching its code you have to use **rake** or **thor**. Here I provide
98
+ thor script as an example:
99
+
100
+ ```ruby
101
+ require 'thor'
102
+ require 'oracle_client_provision'
103
+
104
+ class OracleClient < Thor
105
+ @installer = OracleClientProvision.new self, ".oracle_client_provision.json"
106
+
107
+ class << self
108
+ attr_reader :installer
109
+ end
110
+
111
+ desc "install", "Installs Oracle Instant Client"
112
+ def install
113
+ OracleClient.installer.install
114
+ end
115
+
116
+ desc "uninstall", "Uninstalls Oracle Instant Client"
117
+ def uninstall
118
+ OracleClient.installer.uninstall
119
+ end
120
+
121
+ desc "verify", "Verifies Oracle Instant Client connection"
122
+ def verify
123
+ username = "scott"
124
+ password = "tiger"
125
+ schema = "ORCL"
126
+ sql = "SELECT * FROM emp where rownum <= 10"
127
+
128
+ OracleClient.installer.verify do
129
+ "require 'oci8'; OCI8.new('#{username}','#{password}','#{schema}').exec('#{sql}') do |r| puts r.join(','); end"
130
+ end
131
+ end
132
+
133
+ end
134
+ ```
135
+
136
+ ## Install Oracle Instant Client
137
+
138
+ Run this **thor** command:
139
+
140
+ ```bash
141
+ thor oracle_client:install
142
+ ```
143
+
144
+ After execution all Instant Client packages (basic, sdk and sqlplus) will be installed at the right location
145
+ (instant_client.dest\_dir) on your computer.
146
+
147
+ ## Again: install gems for the project, now with ruby-oci8 gem
148
+
149
+ Remove .bundle folder in order to include "oracle" group into bundle execution and
150
+ then run bundler with "oracle" group:
151
+
152
+ ```bash
153
+ rm -rf .bundle
154
+
155
+ bundle
156
+ ```
157
+
158
+ ## Verify the installation
159
+
160
+ If you have Oracle installed locally with **scott/tiger/ORCL**, you can test it now:
161
+
162
+ ```bash
163
+ thor oracle_client:verify
164
+ ```
165
+
166
+ If you have oracle installed somewhere on the network, you can add TNS names inside your
167
+ **tnsnames.ora** file located inside **/usr/local/oracle/network/admin** folder. You can set up
168
+ this location via **tns\_admin\_dir** property inside your configuration file.
169
+
170
+ tnsnames.ora file will have this section:
171
+
172
+ ```
173
+ MY_ORCL=
174
+ (DESCRIPTION=
175
+ (ADDRESS=
176
+ (PROTOCOL=TCP)
177
+ (HOST=db.your_host.com)
178
+ (PORT=1521)
179
+ )
180
+ (CONNECT_DATA=
181
+ (SID=MY_ORCL)
182
+ )
183
+ )
184
+ ```
185
+
186
+ where you define **MY\_ORCL** schema on **db.your\_host.com** running on port **1521**.
187
+
188
+ In order to use oracle driver inside rails application, you have to include it into your Gemfile:
189
+
190
+ ```ruby
191
+ # Gemfile
192
+
193
+ group :oracle do
194
+ ...
195
+ gem 'activerecord-oracle_enhanced-adapter', '1.5.5'
196
+ end
197
+ ```
198
+
199
+ # Summary: all steps all together
200
+
201
+ ```bash
202
+ bundle install --without=oracle
203
+
204
+ thor oracle_client:install
205
+
206
+ rm -rf .bundle
207
+
208
+ bundle
209
+
210
+ thor oracle_client:verify
211
+ ```
212
+
213
+
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env rake
2
+
3
+ include Rake::DSL
4
+
5
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
6
+
7
+ require "rspec/core/rake_task"
8
+ require "oracle_client_provision/version"
9
+ require "gemspec_deps_gen/gemspec_deps_gen"
10
+
11
+ version = OracleClientProvision::VERSION
12
+ project_name = File.basename(Dir.pwd)
13
+
14
+ task :gen do
15
+ generator = GemspecDepsGen.new
16
+
17
+ generator.generate_dependencies "spec", "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
18
+ end
19
+
20
+ task :build => :gen do
21
+ system "gem build #{project_name}.gemspec"
22
+ end
23
+
24
+ task :install do
25
+ system "gem install #{project_name}-#{version}.gem"
26
+ end
27
+
28
+ task :uninstall do
29
+ system "gem uninstall #{project_name}"
30
+ end
31
+
32
+ task :release => :build do
33
+ system "gem push #{project_name}-#{version}.gem"
34
+ end
35
+
36
+ RSpec::Core::RakeTask.new do |task|
37
+ task.pattern = 'spec/**/*_spec.rb'
38
+ task.verbose = false
39
+ end
40
+
41
+ desc 'Installs oracle ruby-oci8 support'
42
+ task :oracle_install do
43
+ system "bundle install --without=oracle"
44
+
45
+ system "rm -rf .bundle"
46
+
47
+ system "thor oracle_client:install"
48
+
49
+ system "thor oracle_client:verify"
50
+ end
51
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless defined? Thor::Runner
4
+ require 'bundler'
5
+
6
+ gems = Bundler::Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil).requested_specs
7
+
8
+ gem = gems.find { |gem| gem.name == 'thor'}
9
+
10
+ load "#{ENV['GEM_HOME']}/gems/#{gem.name}-#{gem.version}/bin/thor"
11
+ end
12
+
13
+ require 'thor'
14
+
15
+ Dir.glob("thor/**/*.thor") do |name|
16
+ Thor::Util.load_thorfile(name)
17
+ end
@@ -0,0 +1 @@
1
+ require 'oracle_client_provision/oracle_client_provision'
@@ -0,0 +1,30 @@
1
+ require 'script_executor/base_provision'
2
+
3
+ class OracleClientProvision < BaseProvision
4
+ include Executable, ScriptLocator
5
+
6
+ def initialize parent_class, config_file_name=".oracle_client_provision.json", scripts_file_names=[]
7
+ scripts_file_names.unshift(File.expand_path("oracle_client_provision_scripts.sh", File.dirname(__FILE__))) # make it first
8
+
9
+ super
10
+ end
11
+
12
+ def install
13
+ puts "ruby home: #{env[:project][:ruby_home]}"
14
+ puts "ruby_oci_version: #{env[:oracle][:ruby_oci_version]}"
15
+ puts "user: #{env[:node][:user]}"
16
+
17
+ run(server_info.merge({:sudo => true, :capture_output => true}), "install_client", env)
18
+
19
+ run(server_info, "install-ruby-oci8", env)
20
+ end
21
+
22
+ def uninstall
23
+ run({:sudo => true}, "uninstall", env)
24
+ end
25
+
26
+ def verify &code
27
+ run(server_info, "verify_install", env.merge(:cmd => code.call))
28
+ end
29
+
30
+ end
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+
3
+ [install_client]
4
+
5
+ echo "Removing Oracle instant client..."
6
+
7
+ rm -rf #{instant_client.dest_dir}
8
+
9
+ echo "Creating required directories for Oracle instant client..."
10
+
11
+ mkdir -p #{oracle.oracle_base}
12
+ mkdir -p #{oracle.tns_admin_dir}
13
+ mkdir -p #{instant_client.dest_dir}
14
+
15
+ echo "Unzipping Oracle instant client..."
16
+
17
+ cp #{instant_client.basic_zip} #{oracle.oracle_base}
18
+ cp #{instant_client.sdk_zip} #{oracle.oracle_base}
19
+ cp #{instant_client.sqlplus_zip} #{oracle.oracle_base}
20
+
21
+ unzip -o #{instant_client.basic_zip} -d #{oracle.oracle_base}
22
+ unzip -o #{instant_client.sdk_zip} -d #{oracle.oracle_base}
23
+ unzip -o #{instant_client.sqlplus_zip} -d #{oracle.oracle_base}
24
+
25
+ echo "Creating soft links..."
26
+
27
+ ln -sF #{instant_client.dest_dir}/libclntsh.dylib.11.1 #{instant_client.dest_dir}/libclntsh.dylib
28
+
29
+
30
+ [install-ruby-oci8]
31
+
32
+ echo "Installing ruby-oci8 gem..."
33
+
34
+ ORACLE_BASE="#{oracle.oracle_base}"
35
+ DYLD_LIBRARY_PATH="#{instant_client.dest_dir}"
36
+ TNS_ADMIN="#{oracle.tns_admin_dir}"
37
+ NLS_LANG=".UTF8"
38
+
39
+ ENV_VARS="ORACLE_BASE=$ORACLE_BASE DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH TNS_ADMIN=$TNS_ADMIN NLS_LANG=$NLS_LANG"
40
+
41
+ env $ENV_VARS bash -c 'gem install ruby-oci8 -v #{oracle.ruby_oci_version}'
42
+
43
+
44
+ [uninstall]
45
+
46
+ echo "Removing Oracle instant client..."
47
+
48
+ rm -rf #{instant_client.dest_dir}
49
+
50
+ echo "Creating required directories for Oracle instant client..."
51
+
52
+ mkdir -p #{oracle.oracle_base}
53
+ mkdir -p #{oracle.tns_admin_dir}
54
+ mkdir -p #{instant_client.dest_dir}
55
+
56
+ echo "Unzipping Oracle instant client..."
57
+
58
+ cp #{instant_client.basic_zip} #{oracle.oracle_base}
59
+ cp #{instant_client.sdk_zip} #{oracle.oracle_base}
60
+ cp #{instant_client.sqlplus_zip} #{oracle.oracle_base}
61
+
62
+ unzip -o #{instant_client.basic_zip} -d #{oracle.oracle_base}
63
+ unzip -o #{instant_client.sdk_zip} -d #{oracle.oracle_base}
64
+ unzip -o #{instant_client.sqlplus_zip} -d #{oracle.oracle_base}
65
+
66
+ echo "Creating soft links..."
67
+
68
+ ln -sF #{instant_client.dest_dir}/libclntsh.dylib.11.1 #{instant_client.dest_dir}/libclntsh.dylib
69
+
70
+
71
+ [verify_install]
72
+
73
+ echo "Testing Instant Client installation..."
74
+
75
+ RUBY="#{project.ruby_home}/bin/ruby"
76
+ ORACLE_BASE="#{oracle.oracle_base}"
77
+ DYLD_LIBRARY_PATH="#{instant_client.dest_dir}"
78
+ TNS_ADMIN="#{oracle.tns_admin_dir}"
79
+ NLS_LANG='.UTF8'
80
+
81
+ ENV_VARS="ORACLE_BASE=$ORACLE_BASE DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH TNS_ADMIN=$TNS_ADMIN NLS_LANG=$NLS_LANG"
82
+
83
+ env $ENV_VARS $RUBY -e "#{cmd}"
@@ -0,0 +1,3 @@
1
+ class OracleClientProvision
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/oracle_client_provision/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "oracle_client_provision"
7
+ spec.summary = %q{Thor-based tasks for installing oracle client}
8
+ spec.description = %q{Thor-based tasks for installing oracle client.}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/oracle_client_provision"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+ spec.version = OracleClientProvision::VERSION
17
+ spec.license = "MIT"
18
+
19
+ <%= project_dependencies %>
20
+ end
21
+
@@ -0,0 +1,16 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ require 'oracle_client_provision'
4
+
5
+ describe OracleClientProvision do
6
+ subject { OracleClientProvision.new self.class, ".oracle_client_provision.json"}
7
+
8
+ describe "#install" do
9
+ it "calls install method" do
10
+ expect(subject).to receive(:run).exactly(2).times
11
+
12
+ subject.install
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,6 @@
1
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
2
+
3
+ # RSpec.configure do |config|
4
+ # config.mock_with :mocha
5
+ # end
6
+
@@ -0,0 +1,35 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'oracle_client_provision'
4
+
5
+ class OracleClient < Thor
6
+ @installer = OracleClientProvision.new self, ".oracle_client_provision.json"
7
+
8
+ class << self
9
+ attr_reader :installer
10
+ end
11
+
12
+ desc "install", "Installs Oracle Instant Client"
13
+ def install
14
+ OracleClient.installer.install
15
+ end
16
+
17
+ desc "uninstall", "Uninstalls Oracle Instant Client"
18
+ def uninstall
19
+ OracleClient.installer.uninstall
20
+ end
21
+
22
+ desc "verify", "Verifies Oracle Instant Client connection"
23
+ def verify
24
+ username = "scott"
25
+ password = "tiger"
26
+ schema = "ORCL"
27
+ sql = "SELECT * FROM emp where rownum <= 10"
28
+
29
+ OracleClient.installer.verify do
30
+ "require 'oci8'; OCI8.new('#{username}','#{password}','#{schema}').exec('#{sql}') do |r| puts r.join(','); end"
31
+ end
32
+ end
33
+
34
+ end
35
+
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oracle_client_provision
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Shvets
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: text-interpolator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: script_executor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.19'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json_pure
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gemspec_deps_gen
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: gemcutter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.7'
97
+ description: Thor-based tasks for installing oracle client.
98
+ email: alexander.shvets@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - .gitignore
104
+ - .idea/.name
105
+ - .idea/.rakeTasks
106
+ - .idea/encodings.xml
107
+ - .idea/misc.xml
108
+ - .idea/modules.xml
109
+ - .idea/oracle_client_provision.iml
110
+ - .idea/scopes/scope_settings.xml
111
+ - .idea/vcs.xml
112
+ - .oracle_client_provision.json
113
+ - .ruby-gemset
114
+ - .ruby-version
115
+ - CHANGES
116
+ - Gemfile
117
+ - Gemfile.lock
118
+ - LICENSE
119
+ - README.md
120
+ - Rakefile
121
+ - Thorfile
122
+ - lib/oracle_client_provision.rb
123
+ - lib/oracle_client_provision/oracle_client_provision.rb
124
+ - lib/oracle_client_provision/oracle_client_provision_scripts.sh
125
+ - lib/oracle_client_provision/version.rb
126
+ - oracle_client_provision.gemspec.erb
127
+ - spec/oracle_client_provision_spec.rb
128
+ - spec/spec_helper.rb
129
+ - thor/oracle_client.thor
130
+ homepage: http://github.com/shvets/oracle_client_provision
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.2.2
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Thor-based tasks for installing oracle client
154
+ test_files:
155
+ - spec/oracle_client_provision_spec.rb
156
+ - spec/spec_helper.rb