ymldot 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/ymldot +2 -2
  2. data/lib/util.rb +48 -0
  3. data/lib/ymldot.rb +4 -2
  4. metadata +3 -2
data/bin/ymldot CHANGED
@@ -9,12 +9,12 @@ end
9
9
  require 'ymldot'
10
10
  require 'optparse'
11
11
 
12
- Version = "0.0.2"
12
+ Version = "0.0.5"
13
13
  is_output = false
14
14
  is_csv = false
15
15
  opt = OptionParser.new
16
16
  opt.version = Version
17
- opt.release = "0.0.1"
17
+ opt.release = "0.1.0"
18
18
  opt.on('-o', 'output file to current directory. name is "#{input_filename}.dot"') {|v| is_output = true }
19
19
  opt.on('-c', '--csv', 'csv format output') {|v| is_csv = true }
20
20
  opt.parse!(ARGV)
data/lib/util.rb ADDED
@@ -0,0 +1,48 @@
1
+ # by activesupport/lib/active_support/inflector.rb
2
+
3
+ @@singular = []
4
+
5
+ def add_singular(rule, replace)
6
+ @@singular << [rule, replace]
7
+ end
8
+
9
+ add_singular(/s$/i, '')
10
+ add_singular(/(n)ews$/i, '\1ews')
11
+ add_singular(/([ti])a$/i, '\1um')
12
+ add_singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
13
+ add_singular(/(^analy)ses$/i, '\1sis')
14
+ add_singular(/([^f])ves$/i, '\1fe')
15
+ add_singular(/(hive)s$/i, '\1')
16
+ add_singular(/(tive)s$/i, '\1')
17
+ add_singular(/([lr])ves$/i, '\1f')
18
+ add_singular(/([^aeiouy]|qu)ies$/i, '\1y')
19
+ add_singular(/(s)eries$/i, '\1eries')
20
+ add_singular(/(m)ovies$/i, '\1ovie')
21
+ add_singular(/(x|ch|ss|sh)es$/i, '\1')
22
+ add_singular(/([m|l])ice$/i, '\1ouse')
23
+ add_singular(/(bus)es$/i, '\1')
24
+ add_singular(/(o)es$/i, '\1')
25
+ add_singular(/(shoe)s$/i, '\1')
26
+ add_singular(/(cris|ax|test)es$/i, '\1is')
27
+ add_singular(/(octop|vir)i$/i, '\1us')
28
+ add_singular(/(alias|status)es$/i, '\1')
29
+ add_singular(/^(ox)en/i, '\1')
30
+ add_singular(/(vert|ind)ices$/i, '\1ex')
31
+ add_singular(/(matr)ices$/i, '\1ix')
32
+ add_singular(/(quiz)zes$/i, '\1')
33
+
34
+ # The reverse of +pluralize+, returns the singular form of a word in a string.
35
+ #
36
+ # Examples:
37
+ # "posts".singularize # => "post"
38
+ # "octopi".singularize # => "octopus"
39
+ # "sheep".singluarize # => "sheep"
40
+ # "word".singluarize # => "word"
41
+ # "the blue mailmen".singularize # => "the blue mailman"
42
+ # "CamelOctopi".singularize # => "CamelOctopus"
43
+ def singularize(word)
44
+ result = word.to_s.dup
45
+ @@singular.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
46
+ result
47
+ end
48
+
data/lib/ymldot.rb CHANGED
@@ -125,7 +125,9 @@ EOS
125
125
  def config_to_dot
126
126
  res = ""
127
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"]
128
+ if @config["size"] && @config["size"]["x"] && @config["size"]["y"]
129
+ res << %Q!graph [size="#{(@config["size"]["x"]/2.54).round},#{(@config["size"]["y"]/2.54).round}"]\n!
130
+ end
129
131
  raise "Error: please seto 'font'" if @config["ja"] && @config["font"]
130
132
  res << %Q!node [fontname="#{@config["font"]}"]! if @config["font"]
131
133
  res
@@ -217,7 +219,7 @@ EOS
217
219
  @entity_dict[tname].foreignkeys << append_fk_str(singularize(rel["name"])) if key = rel["name"]
218
220
  @entity_dict[tname].columns.unshift "#{singularize(rel["type"])}(type)" if key = rel["type"]
219
221
  rel["tables"].each do |t|
220
- @one_relations << {:self => @entity_dict[t], :have => @entity_dict[tname] }
222
+ @many_relations << {:self => @entity_dict[t], :have => @entity_dict[tname] }
221
223
  end
222
224
  end
223
225
  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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - nari
@@ -25,6 +25,7 @@ files:
25
25
  - README
26
26
  - bin/ymldot
27
27
  - lib/ymldot.rb
28
+ - lib/util.rb
28
29
  - sample/sample.dot
29
30
  - sample/sample.png
30
31
  - sample/sample.yml
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  requirements: []
54
55
 
55
56
  rubyforge_project: ymldot
56
- rubygems_version: 1.1.1
57
+ rubygems_version: 1.3.1
57
58
  signing_key:
58
59
  specification_version: 2
59
60
  summary: Can describe ERD in a from of ".yml"