oracle-model-generator 0.4.1 → 0.5.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.
metadata CHANGED
@@ -1,79 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oracle-model-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
14
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
16
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
18
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
19
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
20
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
21
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97u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MZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
24
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
25
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
27
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
28
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
29
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
30
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
31
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
32
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
33
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
34
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
35
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
32
37
  -----END CERTIFICATE-----
33
- date: 2016-02-01 00:00:00.000000000 Z
38
+ date: 2025-07-23 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: ruby-oci8
37
42
  requirement: !ruby/object:Gem::Requirement
38
43
  requirements:
39
- - - ">="
44
+ - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '0'
46
+ version: '2.2'
42
47
  type: :runtime
43
48
  prerelease: false
44
49
  version_requirements: !ruby/object:Gem::Requirement
45
50
  requirements:
46
- - - ">="
51
+ - - "~>"
47
52
  - !ruby/object:Gem::Version
48
- version: '0'
53
+ version: '2.2'
49
54
  - !ruby/object:Gem::Dependency
50
55
  name: getopt
51
56
  requirement: !ruby/object:Gem::Requirement
52
57
  requirements:
53
- - - ">="
58
+ - - "~>"
54
59
  - !ruby/object:Gem::Version
55
- version: '0'
60
+ version: '1.6'
56
61
  type: :runtime
57
62
  prerelease: false
58
63
  version_requirements: !ruby/object:Gem::Requirement
59
64
  requirements:
60
- - - ">="
65
+ - - "~>"
61
66
  - !ruby/object:Gem::Version
62
- version: '0'
67
+ version: '1.6'
63
68
  - !ruby/object:Gem::Dependency
64
- name: test-unit
69
+ name: rspec
65
70
  requirement: !ruby/object:Gem::Requirement
66
71
  requirements:
67
- - - ">="
72
+ - - "~>"
68
73
  - !ruby/object:Gem::Version
69
- version: '0'
74
+ version: '3.12'
70
75
  type: :development
71
76
  prerelease: false
72
77
  version_requirements: !ruby/object:Gem::Requirement
73
78
  requirements:
74
- - - ">="
79
+ - - "~>"
75
80
  - !ruby/object:Gem::Version
76
- version: '0'
81
+ version: '3.12'
77
82
  description: |2
78
83
  The oracle-model-generator library allows you to generate an ActiveRecord
79
84
  model from an existing Oracle table or view, as well as automatically
@@ -82,32 +87,31 @@ email: djberg96@gmail.com
82
87
  executables:
83
88
  - omg
84
89
  extensions: []
85
- extra_rdoc_files:
86
- - CHANGES
87
- - README
88
- - MANIFEST
90
+ extra_rdoc_files: []
89
91
  files:
90
- - bin
92
+ - CHANGES.md
93
+ - DOCKER.md
94
+ - Dockerfile
95
+ - Gemfile
96
+ - LICENSE
97
+ - MANIFEST.md
98
+ - README-Docker.md
99
+ - README.md
100
+ - Rakefile
91
101
  - bin/omg
92
- - certs
93
102
  - certs/djberg96_pub.pem
94
- - CHANGES
95
- - lib
96
- - lib/oracle
97
- - lib/oracle/model
98
- - lib/oracle/model/generator.rb
103
+ - docker-compose.yml
99
104
  - lib/oracle-model-generator.rb
100
- - MANIFEST
105
+ - lib/oracle/model/generator.rb
101
106
  - oracle-model-generator.gemspec
102
- - Rakefile
103
- - README
104
- - test
105
- - test/test_oracle_model_generator.rb
107
+ - spec/oracle_model_generator_spec.rb
108
+ - spec/spec_helper.rb
109
+ - spec/support/oracle_connection.rb
106
110
  homepage: http://www.github.com/djberg96/oracle-model-generator
107
111
  licenses:
108
- - Artistic 2.0
112
+ - Apache-2.0
109
113
  metadata: {}
110
- post_install_message:
114
+ post_install_message:
111
115
  rdoc_options: []
112
116
  require_paths:
113
117
  - lib
@@ -122,10 +126,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
126
  - !ruby/object:Gem::Version
123
127
  version: '0'
124
128
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.4.5.1
127
- signing_key:
129
+ rubygems_version: 3.5.22
130
+ signing_key:
128
131
  specification_version: 4
129
132
  summary: A Ruby interface for determining protocol information
130
133
  test_files:
131
- - test/test_oracle_model_generator.rb
134
+ - spec/oracle_model_generator_spec.rb
135
+ - spec/spec_helper.rb
136
+ - spec/support/oracle_connection.rb
metadata.gz.sig CHANGED
Binary file
data/README DELETED
@@ -1,150 +0,0 @@
1
- = Description
2
- A library for generating an ActiveRecord model from an existing Oracle table.
3
- This will install an "omg" executable that you can use from the command line.
4
-
5
- = Synopsis
6
- Using the command line tool:
7
-
8
- omg -d your_database -t locations -u some_user -p some_password
9
-
10
- The above command results in a file called "location.rb". This is an
11
- ActiveRecord model declaration, with all validations, primary keys,
12
- table name and belongs_to relationships defined.
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 Location < 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
-
52
- It will also generate a corresponding test file using test-unit 2 by default.
53
- For the above example you will see some tests like this:
54
-
55
- class TC_Location < Test::Unit::TestCase
56
- def setup
57
- @location = Location.new
58
- end
59
-
60
- test 'table name is locations' do
61
- assert_equal('locations', Location.table_name)
62
- end
63
-
64
- test 'primary key is location_id' do
65
- assert_equal('location_id', Location.primary_key)
66
- end
67
-
68
- test 'location_id basic functionality' do
69
- assert_respond_to(@location, :location_id)
70
- assert_nothing_raised{ @location.location_id }
71
- assert_kind_of(Numeric, @location.location_id)
72
- end
73
-
74
- test 'location_id must be a number' do
75
- @location.location_id = 'test_string'
76
- assert_false(@location.valid?)
77
- assert_true(@location.errors[:location_id].include?('is not a number'))
78
- end
79
-
80
- test 'location_id cannot exceed the value 9999' do
81
- @location.location_id = 10000
82
- assert_false(@location.valid?)
83
- assert_true(@location.errors[:location_id].include?('must be less than or equal to 9999'))
84
- end
85
-
86
- # ... and so on.
87
- end
88
-
89
- = Requirements
90
- == Must Have
91
- * ruby-oci8
92
- * getopt
93
-
94
- == Optional
95
- If you want to be able to avoid specifying a username and password on the
96
- command line then you will need the dbi-dbrc library.
97
-
98
- If you want your models to support multiple primary keys, then you will
99
- need to install the composite_primary_keys library.
100
-
101
- If you want date format validations, then you will need to install the
102
- validates_timeliness library.
103
-
104
- = What this library doesn't do
105
- I do not attempt to set has_many or has_one relationships. There's no good
106
- way to determine that relationship (one or many?). Besides, in practice I
107
- find that most people set custom has_xxx relationships that go over and
108
- above what's set in the Oracle database anyway for purposes of their
109
- application.
110
-
111
- I also do not go out of my way to get the model name correct with regards
112
- to singular vs plural. I do a simple guess that covers most cases, but
113
- complex cases will break it. It's much easier for you to rename a class or
114
- file name than it is for me to get this 100% correct. As of 0.3.1 there's
115
- also the --class option that let's you eplicitly set it if you like.
116
-
117
- = Author's Comments
118
- I chose not to patch legacy_data because I have no interest in supporting
119
- other vendors other than Oracle with this library. By focusing only on
120
- Oracle I could take advantage of ruby-oci8 features. In addition, I have no
121
- interest in making this a Rails plugin, and I needed the support of multiple
122
- primary keys.
123
-
124
- = Future Plans
125
- Add support for views.
126
- Add automatic test suite generation for rspec.
127
- Explicitly set :foreign_key if using CPK in belongs_to relationships.
128
- The output could use a little formatting love.
129
-
130
- = Acknowlegements
131
- Thanks go to Daniel Luna for his --class patch.
132
-
133
- = Known Issues
134
- None known. If you find any issues, please report them on the github project
135
- page at http://www.github.com/djberg96/oracle-model-generator.
136
-
137
- = Warranty
138
- This package is provided "as is" and without any express or
139
- implied warranties, including, without limitation, the implied
140
- warranties of merchantability and fitness for a particular purpose.
141
-
142
- = Copyright
143
- (C) 2010-2016 Daniel J. Berger
144
- All Rights Reserved
145
-
146
- = License
147
- Artistic 2.0
148
-
149
- = Author
150
- Daniel J. Berger
@@ -1,68 +0,0 @@
1
- #############################################################################
2
- # test_oracle_model_generator.rb
3
- #
4
- # Test suite for the oracle-model-generator library. For testing purposes
5
- # I'm using the 'hr' database that comes as part of the Oracle Express
6
- # edition which you can download from oracle.com. Adjust as necessary.
7
- #############################################################################
8
- require 'test-unit'
9
- require 'oracle/model/generator'
10
-
11
- class TC_Oracle_Model_Generator < Test::Unit::TestCase
12
- def setup
13
- @username = 'hr'
14
- @password = 'hr'
15
- @database = 'xe'
16
- @generator = nil
17
- @connection = OCI8.new(@username, @password, @database)
18
- end
19
-
20
- test "version number is correct" do
21
- assert_equal('0.4.1', Oracle::Model::Generator::VERSION)
22
- end
23
-
24
- test "constructor accepts an oci8 connection object" do
25
- assert_nothing_raised{ @generator = Oracle::Model::Generator.new(@connection) }
26
- end
27
-
28
- test "generate method basic functionality" do
29
- assert_nothing_raised{ @generator = Oracle::Model::Generator.new(@connection) }
30
- assert_respond_to(@generator, :generate)
31
- end
32
-
33
- test "generate method works with a table name or view" do
34
- @generator = Oracle::Model::Generator.new(@connection)
35
- assert_nothing_raised{ @generator.generate('employees') }
36
- assert_nothing_raised{ @generator.generate('emp_details_view', true) }
37
- end
38
-
39
- test "model method returns active record model name" do
40
- @generator = Oracle::Model::Generator.new(@connection)
41
- @generator.generate('emp_details_view', true)
42
- assert_respond_to(@generator, :model)
43
- assert_equal('EmpDetailsView', @generator.model)
44
- end
45
-
46
- test "table method returns uppercased table name passed to generate method" do
47
- @generator = Oracle::Model::Generator.new(@connection)
48
- @generator.generate('emp_details_view', true)
49
- assert_respond_to(@generator, :table)
50
- assert_equal('EMP_DETAILS_VIEW', @generator.table)
51
- end
52
-
53
- test "dependencies method returns an array of hashes" do
54
- @generator = Oracle::Model::Generator.new(@connection)
55
- @generator.generate('employees', true)
56
- assert_respond_to(@generator, :dependencies)
57
- assert_kind_of(Array, @generator.dependencies)
58
- assert_kind_of(Hash, @generator.dependencies.first)
59
- end
60
-
61
- def teardown
62
- @username = nil
63
- @password = nil
64
- @database = nil
65
- @generator = nil
66
- @connection.logoff if @connection
67
- end
68
- end