oracle_client_installer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWIxMDE5MDljNWE2MTQyMTk4MGYwMzUzMGZhNGQxMDA3ODhmMjVjYQ==
5
+ data.tar.gz: !binary |-
6
+ YzM4OTMxZDZmYjRkMzM5NGRmZGM3NzRiZTMzZWRmZDQwMGMzZDEyNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZmE5NmRiYWY1YjkzMDgyNWExNGRhZDM2Y2U1ZTk4YTMzNmY0YjI2MWRmN2Y5
10
+ Y2NhMDExNzY4MThhN2UzMWIwZWM1N2M5MDRlOGU5NGNjMzI1NTJmMTRiNTlj
11
+ NWMwZGVkYWY3YzEzMTczMzA5NTk4YjEzODMyYjRmMDc1YjMwMGM=
12
+ data.tar.gz: !binary |-
13
+ YmQ2OWM5MmQwMjhiZjEyMDNhOTcwZGQ5MWM5M2IxMTM5MGQ3Njg4NjRiYWU0
14
+ ZThmODJhODUzOGUxODcwNDA3MDRjODQ4ODNmYzE5ZDc1OGJmYjdhZTQ5NzQ3
15
+ MGFlOWMxZDUyODFjOWFjZjI4Y2Q0NTg3Yjc3OWNmOTU0MzVhNjQ=
data/.gitignore ADDED
@@ -0,0 +1,34 @@
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
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
@@ -0,0 +1,18 @@
1
+ {
2
+ "host": "localhost",
3
+ "user": "ENV['USER']",
4
+ "home": "ENV['HOME']",
5
+ "ruby_home": "ENV['MY_RUBY_HOME']",
6
+
7
+ "oracle_base": "/usr/local/oracle",
8
+ "oracle_version": "11.2.0.4.0",
9
+ "ruby_oci_version": "2.1.7",
10
+ "tns_admin_dir": "#{oracle_base}/network/admin",
11
+
12
+ "src_dir": "downloads",
13
+ "dest_dir": "#{oracle_base}/instantclient_11_2",
14
+
15
+ "basic_zip": "#{src_dir}/instantclient-basic-macos.x64-#{oracle_version}.zip",
16
+ "sdk_zip": "#{src_dir}/instantclient-sdk-macos.x64-#{oracle_version}.zip",
17
+ "sqlplus_zip": "#{src_dir}/instantclient-sqlplus-macos.x64-#{oracle_version}.zip"
18
+ }
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ oracle_client_installer
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ = Oracle Instant Client Installer Changelog
2
+
3
+ == Version 1.0.0
4
+
5
+ * Initial release.
6
+
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.0"
7
+ gem "script_executor", "~>1.3"
8
+ gem "thor", "~>0.19"
9
+ end
10
+
11
+ group :development do
12
+ gem "gemspec_deps_gen", "~>1.1"
13
+ gem "gemcutter", "~>0.7"
14
+ end
15
+
16
+ group :oracle do
17
+ gem "ruby-oci8", "2.1.7"
18
+ end
19
+
20
+ group :test do
21
+ gem "rspec"
22
+ gem "mocha"
23
+ gem "json_pure"
24
+ end
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.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ oracle_client_installer
2
+ =======================
3
+
4
+ Thor-based tasks for installing oracle client
5
+
6
+
7
+ ```bash
8
+ bundle install --without=oracle_driver
9
+
10
+ rm -rf .bundle
11
+
12
+ thor oracle_client:install
13
+ ```
14
+
15
+ ```bash
16
+ thor oracle_client:verify
17
+ ```
data/Rakefile ADDED
@@ -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_installer/version"
9
+ require "gemspec_deps_gen/gemspec_deps_gen"
10
+
11
+ version = OracleClientInstaller::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
+
data/Thorfile ADDED
@@ -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_installer/oracle_client_installer'
@@ -0,0 +1,53 @@
1
+ require 'json'
2
+ require 'script_executor/executable'
3
+ require 'script_executor/script_locator'
4
+ require 'text_interpolator'
5
+
6
+ class OracleClientInstaller
7
+ include Executable, ScriptLocator
8
+
9
+ attr_reader :env, :script_list, :interpolator
10
+
11
+ def initialize config_file_name
12
+ @interpolator = TextInterpolator.new
13
+
14
+ @env = read_config(config_file_name)
15
+
16
+ puts "ruby home: #{env[:ruby_home]}"
17
+ puts "ruby_oci_version: #{env[:ruby_oci_version]}"
18
+ puts "user: #{env[:user]}"
19
+
20
+ @script_list = scripts(File.expand_path('scripts.sh', File.dirname(__FILE__)))
21
+ end
22
+
23
+ def install
24
+ run({:sudo => true, :capture_output => true}, "install", env)
25
+
26
+ run({}, "install-ruby-oci8", env)
27
+ end
28
+
29
+ def uninstall
30
+ run({:sudo => true}, "uninstall", env)
31
+ end
32
+
33
+ def verify &code
34
+ run({}, "verify", env.merge(:cmd => code.call))
35
+ end
36
+
37
+ private
38
+
39
+ def read_config config_file_name
40
+ hash = JSON.parse(File.read(config_file_name), :symbolize_names => true)
41
+
42
+ interpolator.interpolate hash
43
+ end
44
+
45
+ def run server_info, script_name, env
46
+ execute(server_info) { evaluate_script_body(script_list[script_name], env) }
47
+ end
48
+
49
+ def evaluate_script_body content, env
50
+ interpolator.interpolate content, env
51
+ end
52
+
53
+ end
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+
3
+ [install]
4
+
5
+ echo "Removing Oracle instant client..."
6
+
7
+ rm -rf #{dest_dir}
8
+
9
+ echo "Creating required directories for Oracle instant client..."
10
+
11
+ mkdir -p #{oracle_base}
12
+ mkdir -p #{tns_admin_dir}
13
+ mkdir -p #{dest_dir}
14
+
15
+ echo "Unzipping Oracle instant client..."
16
+
17
+ cp #{basic_zip} #{oracle_base}
18
+ cp #{sdk_zip} #{oracle_base}
19
+ cp #{sqlplus_zip} #{oracle_base}
20
+
21
+ unzip -o #{basic_zip} -d #{oracle_base}
22
+ unzip -o #{sdk_zip} -d #{oracle_base}
23
+ unzip -o #{sqlplus_zip} -d #{oracle_base}
24
+
25
+ echo "Creating soft links..."
26
+
27
+ ln -sF #{dest_dir}/libclntsh.dylib.11.1 #{dest_dir}/libclntsh.dylib
28
+
29
+
30
+ [install-ruby-oci8]
31
+
32
+ echo "Installing ruby-oci8 gem..."
33
+
34
+ ORACLE_BASE="#{oracle_base}"
35
+ DYLD_LIBRARY_PATH="#{dest_dir}"
36
+ TNS_ADMIN="#{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 #{ruby_oci_version}'
42
+
43
+
44
+ [uninstall]
45
+
46
+ echo "Removing Oracle instant client..."
47
+
48
+ rm -rf #{dest_dir}
49
+
50
+ echo "Creating required directories for Oracle instant client..."
51
+
52
+ mkdir -p #{oracle_base}
53
+ mkdir -p #{tns_admin_dir}
54
+ mkdir -p #{dest_dir}
55
+
56
+ echo "Unzipping Oracle instant client..."
57
+
58
+ cp #{basic_zip} #{oracle_base}
59
+ cp #{sdk_zip} #{oracle_base}
60
+ cp #{sqlplus_zip} #{oracle_base}
61
+
62
+ unzip -o #{basic_zip} -d #{oracle_base}
63
+ unzip -o #{sdk_zip} -d #{oracle_base}
64
+ unzip -o #{sqlplus_zip} -d #{oracle_base}
65
+
66
+ echo "Creating soft links..."
67
+
68
+ ln -sF #{dest_dir}/libclntsh.dylib.11.1 #{dest_dir}/libclntsh.dylib
69
+
70
+
71
+ [verify]
72
+
73
+ echo "Testing Instant Client installation..."
74
+
75
+ RUBY="#{ruby_home}/bin/ruby"
76
+ ORACLE_BASE="#{oracle_base}"
77
+ DYLD_LIBRARY_PATH="#{dest_dir}"
78
+ TNS_ADMIN="#{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 OracleClientInstaller
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/oracle_client_installer/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "oracle_client_installer"
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_installer"
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 = OracleClientInstaller::VERSION
17
+ spec.license = "MIT"
18
+
19
+
20
+ spec.add_runtime_dependency "text-interpolator", ["~> 1.0"]
21
+ spec.add_runtime_dependency "script_executor", ["~> 1.3"]
22
+ spec.add_runtime_dependency "thor", ["~> 0.19"]
23
+ spec.add_development_dependency "gemspec_deps_gen", ["~> 1.1"]
24
+ spec.add_development_dependency "gemcutter", ["~> 0.7"]
25
+
26
+ end
27
+
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/oracle_client_installer/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "oracle_client_installer"
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_installer"
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 = OracleClientInstaller::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_installer'
4
+
5
+ describe OracleClientInstaller do
6
+ subject { OracleClientInstaller.new ".oracle_client_installer.json"}
7
+
8
+ describe "#install" do
9
+ it "calls install method" do
10
+ subject.expects(:run)
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_installer/oracle_client_installer'
4
+
5
+ class OracleClient < Thor
6
+ def initialize *params
7
+ @installer = OracleClientInstaller.new ".oracle_client_installer.json"
8
+
9
+ super *params
10
+ end
11
+
12
+ desc "install", "Installs Oracle Instant Client"
13
+ def install
14
+ @installer.install
15
+ end
16
+
17
+ desc "uninstall", "Uninstalls Oracle Instant Client"
18
+ def uninstall
19
+ @installer.uninstall
20
+ end
21
+
22
+ desc "verify", "Verifies Oracle Instant Client connevtion"
23
+ def verify
24
+ username = "scott"
25
+ password = "tiger"
26
+ schema = "ORCL"
27
+ sql = "SELECT * FROM emp where rownum <= 10"
28
+
29
+ @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,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oracle_client_installer
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-04-29 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
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.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
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: gemspec_deps_gen
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gemcutter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ description: Thor-based tasks for installing oracle client.
84
+ email: alexander.shvets@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - .gitignore
90
+ - .oracle_client_installer.json
91
+ - .ruby-gemset
92
+ - .ruby-version
93
+ - CHANGES
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - Thorfile
99
+ - lib/oracle_client_installer.rb
100
+ - lib/oracle_client_installer/oracle_client_installer.rb
101
+ - lib/oracle_client_installer/scripts.sh
102
+ - lib/oracle_client_installer/version.rb
103
+ - oracle_client_installer.gemspec
104
+ - oracle_client_installer.gemspec.erb
105
+ - spec/oracle_client_installer_spec.rb
106
+ - spec/spec_helper.rb
107
+ - thor/oracle_client.thor
108
+ homepage: http://github.com/shvets/oracle_client_installer
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.2.2
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Thor-based tasks for installing oracle client
132
+ test_files:
133
+ - spec/oracle_client_installer_spec.rb
134
+ - spec/spec_helper.rb