ymldot 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/ymldot +1 -1
  2. data/lib/ymldot.rb +7 -6
  3. metadata +2 -2
data/bin/ymldot CHANGED
@@ -9,7 +9,7 @@ end
9
9
  require 'ymldot'
10
10
  require 'optparse'
11
11
 
12
- Version = "0.0.1"
12
+ Version = "0.0.2"
13
13
  is_output = false
14
14
  opt = OptionParser.new
15
15
  opt.version = Version
data/lib/ymldot.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'yaml'
2
2
  require 'pp'
3
+ require 'util'
3
4
 
4
5
  class Entity
5
6
  def initialize(name, dependent, columns = [])
@@ -143,14 +144,14 @@ EOS
143
144
 
144
145
  def eval_relation_has_many(keys, tname)
145
146
  keys.each do |rel|
146
- @entity_dict[rel].foreignkeys << "#{tname}ID(FK)"
147
+ @entity_dict[rel].foreignkeys << "#{singularize(tname)}ID(FK)"
147
148
  @many_relations << {:self => @entity_dict[tname], :have => @entity_dict[rel]}
148
149
  end
149
150
  end
150
151
 
151
152
  def eval_relation_has_one(keys, tname)
152
153
  keys.each do |rel|
153
- @entity_dict[rel].foreignkeys << "#{tname}ID(FK)"
154
+ @entity_dict[rel].foreignkeys << "#{singularize(tname)}ID(FK)"
154
155
  @one_relations << {:self => @entity_dict[tname], :have => @entity_dict[rel]}
155
156
  end
156
157
  end
@@ -161,8 +162,8 @@ EOS
161
162
  return if @entity_dict.has_key? join_tname
162
163
  join_tname = "#{tname}_#{rel}"
163
164
  @entity_dict[join_tname] ||= Entity.new(join_tname, true)
164
- @entity_dict[join_tname].foreignkeys << "#{tname}ID(FK)"
165
- @entity_dict[join_tname].foreignkeys << "#{rel}ID(FK)"
165
+ @entity_dict[join_tname].foreignkeys << "#{singularize(tname)}ID(FK)"
166
+ @entity_dict[join_tname].foreignkeys << "#{singularize(rel)}ID(FK)"
166
167
 
167
168
  # make new category
168
169
  keys = []
@@ -177,8 +178,8 @@ EOS
177
178
 
178
179
  def eval_relation_polymorphic(keys, tname)
179
180
  keys.each do |rel|
180
- @entity_dict[tname].foreignkeys << "#{rel["name"]}ID(FK)" if key = rel["name"]
181
- @entity_dict[tname].columns.unshift "#{rel["type"]}(type)" if key = rel["type"]
181
+ @entity_dict[tname].foreignkeys << "#{singularize(rel["name"])}ID(FK)" if key = rel["name"]
182
+ @entity_dict[tname].columns.unshift "#{singularize(rel["type"])}(type)" if key = rel["type"]
182
183
  rel["tables"].each do |t|
183
184
  @one_relations << {:self => @entity_dict[t], :have => @entity_dict[tname] }
184
185
  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.1
4
+ version: 0.0.2
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-09-10 00:00:00 +09:00
12
+ date: 2008-09-29 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15