ymldot 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +13 -0
  2. data/lib/ymldot.rb +20 -8
  3. metadata +2 -2
data/README CHANGED
@@ -20,6 +20,13 @@ please see ymldot --help
20
20
  * config
21
21
  * font
22
22
  * Please set the font name that You want to use.
23
+ * size
24
+ * Please set the image size(cm).
25
+ * x, y
26
+ * lang
27
+ * en - english(default)
28
+ * ja - japanese
29
+
23
30
  * tables
24
31
  * name
25
32
  * table name
@@ -46,6 +53,12 @@ please see ymldot --help
46
53
  == Sample
47
54
  * in file. "sample/sample.yml"
48
55
 
56
+ config:
57
+ font: MSUIGOTHIC.ttf
58
+ size:
59
+ x: 13
60
+ y: 8
61
+
49
62
  tables:
50
63
  - name: customer
51
64
  columns:
data/lib/ymldot.rb CHANGED
@@ -124,7 +124,9 @@ EOS
124
124
 
125
125
  def config_to_dot
126
126
  res = ""
127
- res << "graph[overlap=false, splines=true]\n"
127
+ res << "graph [overlap=false, splines=true]\n"
128
+ res << %Q!graph [size="#{@config["size"]["x"]/2.54},#{@config["size"]["y"]/2.54}"]\n! if @config["size"] && @config["size"]["x"] && @config["size"]["y"]
129
+ raise "Error: please seto 'font'" if @config["ja"] && @config["font"]
128
130
  res << %Q!node [fontname="#{@config["font"]}"]! if @config["font"]
129
131
  res
130
132
  end
@@ -177,7 +179,7 @@ EOS
177
179
  def eval_relation_has_many(keys, tname)
178
180
  keys.each do |rel|
179
181
  raise "Error Relation! has many #{tname} to #{rel}" if @entity_dict[rel] == nil
180
- @entity_dict[rel].foreignkeys << "#{singularize(tname)}ID(FK)"
182
+ @entity_dict[rel].foreignkeys << append_fk_str(singularize(tname))
181
183
  @many_relations << {:self => @entity_dict[tname], :have => @entity_dict[rel]}
182
184
  end
183
185
  end
@@ -185,7 +187,7 @@ EOS
185
187
  def eval_relation_has_one(keys, tname)
186
188
  keys.each do |rel|
187
189
  raise "Error Relation! has one #{tname} to #{rel}" if @entity_dict[rel] == nil
188
- @entity_dict[rel].foreignkeys << "#{singularize(tname)}ID(FK)"
190
+ @entity_dict[rel].foreignkeys << append_fk_str(singularize(tname))
189
191
  @one_relations << {:self => @entity_dict[tname], :have => @entity_dict[rel]}
190
192
  end
191
193
  end
@@ -196,13 +198,13 @@ EOS
196
198
  return if @entity_dict.has_key? join_tname
197
199
  join_tname = "#{tname}_#{rel}"
198
200
  @entity_dict[join_tname] ||= Entity.new(join_tname, true)
199
- @entity_dict[join_tname].foreignkeys << "#{singularize(tname)}ID(FK)"
200
- @entity_dict[join_tname].foreignkeys << "#{singularize(rel)}ID(FK)"
201
+ @entity_dict[join_tname].foreignkeys << append_fk_str(singularize(tname))
202
+ @entity_dict[join_tname].foreignkeys << append_fk_str(singularize(rel))
201
203
 
202
204
  # make new category
203
205
  keys = []
204
- keys << "#{tname}ID(FK)"
205
- keys << "#{rel}ID(FK)"
206
+ keys << append_fk_str(tname)
207
+ keys << append_fk_str(rel)
206
208
  @category << Tables.new([{"name" => join_tname, "columns" => keys}])
207
209
 
208
210
  @many_relations << {:self => @entity_dict[tname], :have => @entity_dict[join_tname]}
@@ -212,11 +214,21 @@ EOS
212
214
 
213
215
  def eval_relation_polymorphic(keys, tname)
214
216
  keys.each do |rel|
215
- @entity_dict[tname].foreignkeys << "#{singularize(rel["name"])}ID(FK)" if key = rel["name"]
217
+ @entity_dict[tname].foreignkeys << append_fk_str(singularize(rel["name"])) if key = rel["name"]
216
218
  @entity_dict[tname].columns.unshift "#{singularize(rel["type"])}(type)" if key = rel["type"]
217
219
  rel["tables"].each do |t|
218
220
  @one_relations << {:self => @entity_dict[t], :have => @entity_dict[tname] }
219
221
  end
220
222
  end
221
223
  end
224
+
225
+ def append_fk_str(key)
226
+ @config["lang"] ||= "en"
227
+ case @config["lang"]
228
+ when "en"
229
+ return "#{key}_id(FK)"
230
+ when "ja"
231
+ return "#{key}ID(FK)"
232
+ end
233
+ end
222
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ymldot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nari
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-21 00:00:00 +09:00
12
+ date: 2008-10-22 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15