dbd4 1.0.3 → 1.0.4
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/bin/dbd4 +7 -7
- data/lib/dbd4/dbd4_model_file.rb +0 -4
- data/lib/dbd4/rails_migration_file.rb +1 -1
- data/lib/dbd4/rails_model_file.rb +9 -4
- metadata +4 -4
data/bin/dbd4
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#--
|
23
23
|
|
24
|
-
DBD4VERSION = '1.0.
|
24
|
+
DBD4VERSION = '1.0.4'
|
25
25
|
|
26
26
|
require 'getoptlong'
|
27
27
|
require 'dbd4/dbd4_model_file'
|
@@ -33,8 +33,8 @@ require 'dbd4/dbd4_model_file'
|
|
33
33
|
class DBD4Import
|
34
34
|
|
35
35
|
OPTIONS = [
|
36
|
-
['--
|
37
|
-
"Do a dry run without executing actions."],
|
36
|
+
['--validate-only', '-n', GetoptLong::NO_ARGUMENT,
|
37
|
+
"Do a dry run without executing actions, only validate the model."],
|
38
38
|
['--help', '-H', GetoptLong::NO_ARGUMENT,
|
39
39
|
"Display this help message."],
|
40
40
|
['--quiet', '-q', GetoptLong::NO_ARGUMENT,
|
@@ -81,8 +81,8 @@ class DBD4Import
|
|
81
81
|
# Do the option defined by +opt+ and +value+.
|
82
82
|
def do_option(opt, value)
|
83
83
|
case opt
|
84
|
-
when '--
|
85
|
-
$
|
84
|
+
when '--validate-only'
|
85
|
+
$validate_only = true
|
86
86
|
when '--help'
|
87
87
|
help
|
88
88
|
exit
|
@@ -92,7 +92,7 @@ class DBD4Import
|
|
92
92
|
usage
|
93
93
|
exit
|
94
94
|
when '--version'
|
95
|
-
puts "dbmodel, version #{
|
95
|
+
puts "dbmodel, version #{DBD4VERSION}"
|
96
96
|
exit
|
97
97
|
else
|
98
98
|
fail "Unknown option: #{opt}"
|
@@ -138,7 +138,7 @@ class DBD4Import
|
|
138
138
|
exit(1)
|
139
139
|
end
|
140
140
|
|
141
|
-
dbmf.generateModelFiles
|
141
|
+
dbmf.generateModelFiles unless $validate_only == true
|
142
142
|
puts "Done!"
|
143
143
|
end
|
144
144
|
rescue Exception => ex
|
data/lib/dbd4/dbd4_model_file.rb
CHANGED
@@ -83,8 +83,6 @@ module DBD4
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
|
87
|
-
|
88
86
|
class Table
|
89
87
|
attr_reader :id, :name, :columns, :relation_starts, :relation_ends, :modelname, :comments, :non_standard_name, :nm_table
|
90
88
|
attr_writer :modelfile, :name, :nm_table
|
@@ -107,7 +105,6 @@ module DBD4
|
|
107
105
|
column = Column.new(column_xml, self)
|
108
106
|
@primary_key = column if column.primary_key? and ! @primary_key
|
109
107
|
columns << column
|
110
|
-
|
111
108
|
end
|
112
109
|
|
113
110
|
def addEndRelation(e)
|
@@ -410,7 +407,6 @@ module DBD4
|
|
410
407
|
end
|
411
408
|
end
|
412
409
|
|
413
|
-
|
414
410
|
class Relations < OrderedHash
|
415
411
|
def <<(relation)
|
416
412
|
self[relation.id] = relation
|
@@ -112,7 +112,7 @@ end
|
|
112
112
|
MIGRATIONFILE
|
113
113
|
|
114
114
|
old_migration_file_content = IO.readlines(@migrationfile).join("")
|
115
|
-
if (old_migration_file_content != new_migration_file_content)
|
115
|
+
if (old_migration_file_content != new_migration_file_content)
|
116
116
|
puts "Updating migration file for table #{@tablename} (file : #{@migrationfile})..."
|
117
117
|
newFile = File.open(@migrationfile, "w")
|
118
118
|
newFile.puts new_migration_file_content
|
@@ -67,7 +67,7 @@ module DBD4
|
|
67
67
|
@modelfile = File.join('app', 'models', Inflector.underscore(Inflector.camelize(@modelname)) + ".rb")
|
68
68
|
if ! FileTest.exist?(@modelfile)
|
69
69
|
puts "Generating model #{@modelname}..."
|
70
|
-
generate
|
70
|
+
generate
|
71
71
|
end
|
72
72
|
load
|
73
73
|
end
|
@@ -277,9 +277,14 @@ module DBD4
|
|
277
277
|
original_document_modified = @lines <=> @original_lines
|
278
278
|
|
279
279
|
if (original_document_modified != 0)
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
if ($dryrun == true)
|
281
|
+
puts "Would of updated model #{@modelname} (file : #{@modelfile}) with content : "
|
282
|
+
puts @lines
|
283
|
+
else
|
284
|
+
puts "Updating model #{@modelname} (file : #{@modelfile})..."
|
285
|
+
newFile = File.open(@modelfile, "w")
|
286
|
+
newFile.puts @lines
|
287
|
+
end
|
283
288
|
end
|
284
289
|
end
|
285
290
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: dbd4
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2006-08-
|
6
|
+
version: 1.0.4
|
7
|
+
date: 2006-08-24 00:00:00 -04:00
|
8
8
|
summary: A package for importing DB Designer 4 xml models in rails.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,10 +30,10 @@ authors:
|
|
30
30
|
- Daniel Shane
|
31
31
|
files:
|
32
32
|
- lib/slurp.rb
|
33
|
-
- lib/dbd4/rails_migration_file.rb
|
34
|
-
- lib/dbd4/rails_model_file.rb
|
35
33
|
- lib/dbd4/dbd4_model_file.rb
|
36
34
|
- lib/dbd4/ordered_hash.rb
|
35
|
+
- lib/dbd4/rails_migration_file.rb
|
36
|
+
- lib/dbd4/rails_model_file.rb
|
37
37
|
- bin/dbd4
|
38
38
|
- README
|
39
39
|
test_files:
|