annotate_models 0.0.3 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d24a63b4122eeefd4d2b60b6c0040e8cbca75429
4
- data.tar.gz: e76b9331e6efc49948da7bd9939d065cba4a4a8c
3
+ metadata.gz: 67f11e008832b25c83aed3b235810e118793aeae
4
+ data.tar.gz: 04fe40992cdc385ca0aa7b65eadc18c527bdfd95
5
5
  SHA512:
6
- metadata.gz: 22962ee74ccc220ce6f4d6f16a17b07f7726e39052da879a68ac86e79e0b17c4184384148dfa5a9fc16f57858a18de3518242e115ce4851455fc57706b4d33ec
7
- data.tar.gz: d8bd00c8e264a12de8cb698e607edc2b4dd2a05e9f3c940a9b87b64d681b9cf71403d31cef02eb18442a6f5598d353f915f1d401df3ca2766adf2c84d2fb9e3c
6
+ metadata.gz: 54172c43dc2e1de8cbc817cef2eb73dc1b21d7b99312afe4b0fe6c4f71d4d57d49ee62333f0d11b8210836e59810fc2ee595f7f77f5cfd0533edf90649559da8
7
+ data.tar.gz: ad3f9059ded6240f1ae5090fb49e75221d448f0630d9c0fd662067e2717ff0a94b0226cc213d579f27ddf241f7d94ee8dd2d9c4407cfde4c5c81f4451261c48a
@@ -82,15 +82,17 @@ module AnnotateModels
82
82
  # @param model [Class] An ActiveRecord model class.
83
83
 
84
84
  def generate_annotation(model)
85
+ max_column_length = model.columns.collect { |c| c.name.length }.max
85
86
  annotation = []
86
87
  annotation << "#-#{'--' * 38}-"
87
88
  annotation << "# #{model.name}"
88
89
  annotation << "#"
89
- annotation << "# Name SQL Type Null Default Primary"
90
- annotation << "# ------------------------------ -------------------- ------- ------- -------"
90
+ annotation << sprintf("# %-#{max_column_length}s SQL Type Null Default Primary", "Name")
91
+ annotation << sprintf("# %s -------------------- ------- ------- -------", "-" * max_column_length)
92
+ format = "# %-#{max_column_length}s %-20s %-7s %-7s %-7s"
91
93
  model.columns.each do |column|
92
94
  annotation << sprintf(
93
- "# %-30s %-20s %-7s %-7s %-7s",
95
+ format,
94
96
  column.name,
95
97
  column.sql_type,
96
98
  column.null,
@@ -1,3 +1,3 @@
1
1
  module AnnotateModels
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate_models
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
  - Nathan Brazil
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-02-08 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: |-
14
28
  This is my own re-write of an earlier version https://github.com/ctran/annotate_models when work on it waned.
15
29
  This work started out as an old-style Rails plugin; I am now re-bundling it as a gem-ified plugin.