oracle-model-generator 0.2.0 → 0.2.1
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/CHANGES +5 -0
- data/README +42 -2
- data/bin/omg +13 -1
- data/lib/oracle/model/generator.rb +1 -1
- data/oracle-model-generator.gemspec +1 -1
- data/test/test_oracle_model_generator.rb +1 -1
- metadata +5 -5
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 0.2.1 - 3-May-2011
|
2
|
+
* Fixed a bug where the omg binary blew up if you didn't have the dbi-dbrc
|
3
|
+
library installed. It's supposed to be optional. Thanks go to Jason Roth
|
4
|
+
for the spot.
|
5
|
+
|
1
6
|
= 0.2.0 - 8-Mar-2011
|
2
7
|
* Added the -r/--rails command line option. By default the omg binary will
|
3
8
|
now generate Rails 3 style validations. If you want Rails 2 validations,
|
data/README
CHANGED
@@ -5,12 +5,50 @@ This will install an "omg" executable that you can use from the command line.
|
|
5
5
|
= Synopsis
|
6
6
|
Using the command line tool:
|
7
7
|
|
8
|
-
omg -d your_database -t
|
8
|
+
omg -d your_database -t locations -u some_user -p some_password
|
9
9
|
|
10
|
-
Results in a file called "
|
10
|
+
Results in a file called "locations.rb". This is an ActiveRecord model
|
11
11
|
declaration, with all validations, primary keys, table name and belongs_to
|
12
12
|
relationships defined.
|
13
13
|
|
14
|
+
If your locations table looks like this:
|
15
|
+
|
16
|
+
create table locations(
|
17
|
+
location_id number(4,0) primary key,
|
18
|
+
street_address varchar2(40),
|
19
|
+
postal_code varchar2(12),
|
20
|
+
city varchar2(30) not null
|
21
|
+
state_province varchar2(25),
|
22
|
+
country_id CHAR(2),
|
23
|
+
constraint "LOC_C_ID_FK" FOREIGN KEY (country_id)
|
24
|
+
references COUNTRIES (country_id)
|
25
|
+
)
|
26
|
+
|
27
|
+
The omg library will generate this:
|
28
|
+
|
29
|
+
class Locations < ActiveRecord::Base
|
30
|
+
set_table_name :locations
|
31
|
+
set_primary_key :location_id
|
32
|
+
|
33
|
+
# Table relationships
|
34
|
+
|
35
|
+
belongs_to :countries
|
36
|
+
|
37
|
+
# Validations
|
38
|
+
|
39
|
+
validates :location_id, :presence => true, :numericality => {
|
40
|
+
:less_than_or_equal_to => 9999,
|
41
|
+
:greater_than_or_equal_to => -9999,
|
42
|
+
:only_integer => true
|
43
|
+
}
|
44
|
+
|
45
|
+
validates :street_address, :length => {:maximum => 40}
|
46
|
+
validates :postal_code, :length => {:maximum => 12}
|
47
|
+
validates :city, :length => {:maximum => 30}, :presence => true
|
48
|
+
validates :state_province, :length => {:maximum => 25}
|
49
|
+
validates :country_id, :length => {:maximum => 2}
|
50
|
+
end
|
51
|
+
|
14
52
|
= Requirements
|
15
53
|
== Must Have
|
16
54
|
* ruby-oci8
|
@@ -48,6 +86,8 @@ primary keys.
|
|
48
86
|
= Future Plans
|
49
87
|
Add support for views.
|
50
88
|
Add automatic test suite generation.
|
89
|
+
Explicitly set :foreign_key if using CPK in belongs_to relationships.
|
90
|
+
The output could use a little formatting love.
|
51
91
|
|
52
92
|
= Known Issues
|
53
93
|
None known. If you find any issues, please report them on the github project
|
data/bin/omg
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'oracle/model/generator'
|
4
|
-
require 'dbi/dbrc'
|
5
4
|
require 'getopt/long'
|
6
5
|
|
6
|
+
begin
|
7
|
+
require 'dbi/dbrc'
|
8
|
+
rescue LoadError
|
9
|
+
# Do nothing. Users must specify username/password information on the
|
10
|
+
# command line via the -u and -p options.
|
11
|
+
end
|
12
|
+
|
7
13
|
opts = Getopt::Long.getopts(
|
8
14
|
['--help', '-h'],
|
9
15
|
['--table', '-t', Getopt::REQUIRED],
|
@@ -77,6 +83,12 @@ unless user && pass
|
|
77
83
|
dbrc = DBI::DBRC.new(opts['database'], user)
|
78
84
|
user = dbrc.user
|
79
85
|
pass = dbrc.passwd
|
86
|
+
rescue NameError
|
87
|
+
msg = "If you do not specify a username or password on the command line "
|
88
|
+
msg << "then you must use the dbi-dbrc library and create a .dbrc file in "
|
89
|
+
msg << "your home directory."
|
90
|
+
puts msg
|
91
|
+
exit!
|
80
92
|
rescue DBI::DBRC::Error
|
81
93
|
msg = "No user or password provided, and no dbrc entry found for '"
|
82
94
|
msg << opts['database'] + "'."
|
@@ -13,7 +13,7 @@ class TC_Oracle_Model_Generator < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
test "version number is correct" do
|
16
|
-
assert_equal('0.2.
|
16
|
+
assert_equal('0.2.1', Oracle::Model::Generator::VERSION)
|
17
17
|
end
|
18
18
|
|
19
19
|
test "constructor accepts an oci8 connection object" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oracle-model-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel J. Berger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03
|
18
|
+
date: 2011-05-03 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements: []
|
115
115
|
|
116
116
|
rubyforge_project: N/A
|
117
|
-
rubygems_version: 1.6.
|
117
|
+
rubygems_version: 1.6.2
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
120
|
summary: A Ruby interface for determining protocol information
|