oci8_simple 0.9.2 → 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d32480f3660c4a346625635ba296b9a907e6e841
4
+ data.tar.gz: de7df0bae58756a6bedf51045baca46fc4c11d3c
5
+ SHA512:
6
+ metadata.gz: 6adb92f1399a73cb8abaacb05e1f41976cc99cd45d3584642a89a9298cca32f5814741bd5fa873b24eb5d0629d072b4ca8dda6869976c620c865c772b9dfa8a7
7
+ data.tar.gz: 998f2e0a74141370af21032ff3c5902a5e7442808b91d81f711b2cdcf6bf2e3a6b7da5a88c07b198dce5ee641697c67247a8e3254e60d89b37b6a46fd6f2b5bf
data/Gemfile CHANGED
@@ -4,6 +4,5 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem "shoulda", ">= 0"
7
- gem "mocha", ">= 0"
8
7
  gem "pry"
9
8
  end
data/Gemfile.lock CHANGED
@@ -1,43 +1,43 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oci8_simple (0.9.2)
4
+ oci8_simple (1.0.0)
5
5
  ruby-oci8 (~> 2.1.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (3.2.12)
11
- i18n (~> 0.6)
12
- multi_json (~> 1.0)
13
- bourne (1.1.2)
14
- mocha (= 0.10.5)
15
- coderay (1.0.9)
16
- i18n (0.6.1)
17
- metaclass (0.0.1)
18
- method_source (0.8.1)
19
- mocha (0.10.5)
20
- metaclass (~> 0.0.1)
21
- multi_json (1.6.1)
22
- pry (0.9.12)
23
- coderay (~> 1.0.5)
24
- method_source (~> 0.8)
10
+ activesupport (4.2.1)
11
+ i18n (~> 0.7)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ coderay (1.1.0)
17
+ i18n (0.7.0)
18
+ json (1.8.2)
19
+ method_source (0.8.2)
20
+ minitest (5.6.1)
21
+ pry (0.10.1)
22
+ coderay (~> 1.1.0)
23
+ method_source (~> 0.8.1)
25
24
  slop (~> 3.4)
26
- ruby-oci8 (2.1.4)
27
- shoulda (3.3.2)
28
- shoulda-context (~> 1.0.1)
29
- shoulda-matchers (~> 1.4.1)
30
- shoulda-context (1.0.2)
31
- shoulda-matchers (1.4.2)
25
+ ruby-oci8 (2.1.8)
26
+ shoulda (3.5.0)
27
+ shoulda-context (~> 1.0, >= 1.0.1)
28
+ shoulda-matchers (>= 1.4.1, < 3.0)
29
+ shoulda-context (1.2.1)
30
+ shoulda-matchers (2.8.0)
32
31
  activesupport (>= 3.0.0)
33
- bourne (~> 1.1.2)
34
- slop (3.4.3)
32
+ slop (3.6.0)
33
+ thread_safe (0.3.5)
34
+ tzinfo (1.2.2)
35
+ thread_safe (~> 0.1)
35
36
 
36
37
  PLATFORMS
37
38
  ruby
38
39
 
39
40
  DEPENDENCIES
40
- mocha
41
41
  oci8_simple!
42
42
  pry
43
43
  shoulda
data/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # oci8_simple
2
+ This gem is a thin wrapper around the ruby-oci8 gem. The client is intended
3
+ to be used by simple scripts to aid automation. The code is intentionally
4
+ light-weight and featureless, with very little startup time. It is not meant
5
+ to be a Ruby ORM for Oracle - if you want that, look at the
6
+ OracleEnhancedAdapter.
7
+
8
+ This gem installs a few command-line scripts:
9
+ * `oci8_simple`
10
+ * a command to run arbitrary SQL
11
+
12
+ * `describe `
13
+ * a command to describe a table
14
+
15
+ * `show `
16
+ * a command to list things in the database (tables, views, etc.)
17
+
18
+
19
+ You can also use oci8_simple in your Ruby scripts by creating an instance of
20
+ `Oci8Simple::Client` (see more below).
21
+
22
+ ## Prerequisites
23
+ * Oracle Instant Client
24
+ (http://www.oracle.com/technetwork/database/features/instant-client/index-
25
+ 097480.html)
26
+ * ruby-oci8
27
+
28
+
29
+ ## Installation
30
+ gem install oci8_simple
31
+
32
+ ## Configuration
33
+ Oci8Simple will look in three places for your database configuration, in the
34
+ following order:
35
+ * Dir.pwd + database.yml
36
+ * Dir.pwd + config/database.yml
37
+ * ~/.oci8_simple/database.yml
38
+
39
+ The database.yml format is compatible with the Rails format.
40
+
41
+ development:
42
+ database: oracle.hostname:1521/sid
43
+ username: foo_dev
44
+ password: OMG333
45
+ test:
46
+ database: oracle.hostname:1521/sid
47
+ username: foo_test
48
+ password: OMG333
49
+
50
+ ## Logging
51
+ All logging is done to `~/.oci8_simple/oci8_simple.log`.
52
+
53
+ ## Command-Line Examples
54
+ ### oci8_simple
55
+ This script allows you to run single statements against an arbitrary Oracle
56
+ schema via the command line.
57
+
58
+ Run a query against development schema
59
+
60
+ oci8_simple "select id, name from flavors"
61
+
62
+ Run a query against a different schema
63
+
64
+ oci8_simple "select id, name from flavors" -e int
65
+
66
+ Help
67
+
68
+ oci8_simple --help
69
+
70
+ ### describe
71
+ This script shows a description of a table, including the column names
72
+ (sorted), the type and size for each column, the nullable status of the
73
+ column, and the default value, if any.
74
+
75
+ Show column information for a table named "holidays"
76
+
77
+ describe holidays
78
+
79
+ Help
80
+
81
+ describe --help
82
+
83
+ ### show
84
+ This command can list the following items in the database: functions,
85
+ packages, procedures, sequences, synonyms, tables, types, and views.
86
+
87
+ Show a list of all tables in the database
88
+
89
+ show tables
90
+
91
+ Show a list of all views in the database
92
+
93
+ show views
94
+
95
+ Show the DDL for a particular view
96
+
97
+ show view users_view
98
+
99
+ Help
100
+
101
+ show --help
102
+
103
+ ## Code Examples
104
+ Initialize a client against the development schema
105
+
106
+ require 'rubygems'
107
+ require 'oci8_simple'
108
+ client = Oci8Simple::Client.new
109
+
110
+ Run a simple select query against development schema
111
+
112
+ client.run('select id, name from foos')
113
+ #=> [[2, "lol"], [3, "hey"], ...]
114
+ client.run('select id, name from foos', :hash => true)
115
+ #=> [{:id => 2, :name => "lol"}, {:id => 3, :name=>"hey"}, ...])
116
+
117
+ Update something
118
+
119
+ client.run <<-SQL
120
+ UPDATE foos SET bar='baz' WHERE id=1233
121
+ SQL
122
+
123
+ Run some DDL
124
+
125
+ client.run <<-SQL
126
+ CREATE TABLE foos (
127
+ ID NUMBER(38) NOT NULL
128
+ )
129
+ SQL
130
+
131
+ Run some PL/SQL
132
+
133
+ client.run <<-SQL
134
+ DECLARE
135
+ a NUMBER;
136
+ b NUMBER;
137
+ BEGIN
138
+ SELECT e,f INTO a,b FROM T1 WHERE e>1;
139
+ INSERT INTO T1 VALUES(b,a);
140
+ END;
141
+ SQL
142
+
143
+ Run a query against stage schema
144
+
145
+ Oci8Simple::Client.new("stage").run('select id, name from foos')
146
+ #=> [[2, "lol"], [3, "hey"], ...]
147
+
148
+
149
+ ## Contributing to oci8_simple
150
+
151
+ * Check out the latest master to make sure the feature hasn't been
152
+ implemented or the bug hasn't been fixed yet
153
+ * Check out the issue tracker to make sure someone already hasn't requested
154
+ it and/or contributed it
155
+ * Fork the project
156
+ * Start a feature/bugfix branch
157
+ * Commit and push until you are happy with your contribution
158
+ * Make sure to add tests for it. This is important so I don't break it in a
159
+ future version unintentionally.
160
+ * Please try not to mess with the Rakefile, version, or history. If you want
161
+ to have your own version, or is otherwise necessary, that is fine, but
162
+ please isolate to its own commit so I can cherry-pick around it.
163
+
164
+
165
+ ## Copyright
166
+
167
+ Copyright (c) 2015 Billy Reisinger. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -36,9 +36,7 @@ end
36
36
  desc "Release the gem to rubygems.org"
37
37
  task :release => :build do
38
38
  version = File.read(File.expand_path("../VERSION", __FILE__)).strip
39
- `git tag -a v#{version} -m "tagging #{version}"`
40
- `git push --tags`
41
39
  ourgem = "oci8_simple-#{version}.gem"
42
- `gem push #{ourgem}`
40
+ system "gem push #{ourgem}"
43
41
  end
44
42
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 1.0.0
@@ -31,7 +31,7 @@ module Oci8Simple
31
31
  end
32
32
 
33
33
  def self.usage
34
- "Usage: #{$0} \"SQL\" [ENV]"
34
+ "Usage: #{$0} [-e ENV] \"SQL\""
35
35
  end
36
36
 
37
37
  def self.run_from_argv
@@ -39,9 +39,9 @@ module Oci8Simple
39
39
  if(ARGV[0].nil?)
40
40
  puts o
41
41
  else
42
- puts self.new(ARGV[1]).run(ARGV[0], @options)
42
+ puts self.new(@options[:environment]).run(ARGV[0], @options)
43
43
  end
44
44
  end
45
45
 
46
46
  end
47
- end
47
+ end
@@ -36,19 +36,23 @@ module Oci8Simple
36
36
  # SQL
37
37
  class Client
38
38
  USER_DIR = File.join(ENV["HOME"], ".oci8_simple")
39
- LOG_FILE = File.join(USER_DIR, "oci8_simple.log")
40
-
41
- attr_accessor :log_file, :env
39
+ LOG_FILE_PATH = File.join(USER_DIR, "oci8_simple.log")
42
40
 
41
+ attr_accessor :log_file, :log_file_path, :env
42
+
43
+ def log_file_path
44
+ @log_file_path || LOG_FILE_PATH
45
+ end
46
+
43
47
  # * env is the environment heading in your database.yml file
44
48
  def initialize(env=nil)
45
49
  self.env = env || "development"
46
50
  end
47
51
 
48
52
  def log_file
49
- @log_file ||= File.open(LOG_FILE, 'a')
50
- rescue Errno::EACCES => e
51
- raise LogError.new("Cannot write to #{LOG_FILE}... be sure you have write permissions to #{USER_DIR}")
53
+ @log_file ||= File.open(log_file_path, 'a')
54
+ rescue Errno::EACCES, Errno::ENOENT => e
55
+ raise LogError.new("Cannot write to #{log_file_path}")
52
56
  end
53
57
 
54
58
  # sql - a query
@@ -117,4 +121,4 @@ module Oci8Simple
117
121
  log_file.puts "#{Time.now} - #{@env} - #{str}"
118
122
  end
119
123
  end
120
- end
124
+ end
@@ -8,12 +8,15 @@ module Oci8Simple
8
8
 
9
9
  # Returns an OptionParser object.
10
10
  def parse_options(banner)
11
- @options= {}
11
+ @options= {:environment => "development"}
12
12
  o = OptionParser.new do |opt|
13
13
  opt.banner = banner
14
14
  opt.on("-c", "--show_column_names", "Show column names for each result") do
15
15
  @options[:hash] = true
16
16
  end
17
+ opt.on("-e", "--environment ENV", "Set environment. Defaults to development") do |e|
18
+ @options[:environment] = e
19
+ end
17
20
  opt.on("-v", "--version", "Show version") do
18
21
  puts "#{self.to_s} #{Oci8Simple::VERSION}"
19
22
  exit
@@ -25,4 +28,4 @@ module Oci8Simple
25
28
 
26
29
  end
27
30
  end
28
- end
31
+ end
@@ -19,8 +19,10 @@ module Oci8Simple
19
19
  def database_yaml_path
20
20
  path = File.join(Dir.pwd, "database.yml")
21
21
  return path if File.exists?(path)
22
+
22
23
  path = File.join(Dir.pwd, "config", "database.yml")
23
24
  return path if File.exists?(path)
25
+
24
26
  File.join(USER_DIR, "database.yml")
25
27
  end
26
28
 
@@ -41,4 +43,4 @@ ERR
41
43
  end
42
44
  end
43
45
  end
44
- end
46
+ end
@@ -45,7 +45,7 @@ module Oci8Simple
45
45
  if(ARGV[0].nil?)
46
46
  puts o
47
47
  else
48
- puts self.new(ARGV[1]).run(ARGV[0])
48
+ puts self.new(@options[:environment]).run(ARGV[0])
49
49
  end
50
50
  end
51
51
 
@@ -123,4 +123,4 @@ module Oci8Simple
123
123
  @client ||= Oci8Simple::Client.new(@env)
124
124
  end
125
125
  end
126
- end
126
+ end
@@ -1,4 +1,10 @@
1
1
  module Oci8Simple
2
+ ##
3
+ # Examples: show tables
4
+ # show table users # gets ddl for table
5
+ # show packages
6
+ # show package do_stuff # gets ddl for do_stuff
7
+ #
2
8
  class Show
3
9
  include Command
4
10
 
@@ -12,11 +18,18 @@ module Oci8Simple
12
18
  "types" => "Type",
13
19
  "views" => "View"
14
20
  }
15
-
16
- def run(type)
17
- clazz = eval("OCI8::Metadata::#{TYPES[type]}")
18
- objects = client.send(:conn).describe_schema(client.config["username"]).all_objects.find_all{|f| f.class == clazz}
19
- objects.map(&:obj_name).map(&:downcase).sort
21
+
22
+ def run(type, thing = nil)
23
+ if thing.nil?
24
+ raise "Unknown type: #{type.inspect}" unless TYPES.has_key?(type)
25
+ clazz = eval("OCI8::Metadata::#{TYPES[type]}")
26
+ objects = client.send(:conn).describe_schema(client.config["username"]).all_objects.find_all{|f| f.class == clazz}
27
+ objects.map(&:obj_name).map(&:downcase).sort
28
+ else
29
+ cursor = client.send(:conn).exec("SELECT dbms_metadata.get_ddl('#{type.upcase}', '#{thing.upcase}') from dual")
30
+ result = cursor.fetch
31
+ result[0] ? result[0].read : ""
32
+ end
20
33
  end
21
34
 
22
35
  def initialize(env=nil)
@@ -25,10 +38,10 @@ module Oci8Simple
25
38
 
26
39
  def self.run_from_argv
27
40
  o = parse_options(self.usage)
28
- if(ARGV[0].nil? || TYPES[ARGV[0]].nil?)
41
+ if(ARGV[0].nil?)
29
42
  puts o
30
43
  else
31
- puts self.new(ARGV[1]).run(ARGV[0])
44
+ puts self.new(@options[:environment]).run(*ARGV)
32
45
  end
33
46
  end
34
47
 
@@ -46,4 +59,4 @@ STR
46
59
  @client ||= Oci8Simple::Client.new(@env)
47
60
  end
48
61
  end
49
- end
62
+ end
data/oci8_simple.gemspec CHANGED
@@ -10,14 +10,14 @@ Gem::Specification.new do |s|
10
10
  s.email = %q{billy.reisinger@gmail.com}
11
11
  s.executables = ["oci8_simple", "show", "describe"]
12
12
  s.extra_rdoc_files = [
13
- "README.rdoc"
13
+ "README.md"
14
14
  ]
15
15
  s.files = [
16
16
  ".document",
17
17
  "Gemfile",
18
18
  "Gemfile.lock",
19
19
  "LICENSE.txt",
20
- "README.rdoc",
20
+ "README.md",
21
21
  "Rakefile",
22
22
  "VERSION",
23
23
  "bin/describe",
data/test/cli_test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
- class CliTest < Test::Unit::TestCase
2
+ class CliTest < Minitest::Test
3
3
  context "Given a table and some data" do
4
4
  setup do
5
5
  @client = Oci8Simple::Client.new("test")
data/test/client_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class ClientTest < Test::Unit::TestCase
3
+ class ClientTest < Minitest::Test
4
4
  context "A client" do
5
5
  setup do
6
6
  @client = Oci8Simple::Client.new
@@ -10,36 +10,21 @@ class ClientTest < Test::Unit::TestCase
10
10
  end
11
11
  context "with a bad log file" do
12
12
  setup do
13
- File.expects(:open).with(Oci8Simple::Client::LOG_FILE, 'a').raises(Errno::EACCES.new("no permission"))
13
+ @client.log_file_path = "/bridge/to/nowhere"
14
14
  end
15
15
  should "raise custom error" do
16
- assert_raise Oci8Simple::LogError do
16
+ assert_raises Oci8Simple::LogError do
17
17
  @client.log_file
18
18
  end
19
19
  end
20
20
  end
21
- context "with no database.yml" do
22
- setup do
23
- fake_file = "/flkjlkj/flkjljk/flklkj"
24
- Oci8Simple::Config.any_instance.expects(:database_yaml_path).returns(fake_file)
25
- YAML.expects(:load_file).with(fake_file).raises(Errno::ENOENT.new)
26
- end
27
- should "raise a custom error" do
28
- assert_raise Oci8Simple::ConfigError do
29
- @client.config
30
- end
31
- end
32
- end
33
21
  end
34
22
  context "Running a procedure with nil return" do
35
23
  setup do
36
24
  @client = Oci8Simple::Client.new("test")
37
- @client.conn.expects(:exec).yields(nil)
38
25
  end
39
26
  should "not raise an exception" do
40
- assert_nothing_raised do
41
- @client.run("A NOOP")
42
- end
27
+ @client.run("SELECT NULL FROM DUAL")
43
28
  end
44
29
  end
45
30
 
@@ -74,13 +59,13 @@ class ClientTest < Test::Unit::TestCase
74
59
  end
75
60
 
76
61
  should "have logged something" do
77
- File.unlink(Oci8Simple::Client::LOG_FILE)
78
- assert(!File.exists?(Oci8Simple::Client::LOG_FILE))
62
+ File.unlink(Oci8Simple::Client::LOG_FILE_PATH)
63
+ assert(!File.exists?(Oci8Simple::Client::LOG_FILE_PATH))
79
64
  @client = Oci8Simple::Client.new("test")
80
65
  @client.run "select NULL from dual"
81
66
  @client.log_file.close
82
- assert(File.exists?(Oci8Simple::Client::LOG_FILE))
83
- assert(!(0 == File.size(Oci8Simple::Client::LOG_FILE)))
67
+ assert(File.exists?(Oci8Simple::Client::LOG_FILE_PATH))
68
+ assert(!(0 == File.size(Oci8Simple::Client::LOG_FILE_PATH)))
84
69
  end
85
70
  end
86
71
  end
@@ -1,5 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
- class DescribeTest < Test::Unit::TestCase
2
+ class DescribeTest < Minitest::Test
3
3
  context "Given a table and some data" do
4
4
  setup do
5
5
  @client = Oci8Simple::Client.new("test")
data/test/helper.rb CHANGED
@@ -7,14 +7,13 @@ rescue Bundler::BundlerError => e
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
- require 'test/unit'
10
+ require 'minitest/autorun'
11
11
  require 'shoulda'
12
- require 'mocha'
13
12
  require 'pry'
14
13
 
15
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
17
16
  require 'oci8_simple'
18
17
 
19
- class Test::Unit::TestCase
18
+ class Minitest::Test
20
19
  end
data/test/show_test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
- class ShowTest < Test::Unit::TestCase
2
+ class ShowTest < Minitest::Test
3
3
  def setup
4
4
  @client = Oci8Simple::Client.new("test")
5
5
  @show = Oci8Simple::Show.new("test")
@@ -19,15 +19,14 @@ class ShowTest < Test::Unit::TestCase
19
19
  SQL
20
20
  end
21
21
  should "list the tables" do
22
- assert_equal ["oci8_simple_test","oci8_simple_test_2"], @show.run("tables")
22
+ assert((["oci8_simple_test", "oci8_simple_test_2"] - @show.run("tables")).empty?)
23
23
  end
24
24
  end
25
25
 
26
26
  context "Show functions" do
27
27
  setup do
28
- @client.run "drop function oci8_simple_function" rescue nil
29
- @client.run <<-SQL
30
- CREATE FUNCTION oci8_simple_function
28
+ @fct = <<-SQL
29
+ CREATE OR REPLACE FUNCTION \"#{@client.config["username"]}\".\"OCI8_SIMPLE_FUNCTION\"
31
30
  RETURN NUMBER
32
31
  IS num NUMBER(1,0);
33
32
  BEGIN
@@ -35,24 +34,33 @@ class ShowTest < Test::Unit::TestCase
35
34
  RETURN(num);
36
35
  END
37
36
  SQL
37
+ @client.run "drop function oci8_simple_function" rescue nil
38
+ @client.run @fct
38
39
  end
39
40
  should "list the functions" do
40
- assert_equal ["oci8_simple_function"], @show.run("functions")
41
+ assert((["oci8_simple_function"] - @show.run("functions")).empty?)
42
+ end
43
+ should "show the function" do
44
+ assert_equal @fct.gsub(/\s+/,' '), @show.run("function", "oci8_simple_function").gsub(/\s+/,' ')
41
45
  end
42
46
  end
43
47
 
44
48
  context "Show packages" do
45
49
  setup do
46
- @client.run "drop package oci8_simple_package" rescue nil
47
- @client.run <<-SQL
48
- CREATE OR REPLACE PACKAGE oci8_simple_package AS
50
+ @pkg = <<-SQL
51
+ CREATE OR REPLACE PACKAGE \"#{@client.config["username"]}\".\"OCI8_SIMPLE_PACKAGE\" AS
49
52
  FUNCTION something(id NUMBER, foo NUMBER)
50
53
  RETURN NUMBER;
51
- END oci8_simple_package
54
+ END OCI8_SIMPLE_PACKAGE
52
55
  SQL
56
+ @client.run "drop package oci8_simple_package" rescue nil
57
+ @client.run @pkg
53
58
  end
54
59
  should "list the packages" do
55
- assert_equal ["oci8_simple_package"], @show.run("packages")
60
+ assert((["oci8_simple_package"] - @show.run("packages")).empty?)
61
+ end
62
+ should "show the package" do
63
+ assert_equal @pkg.gsub(/\s+/,' '), @show.run("package", "oci8_simple_package").gsub(/\s+/,' ')
56
64
  end
57
65
  end
58
66
 
@@ -67,7 +75,7 @@ class ShowTest < Test::Unit::TestCase
67
75
  SQL
68
76
  end
69
77
  should "list the procedures" do
70
- assert_equal ["oci8_simple_procedure"], @show.run("procedures")
78
+ assert((["oci8_simple_procedure"] - @show.run("procedures")).empty?)
71
79
  end
72
80
  end
73
81
 
@@ -79,7 +87,7 @@ class ShowTest < Test::Unit::TestCase
79
87
  SQL
80
88
  end
81
89
  should "list the sequences" do
82
- assert_equal ["oci8_simple_sequence"], @show.run("sequences")
90
+ assert((["oci8_simple_sequence"] - @show.run("sequences")).empty?)
83
91
  end
84
92
  end
85
93
 
@@ -92,7 +100,7 @@ class ShowTest < Test::Unit::TestCase
92
100
  SQL
93
101
  end
94
102
  should "list the synonyms" do
95
- assert_equal ["oci8_simple_synonym"], @show.run("synonyms")
103
+ assert((["oci8_simple_synonym"] - @show.run("synonyms")).empty?)
96
104
  end
97
105
  end
98
106
 
@@ -105,7 +113,7 @@ class ShowTest < Test::Unit::TestCase
105
113
  SQL
106
114
  end
107
115
  should "list the types" do
108
- assert_equal ["oci8_simple_type"], @show.run("types")
116
+ assert((["oci8_simple_type"] - @show.run("types")).empty?)
109
117
  end
110
118
  end
111
119
 
@@ -118,7 +126,7 @@ class ShowTest < Test::Unit::TestCase
118
126
  SQL
119
127
  end
120
128
  should "list the views" do
121
- assert_equal ["oci8_simple_view"], @show.run("views")
129
+ assert((["oci8_simple_view"] - @show.run("views")).empty?)
122
130
  end
123
131
  end
124
- end
132
+ end
metadata CHANGED
@@ -1,33 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oci8_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Billy Reisinger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ruby-oci8
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.1.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.1.2
30
- description: ! "Command-line tools for interacting with an Oracle database. This client
27
+ description: "Command-line tools for interacting with an Oracle database. This client
31
28
  is intended to be used \n to aid development and automation. This is *not* meant
32
29
  to replace an ORM such as ActiveRecord + OracleEnhancedAdapter.\n The only prerequisite
33
30
  to running this code is that you have installed the ruby-oci8 gem on your machine."
@@ -38,13 +35,13 @@ executables:
38
35
  - describe
39
36
  extensions: []
40
37
  extra_rdoc_files:
41
- - README.rdoc
38
+ - README.md
42
39
  files:
43
- - .document
40
+ - ".document"
44
41
  - Gemfile
45
42
  - Gemfile.lock
46
43
  - LICENSE.txt
47
- - README.rdoc
44
+ - README.md
48
45
  - Rakefile
49
46
  - VERSION
50
47
  - bin/describe
@@ -66,31 +63,24 @@ files:
66
63
  homepage: http://github.com/unclebilly/oci8_simple
67
64
  licenses:
68
65
  - MIT
66
+ metadata: {}
69
67
  post_install_message:
70
68
  rdoc_options: []
71
69
  require_paths:
72
70
  - lib
73
71
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
72
  requirements:
76
- - - ! '>='
73
+ - - ">="
77
74
  - !ruby/object:Gem::Version
78
75
  version: '0'
79
- segments:
80
- - 0
81
- hash: -4565524330145410759
82
76
  required_rubygems_version: !ruby/object:Gem::Requirement
83
- none: false
84
77
  requirements:
85
- - - ! '>='
78
+ - - ">="
86
79
  - !ruby/object:Gem::Version
87
80
  version: '0'
88
- segments:
89
- - 0
90
- hash: -4565524330145410759
91
81
  requirements: []
92
82
  rubyforge_project:
93
- rubygems_version: 1.8.25
83
+ rubygems_version: 2.4.6
94
84
  signing_key:
95
85
  specification_version: 3
96
86
  summary: Command-line tools for interacting with an Oracle database.
data/README.rdoc DELETED
@@ -1,124 +0,0 @@
1
- = oci8_simple
2
- This gem is a thin wrapper around the ruby-oci8 gem. The client is intended to be used by simple
3
- scripts to aid automation. The code is intentionally light-weight and featureless, with very little startup time.
4
- It is not meant to be a Ruby ORM for Oracle - if you want that, look at the OracleEnhancedAdapter.
5
-
6
- This gem installs a few command-line scripts:
7
- * <code>oci8_simple</code>
8
- * a command to run arbitrary SQL
9
- * <code>describe </code>
10
- * a command to describe a table
11
- * <code>show </code>
12
- * a command to list things in the database (tables, views, etc.)
13
- You can also use oci8_simple in your Ruby scripts by creating an instance of <code>Oci8Simple::Client</code>
14
- (see more below).
15
-
16
- == Prerequisites
17
- * Oracle Instant Client (http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html)
18
- * ruby-oci8
19
-
20
- == Installation
21
- gem install oci8_simple
22
-
23
- == Configuration
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.
29
- development:
30
- database: oracle.hostname:1521/sid
31
- username: foo_dev
32
- password: OMG333
33
- test:
34
- database: oracle.hostname:1521/sid
35
- username: foo_test
36
- password: OMG333
37
-
38
- == Logging
39
- All logging is done to <code>~/.oci8_simple/oci8_simple.log</code>.
40
-
41
- == Command-Line Examples
42
- === oci8_simple
43
- This script allows you to run single statements against an
44
- arbitrary Oracle schema via the command line.
45
-
46
- Run a query against development schema
47
- oci8_simple "select id, name from flavors"
48
-
49
- Run a query against a different schema
50
- oci8_simple "select id, name from flavors" int
51
-
52
- Help
53
- oci8_simple --help
54
-
55
- === describe
56
- This script shows a description of a table, including the column names (sorted),
57
- the type and size for each column, the nullable status of the column, and the default
58
- value, if any.
59
-
60
- Show column information for a table named "holidays"
61
- describe holidays
62
-
63
- Help
64
- describe --help
65
-
66
- === show
67
- This command can list the following items in the database:
68
- functions, packages, procedures, sequences, synonyms, tables, types, and views.
69
-
70
- Show a list of all tables in the database
71
- show tables
72
-
73
- Show a list of all views in the database
74
- show views
75
-
76
- Help
77
- show --help
78
-
79
- == Code Examples
80
- * Initialize a client against the development schema
81
- require 'rubygems'
82
- require 'oci8_simple'
83
- client = Oci8Simple::Client.new
84
- * Run a simple select query against development schema
85
- client.run('select id, name from foos') => [[2, "lol"], [3, "hey"], ...]
86
- client.run('select id, name from foos', :hash => true) => [{:id => 2, :name => "lol"}, {:id => 3, :name=>"hey"}, ...])
87
- * Update something
88
- client.run <<-SQL
89
- UPDATE foos SET bar='baz' WHERE id=1233
90
- SQL
91
- * Run some DDL
92
- client.run <<-SQL
93
- CREATE TABLE foos (
94
- ID NUMBER(38) NOT NULL
95
- )
96
- SQL
97
- * Run some PL/SQL
98
- client.run <<-SQL
99
- DECLARE
100
- a NUMBER;
101
- b NUMBER;
102
- BEGIN
103
- SELECT e,f INTO a,b FROM T1 WHERE e>1;
104
- INSERT INTO T1 VALUES(b,a);
105
- END;
106
- SQL
107
- * Run a query against stage schema
108
- Oci8Simple::Client.new("stage").run('select id, name from foos') => [[2, "lol"], [3, "hey"], ...]
109
-
110
- == Contributing to oci8_simple
111
-
112
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
113
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
114
- * Fork the project
115
- * Start a feature/bugfix branch
116
- * Commit and push until you are happy with your contribution
117
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
118
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
119
-
120
- == Copyright
121
-
122
- Copyright (c) 2011 Billy Reisinger. See LICENSE.txt for
123
- further details.
124
-